[Python-checkins] r56772 - in doctools/trunk/sphinx: style/doctools.js writer.py

georg.brandl python-checkins at python.org
Mon Aug 6 18:51:47 CEST 2007


Author: georg.brandl
Date: Mon Aug  6 18:51:47 2007
New Revision: 56772

Modified:
   doctools/trunk/sphinx/style/doctools.js
   doctools/trunk/sphinx/writer.py
Log:
Add header links statically.


Modified: doctools/trunk/sphinx/style/doctools.js
==============================================================================
--- doctools/trunk/sphinx/style/doctools.js	(original)
+++ doctools/trunk/sphinx/style/doctools.js	Mon Aug  6 18:51:47 2007
@@ -94,7 +94,7 @@
 var Documentation = {
 
   init : function() {
-    this.addContextElements();
+    /* this.addContextElements(); -- now done statically */
     this.fixFirefoxAnchorBug();
     this.highlightSearchWords();
     this.initModIndex();

Modified: doctools/trunk/sphinx/writer.py
==============================================================================
--- doctools/trunk/sphinx/writer.py	(original)
+++ doctools/trunk/sphinx/writer.py	Mon Aug  6 18:51:47 2007
@@ -54,6 +54,9 @@
         if node.parent['desctype'] in ('class', 'exception'):
             self.body.append('%s ' % node.parent['desctype'])
     def depart_desc_signature(self, node):
+        if node['ids']:
+            self.body.append(u'<a class="headerlink" href="#%s" ' % node['ids'][0] +
+                             u'title="Permalink to this definition">\u00B6</a>')
         self.body.append('</dt>\n')
 
     def visit_desc_classname(self, node):
@@ -202,6 +205,16 @@
     def depart_literal_emphasis(self, node):
         return self.depart_emphasis(node)
 
+    def depart_title(self, node):
+        close_tag = self.context[-1]
+        if close_tag.startswith(('</h', '</a></h')) and \
+               node.parent.hasattr('ids') and node.parent['ids']:
+            aname = node.parent['ids'][0]
+            # add permalink anchor
+            self.body.append(u'<a class="headerlink" href="#%s" ' % aname +
+                             u'title="Permalink to this headline">\u00B6</a>')
+        BaseTranslator.depart_title(self, node)
+
 
 class SmartyPantsHTMLTranslator(HTMLTranslator):
     """


More information about the Python-checkins mailing list