summaryrefslogtreecommitdiff
path: root/sphinx/pycode
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-01-04 19:16:52 +0100
committerGeorg Brandl <georg@python.org>2009-01-04 19:16:52 +0100
commit939e3f37d96e29c260244476caf60ee33c2761ed (patch)
tree88c769a5ba6581fd8baad34e1d3a95f4b9532c79 /sphinx/pycode
parent615da933a90527588029a1164894c6a8f56ecfce (diff)
downloadsphinx-939e3f37d96e29c260244476caf60ee33c2761ed.tar.gz
Cache tags and attribute docs in the analyzer.
Diffstat (limited to 'sphinx/pycode')
-rw-r--r--sphinx/pycode/__init__.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/sphinx/pycode/__init__.py b/sphinx/pycode/__init__.py
index a61a051a..0141ede4 100644
--- a/sphinx/pycode/__init__.py
+++ b/sphinx/pycode/__init__.py
@@ -176,6 +176,10 @@ class ModuleAnalyzer(object):
self.tokens = None
# will be filled by parse()
self.parsetree = None
+ # will be filled by find_attr_docs()
+ self.attr_docs = None
+ # will be filled by find_tags()
+ self.tags = None
def tokenize(self):
"""Generate tokens from the source."""
@@ -193,13 +197,18 @@ class ModuleAnalyzer(object):
def find_attr_docs(self, scope=''):
"""Find class and module-level attributes and their documentation."""
+ if self.attr_docs is not None:
+ return self.attr_docs
self.parse()
attr_visitor = AttrDocVisitor(number2name, scope)
attr_visitor.visit(self.parsetree)
+ self.attr_docs = attr_visitor.collected
return attr_visitor.collected
def find_tags(self):
"""Find class, function and method definitions and their location."""
+ if self.tags is not None:
+ return self.tags
self.tokenize()
result = {}
namespace = []
@@ -246,6 +255,7 @@ class ModuleAnalyzer(object):
if defline:
defline = False
expect_indent = True
+ self.tags = result
return result