Commits

Anonymous committed 1ecabae

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

  • Participants
  • Parent commits 08b439c

Comments (0)

Files changed (5)

File sphinx/addnodes.py

 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
+
+# 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_classname(nodes.Part, nodes.Inline, nodes.TextElement): pass
-class desc_type(nodes.Part, nodes.Inline, nodes.TextElement): pass
-class desc_name(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
     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
 
 # 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())

File sphinx/directives/desc.py

         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:
     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:
         paramlist += param
     signode += paramlist
     if const:
-        signode += addnodes.desc_classname(const, const)
+        signode += addnodes.desc_addname(const, const)
     return name
 
 
     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

File sphinx/htmlwriter.py

                              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

File sphinx/latexwriter.py

             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())

File sphinx/textwriter.py

     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):
                 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)