[telepathy-doc/master] Fix linking support for full-file includes

Davyd Madeley davyd at madeley.id.au
Thu Apr 2 03:05:55 PDT 2009


---
 docs/book/insert-examples.py |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/docs/book/insert-examples.py b/docs/book/insert-examples.py
index c1d6d7f..8d81419 100755
--- a/docs/book/insert-examples.py
+++ b/docs/book/insert-examples.py
@@ -61,6 +61,8 @@ for example in examples:
 	if id is not None:
 		included_files[nicename].append (id)
 
+	xmlname = re.sub (r'/', '.', nicename)
+
 	if id:
 		print >> sys.stderr, "Including `%s' from `%s'..." % (id, filename)
 
@@ -90,9 +92,16 @@ for example in examples:
 			trim = min ([ leading_space(s) for s in lines if s != "" ])
 
 			contents = '\n'.join (map (lambda s: s[trim:], lines))
+
+			linkid = 'anchor.%s.%s' % (xmlname, id)
+		else:
+			linkid = 'appendix.source-code.%s' % xmlname
+
 	else:
 		print >> sys.stderr, "Including file `%s'..." % filename
 
+		linkid = 'appendix.source-code.%s' % xmlname
+
 	if pygments:
 		# syntax highlighting
 		lexer = pygments.lexers.get_lexer_for_filename (filename)
@@ -104,8 +113,7 @@ for example in examples:
 
 	etree.SubElement (example, 'programlisting').append (etree.XML (contents))
 	p = etree.SubElement (example, 'para')
-	xmlname = re.sub (r'/', '.', nicename)
-	etree.SubElement (p, 'link', linkend='anchor.%s.%s' % (xmlname, id)).text = "Complete Source Code"
+	etree.SubElement (p, 'link', linkend=linkid).text = "Complete Source Code"
 
 	f.close ()
 
-- 
1.5.6.5



More information about the telepathy-commits mailing list