mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
autosummary: respect py:currentclass when looking up Python objects
This makes autosummary directives inside classes to work properly.
This commit is contained in:
@@ -171,7 +171,7 @@ class Autosummary(Directive):
|
|||||||
"""
|
"""
|
||||||
Pretty table containing short signatures and summaries of functions etc.
|
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
|
required_arguments = 0
|
||||||
@@ -232,10 +232,18 @@ class Autosummary(Directive):
|
|||||||
env = self.state.document.settings.env
|
env = self.state.document.settings.env
|
||||||
|
|
||||||
prefixes = ['']
|
prefixes = ['']
|
||||||
|
|
||||||
currmodule = env.temp_data.get('py:module')
|
currmodule = env.temp_data.get('py:module')
|
||||||
if currmodule:
|
if currmodule:
|
||||||
prefixes.insert(0, 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 = []
|
items = []
|
||||||
|
|
||||||
max_item_chars = 50
|
max_item_chars = 50
|
||||||
|
|||||||
@@ -5,3 +5,27 @@ Autosummary test
|
|||||||
:toctree: generated
|
:toctree: generated
|
||||||
|
|
||||||
sphinx.application.TemplateBridge
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user