Georg Brandl avatar Georg Brandl committed 0281c9d

Closes #669: Respect the ``noindex`` flag option in py:module directives.

Comments (0)

Files changed (2)

 Release 1.0.8 (in development)
 ==============================
 
+* #669: Respect the ``noindex`` flag option in py:module directives.
+
 * #675: Fix IndexErrors when including nonexisting lines with
   :rst:dir:`literalinclude`.
 

sphinx/domains/python.py

         modname = self.arguments[0].strip()
         noindex = 'noindex' in self.options
         env.temp_data['py:module'] = modname
-        env.domaindata['py']['modules'][modname] = \
-            (env.docname, self.options.get('synopsis', ''),
-             self.options.get('platform', ''), 'deprecated' in self.options)
-        # make a duplicate entry in 'objects' to facilitate searching for the
-        # module in PythonDomain.find_obj()
-        env.domaindata['py']['objects'][modname] = (env.docname, 'module')
-        targetnode = nodes.target('', '', ids=['module-' + modname], ismod=True)
-        self.state.document.note_explicit_target(targetnode)
-        ret = [targetnode]
+        ret = []
+        if not noindex:
+            env.domaindata['py']['modules'][modname] = \
+                (env.docname, self.options.get('synopsis', ''),
+                 self.options.get('platform', ''), 'deprecated' in self.options)
+            # make a duplicate entry in 'objects' to facilitate searching for
+            # the module in PythonDomain.find_obj()
+            env.domaindata['py']['objects'][modname] = (env.docname, 'module')
+            targetnode = nodes.target('', '', ids=['module-' + modname],
+                                      ismod=True)
+            self.state.document.note_explicit_target(targetnode)
+            ret.append(targetnode)
         # XXX this behavior of the module directive is a mess...
         if 'platform' in self.options:
             platform = self.options['platform']
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.