Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Got rid of the <a name=...>s around all the headers in the created html;

git-svn-id: http://code.djangoproject.com/svn/djangoproject.com@40 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 1028f35aed2ddaf5efd8b931862894717bfdf6d9 1 parent ddfaba0
authored
48  django_website/apps/docs/parts/build_documentation.py
... ...
@@ -1,5 +1,3 @@
1  
-#!/usr/bin/env python
2  
-
3 1
 """
4 2
 Script to build the documentation for Django from ReST -> HTML.
5 3
 
@@ -86,7 +84,51 @@ class DjangoHTMLTranslator(html4css1.HTMLTranslator):
86 84
     def visit_table(self, node):
87 85
         """Remove the damn border=1 from the standard HTML writer"""
88 86
         self.body.append(self.starttag(node, 'table', CLASS='docutils'))
89  
-        
  87
+    
  88
+    def visit_title(self, node):
  89
+        """Coppied from html4css1.Writer wholesale just to get rid of the <a name=> crap.  Fun, eh?"""
  90
+        check_id = 0
  91
+        close_tag = '</p>\n'
  92
+        if isinstance(node.parent, nodes.topic):
  93
+            self.body.append(
  94
+                  self.starttag(node, 'p', '', CLASS='topic-title first'))
  95
+            check_id = 1
  96
+        elif isinstance(node.parent, nodes.sidebar):
  97
+            self.body.append(
  98
+                  self.starttag(node, 'p', '', CLASS='sidebar-title'))
  99
+            check_id = 1
  100
+        elif isinstance(node.parent, nodes.Admonition):
  101
+            self.body.append(
  102
+                  self.starttag(node, 'p', '', CLASS='admonition-title'))
  103
+            check_id = 1
  104
+        elif isinstance(node.parent, nodes.table):
  105
+            self.body.append(
  106
+                  self.starttag(node, 'caption', ''))
  107
+            check_id = 1
  108
+            close_tag = '</caption>\n'
  109
+        elif isinstance(node.parent, nodes.document):
  110
+            self.body.append(self.starttag(node, 'h1', '', CLASS='title'))
  111
+            self.context.append('</h1>\n')
  112
+            self.in_document_title = len(self.body)
  113
+        else:
  114
+            assert isinstance(node.parent, nodes.section)
  115
+            h_level = self.section_level + self.initial_header_level - 1
  116
+            atts = {}
  117
+            if (len(node.parent) >= 2 and
  118
+                isinstance(node.parent[1], nodes.subtitle)):
  119
+                atts['CLASS'] = 'with-subtitle'
  120
+            node.ids = node.parent['ids']
  121
+            self.body.append(self.starttag(node, 'h%s' % h_level, '', **atts))
  122
+            self.context.append('</h%s>\n' % (h_level))
  123
+        if check_id:
  124
+            if node.parent['ids']:
  125
+                self.body.append(
  126
+                    self.starttag({}, 'a', '', name=node.parent['ids'][0]))
  127
+                self.context.append('</a>' + close_tag)
  128
+            else:
  129
+                self.context.append(close_tag)
  130
+
  131
+    
90 132
 if __name__ == "__main__":
91 133
     if len(sys.argv) > 1:
92 134
         build(sys.argv[1:])

0 notes on commit 1028f35

Please sign in to comment.
Something went wrong with that request. Please try again.