1. Chris McDonough
  2. sphinx


georg.brandl  committed d841161

Add the module name to module globals' descriptions.

  • Participants
  • Parent commits 06dcb31
  • Branches default

Comments (0)

Files changed (1)

File sphinx/directives.py

View file
 py_paramlist_re = re.compile(r'([\[\],])')  # split at '[', ']' and ','
-def parse_py_signature(signode, sig, desctype, currclass):
+def parse_py_signature(signode, sig, desctype, currmodule, currclass):
-    Transform a python signature into RST nodes. Returns (signode, fullname).
+    Transform a python signature into RST nodes.
     Return the fully qualified name of the thing.
     If inside a class, the current class name is handled intelligently:
     if classname:
         signode += addnodes.desc_classname(classname, classname)
+    # only add the module name for module globals
+    # exceptions are a special case, since they are documented in the
+    # 'exceptions' module.
+    elif currmodule and currmodule != 'exceptions':
+        signode += addnodes.desc_classname(currmodule+'.', currmodule+'.')
     signode += addnodes.desc_name(name, name)
     if not arglist:
         if desctype in ('function', 'method'):
             if desctype in ('function', 'data', 'class', 'exception',
                             'method', 'attribute'):
-                name = parse_py_signature(signode, sig, desctype, env.currclass)
+                name = parse_py_signature(signode, sig, desctype,
+                                          env.currmodule, env.currclass)
             elif desctype in ('cfunction', 'cmember', 'cmacro', 'ctype', 'cvar'):
                 name = parse_c_signature(signode, sig, desctype)
             elif desctype == 'opcode':