Django

Code

Changeset 40

Show
Ignore:
Timestamp:
07/14/05 16:13:28 (3 years ago)
Author:
jacob
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • djangoproject.com/django_website/apps/docs/parts/build_documentation.py

    r35 r40  
    1 #!/usr/bin/env python 
    2  
    31""" 
    42Script to build the documentation for Django from ReST -> HTML. 
     
    8785        """Remove the damn border=1 from the standard HTML writer""" 
    8886        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     
    90132if __name__ == "__main__": 
    91133    if len(sys.argv) > 1: