[docmaker] Use field values as HTML link targets where possible. * src/tools/docmaker/tohtml.py (HtmlFormatter::make_block_url): Accept second, optional argument to specify a name. (HtmlFormatter::html_source_quote): Link to field ID if possible. (HtmlFormatter::print_html_field_list): Emit `id' attribute.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
diff --git a/ChangeLog b/ChangeLog
index 083c131..fef862e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2014-11-29 Werner Lemberg <wl@gnu.org>
+ [docmaker] Use field values as HTML link targets where possible.
+
+ * src/tools/docmaker/tohtml.py (HtmlFormatter::make_block_url):
+ Accept second, optional argument to specify a name.
+ (HtmlFormatter::html_source_quote): Link to field ID if possible.
+ (HtmlFormatter::print_html_field_list): Emit `id' attribute.
+
+2014-11-29 Werner Lemberg <wl@gnu.org>
+
[docmaker] Allow empty lines in `<Order>' blocks.
Before this patch, the suggested order of entries stopped at the
diff --git a/src/tools/docmaker/tohtml.py b/src/tools/docmaker/tohtml.py
index aa1a7a9..e570034 100644
--- a/src/tools/docmaker/tohtml.py
+++ b/src/tools/docmaker/tohtml.py
@@ -306,8 +306,10 @@ class HtmlFormatter( Formatter ):
def make_section_url( self, section ):
return self.file_prefix + section.name + ".html"
- def make_block_url( self, block ):
- return self.make_section_url( block.section ) + "#" + block.name
+ def make_block_url( self, block, name = None ):
+ if name == None:
+ name = block.name
+ return self.make_section_url( block.section ) + "#" + name
def make_html_word( self, word ):
"""Analyze a simple word to detect cross-references and markup."""
@@ -412,8 +414,18 @@ class HtmlFormatter( Formatter ):
elif self.identifiers.has_key( name ):
# this is a known identifier
block = self.identifiers[name]
+ id = block.name
+
+ # link to a field ID if possible
+ for markup in block.markups:
+ if markup.tag == 'values':
+ for field in markup.fields:
+ if field.name:
+ id = name
+
result = ( result + prefix
- + '<a href="' + self.make_block_url( block )
+ + '<a href="'
+ + self.make_block_url( block, id )
+ '">' + name + '</a>' )
else:
result = result + html_quote( line[:length] )
@@ -428,7 +440,7 @@ class HtmlFormatter( Formatter ):
def print_html_field_list( self, fields ):
print '<table class="fields">'
for field in fields:
- print ( '<tr><td class="val">'
+ print ( '<tr><td class="val" id="' + field.name + '">'
+ field.name
+ '</td><td class="desc">' )
self.print_html_items( field.items )