pv avatar pv committed b4b9c0f

autosummary: respect py:currentclass when looking up Python objects

This makes autosummary directives inside classes to work properly.

Comments (0)

Files changed (2)

sphinx/ext/autosummary/__init__.py

     """
     Pretty table containing short signatures and summaries of functions etc.
 
-    autosummary also generates a (hidden) toctree:: node.
+    autosummary can also optionally generate a hidden toctree:: node.
     """
 
     required_arguments = 0
         env = self.state.document.settings.env
 
         prefixes = ['']
+
         currmodule = env.temp_data.get('py:module')
         if currmodule:
             prefixes.insert(0, currmodule)
 
+        currclass = env.temp_data.get('py:class')
+        if currclass:
+            if currmodule:
+                prefixes.insert(0, currmodule + "." + currclass)
+            else:
+                prefixes.insert(0, currclass)
+
         items = []
 
         max_item_chars = 50

tests/root/autosummary.txt

    :toctree: generated
 
    sphinx.application.TemplateBridge
+
+.. currentmodule:: sphinx.application
+
+.. autoclass:: TemplateBridge
+
+   Basic test
+
+   .. autosummary::
+
+      render                    -- some ignored stuff goes here
+      render_string             More ignored stuff
+
+   Test with tildes
+
+   .. autosummary::
+
+      ~TemplateBridge.render
+      ~TemplateBridge.render_string
+
+   Methods:
+
+  .. automethod:: render
+
+  .. automethod:: render_string
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.