[Python-checkins] r64380 - in doctools/trunk/sphinx: addnodes.py directives/desc.py htmlwriter.py latexwriter.py textwriter.py

georg.brandl python-checkins at python.org
Wed Jun 18 20:16:26 CEST 2008


Author: georg.brandl
Date: Wed Jun 18 20:16:25 2008
New Revision: 64380

Log:
Rename node class desc_classname to desc_addname, which
fits its many usages much better.


Modified:
   doctools/trunk/sphinx/addnodes.py
   doctools/trunk/sphinx/directives/desc.py
   doctools/trunk/sphinx/htmlwriter.py
   doctools/trunk/sphinx/latexwriter.py
   doctools/trunk/sphinx/textwriter.py

Modified: doctools/trunk/sphinx/addnodes.py
==============================================================================
--- doctools/trunk/sphinx/addnodes.py	(original)
+++ doctools/trunk/sphinx/addnodes.py	Wed Jun 18 20:16:25 2008
@@ -15,12 +15,20 @@
 class index(nodes.Invisible, nodes.Inline, nodes.TextElement): pass
 
 # description units (classdesc, funcdesc etc.)
+
+# parent node for signature and content
 class desc(nodes.Admonition, nodes.Element): pass
-class desc_content(nodes.General, nodes.Element): pass
-class desc_signature(nodes.Part, nodes.Inline, nodes.TextElement): pass
-class desc_classname(nodes.Part, nodes.Inline, nodes.TextElement): pass
+
+# additional name parts (module name, class name)
+class desc_addname(nodes.Part, nodes.Inline, nodes.TextElement): pass
+# compatibility alias
+desc_classname = desc_addname
+# return type (C), object type (Python)
 class desc_type(nodes.Part, nodes.Inline, nodes.TextElement): pass
+# main name of object
 class desc_name(nodes.Part, nodes.Inline, nodes.TextElement): pass
+# argument list
+class desc_signature(nodes.Part, nodes.Inline, nodes.TextElement): pass
 class desc_parameterlist(nodes.Part, nodes.Inline, nodes.TextElement):
     child_text_separator = ', '
 class desc_parameter(nodes.Part, nodes.Inline, nodes.TextElement): pass
@@ -29,6 +37,9 @@
     def astext(self):
         return '[' + nodes.TextElement.astext(self) + ']'
 
+# node for content
+class desc_content(nodes.General, nodes.Element): pass
+
 # \versionadded, \versionchanged, \deprecated
 class versionmodified(nodes.Admonition, nodes.TextElement): pass
 
@@ -75,7 +86,7 @@
 # make them known to docutils. this is needed, because the HTML writer
 # will choke at some point if these are not added
 nodes._add_node_class_names("""index desc desc_content desc_signature desc_type
-      desc_classname desc_name desc_parameterlist desc_parameter desc_optional
+      desc_addname desc_name desc_parameterlist desc_parameter desc_optional
       centered versionmodified seealso productionlist production toctree
       pending_xref compact_paragraph highlightlang literal_emphasis
       glossary acks module start_of_file tabular_col_spec""".split())

Modified: doctools/trunk/sphinx/directives/desc.py
==============================================================================
--- doctools/trunk/sphinx/directives/desc.py	(original)
+++ doctools/trunk/sphinx/directives/desc.py	Wed Jun 18 20:16:25 2008
@@ -96,31 +96,31 @@
         raise ValueError
     classname, name, arglist = m.groups()
 
-    add_module = True
     if env.currclass:
+        add_module = False
         if classname and classname.startswith(env.currclass):
             fullname = classname + name
             # class name is given again in the signature
             classname = classname[len(env.currclass):].lstrip('.')
-            add_module = False
         elif classname:
             # class name is given in the signature, but different
+            # (shouldn't happen)
             fullname = env.currclass + '.' + classname + name
         else:
             # class name is not given in the signature
             fullname = env.currclass + '.' + name
-            add_module = False
     else:
+        add_module = True
         fullname = classname and classname + name or name
 
     if classname:
-        signode += addnodes.desc_classname(classname, classname)
+        signode += addnodes.desc_addname(classname, classname)
     # exceptions are a special case, since they are documented in the
     # 'exceptions' module.
     elif add_module and env.config.add_module_names and \
            module and module != 'exceptions':
         nodetext = module + '.'
-        signode += addnodes.desc_classname(nodetext, nodetext)
+        signode += addnodes.desc_addname(nodetext, nodetext)
 
     signode += addnodes.desc_name(name, name)
     if not arglist:
@@ -199,7 +199,7 @@
     try:
         classname, funcname = name.split('::', 1)
         classname += '::'
-        signode += addnodes.desc_classname(classname, classname)
+        signode += addnodes.desc_addname(classname, classname)
         signode += addnodes.desc_name(funcname, funcname)
         # name (the full name) is still both parts
     except ValueError:
@@ -232,7 +232,7 @@
         paramlist += param
     signode += paramlist
     if const:
-        signode += addnodes.desc_classname(const, const)
+        signode += addnodes.desc_addname(const, const)
     return name
 
 
@@ -261,9 +261,9 @@
     for m in option_desc_re.finditer(sig):
         prefix, optname, args = m.groups()
         if count:
-            signode += addnodes.desc_classname(', ', ', ')
+            signode += addnodes.desc_addname(', ', ', ')
         signode += addnodes.desc_name(prefix+optname, prefix+optname)
-        signode += addnodes.desc_classname(args, args)
+        signode += addnodes.desc_addname(args, args)
         if not count:
             firstname = optname
         count += 1

Modified: doctools/trunk/sphinx/htmlwriter.py
==============================================================================
--- doctools/trunk/sphinx/htmlwriter.py	(original)
+++ doctools/trunk/sphinx/htmlwriter.py	Wed Jun 18 20:16:25 2008
@@ -76,13 +76,12 @@
                              u'title="Permalink to this definition">\u00B6</a>')
         self.body.append('</dt>\n')
 
-    def visit_desc_classname(self, node):
+    def visit_desc_addname(self, node):
         self.body.append(self.starttag(node, 'tt', '', CLASS='descclassname'))
-    def depart_desc_classname(self, node):
+    def depart_desc_addname(self, node):
         self.body.append('</tt>')
 
     def visit_desc_type(self, node):
-        # return type of C functions -- nothing to do here
         pass
     def depart_desc_type(self, node):
         pass

Modified: doctools/trunk/sphinx/latexwriter.py
==============================================================================
--- doctools/trunk/sphinx/latexwriter.py	(original)
+++ doctools/trunk/sphinx/latexwriter.py	Wed Jun 18 20:16:25 2008
@@ -374,7 +374,7 @@
             self.descstack[-1].name = self.encode(node.astext().strip())
         raise nodes.SkipNode
 
-    def visit_desc_classname(self, node):
+    def visit_desc_addname(self, node):
         d = self.descstack[-1]
         if d.env == 'describe':
             d.name += self.encode(node.astext())

Modified: doctools/trunk/sphinx/textwriter.py
==============================================================================
--- doctools/trunk/sphinx/textwriter.py	(original)
+++ doctools/trunk/sphinx/textwriter.py	Wed Jun 18 20:16:25 2008
@@ -169,9 +169,9 @@
     def depart_desc_name(self, node):
         pass
 
-    def visit_desc_classname(self, node):
+    def visit_desc_addname(self, node):
         pass
-    def depart_desc_classname(self, node):
+    def depart_desc_addname(self, node):
         pass
 
     def visit_desc_type(self, node):
@@ -306,7 +306,7 @@
                 for i, cell in enumerate(line):
                     par = textwrap.wrap(cell, width=colwidths[i])
                     if par:
-                        maxwidth = max(map(len, par)) 
+                        maxwidth = max(map(len, par))
                     else:
                         maxwidth = 0
                     realwidths[i] = max(realwidths[i], maxwidth)


More information about the Python-checkins mailing list