diff options
author | Pauli Virtanen <pav@iki.fi> | 2011-06-29 21:27:23 +0200 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2011-06-29 21:27:23 +0200 |
commit | 38a8f81d1c415c0a51eefa3173d4217689b89a94 (patch) | |
tree | 86f9bcf40ccfd81bf5e93e993801f5383aada495 | |
parent | 0dd12d1409e980c097f1fae394e53640a4dd8843 (diff) | |
download | sphinx-38a8f81d1c415c0a51eefa3173d4217689b89a94.tar.gz |
autosummary: respect py:currentclass when looking up Python objects
This makes autosummary directives inside classes to work properly.
-rw-r--r-- | sphinx/ext/autosummary/__init__.py | 10 | ||||
-rw-r--r-- | tests/root/autosummary.txt | 24 |
2 files changed, 33 insertions, 1 deletions
diff --git a/sphinx/ext/autosummary/__init__.py b/sphinx/ext/autosummary/__init__.py index 515777b8..b29470fb 100644 --- a/sphinx/ext/autosummary/__init__.py +++ b/sphinx/ext/autosummary/__init__.py @@ -171,7 +171,7 @@ class Autosummary(Directive): """ 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 @@ -232,10 +232,18 @@ class Autosummary(Directive): 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 diff --git a/tests/root/autosummary.txt b/tests/root/autosummary.txt index edf75e32..82cec7fd 100644 --- a/tests/root/autosummary.txt +++ b/tests/root/autosummary.txt @@ -5,3 +5,27 @@ Autosummary test :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 |