Anonymous avatar Anonymous committed d841161

Add the module name to module globals' descriptions.

Comments (0)

Files changed (1)

sphinx/directives.py

 
 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'):
         try:
             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':
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.