summaryrefslogtreecommitdiff
path: root/sphinx/pycode/parser.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2019-04-24 01:35:10 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2019-04-24 01:35:10 +0900
commit877ddd795e3b3994f6183e372c30dbf2f43f041f (patch)
tree97e723f2e2de33e8241b2755f30533aa9c289981 /sphinx/pycode/parser.py
parentb49ef12e6aed3481188da05955ee1782ebf70778 (diff)
downloadsphinx-git-877ddd795e3b3994f6183e372c30dbf2f43f041f.tar.gz
Add docstring to pycode.parser
Diffstat (limited to 'sphinx/pycode/parser.py')
-rw-r--r--sphinx/pycode/parser.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/sphinx/pycode/parser.py b/sphinx/pycode/parser.py
index 9f9f7dd29..f9489e91a 100644
--- a/sphinx/pycode/parser.py
+++ b/sphinx/pycode/parser.py
@@ -383,10 +383,15 @@ class VariableCommentPicker(ast.NodeVisitor):
def visit_AsyncFunctionDef(self, node):
# type: (ast.AsyncFunctionDef) -> None
+ """Handles AsyncFunctionDef node and set context."""
self.visit_FunctionDef(node) # type: ignore
class DefinitionFinder(TokenProcessor):
+ """Python source code parser to detect location of functions,
+ classes and methods.
+ """
+
def __init__(self, lines):
# type: (List[str]) -> None
super().__init__(lines)
@@ -397,6 +402,7 @@ class DefinitionFinder(TokenProcessor):
def add_definition(self, name, entry):
# type: (str, Tuple[str, int, int]) -> None
+ """Add a location of definition."""
if self.indents and self.indents[-1][0] == 'def' and entry[0] == 'def':
# ignore definition of inner function
pass
@@ -405,6 +411,7 @@ class DefinitionFinder(TokenProcessor):
def parse(self):
# type: () -> None
+ """Parse the code to obtain location of definitions."""
while True:
token = self.fetch_token()
if token is None:
@@ -426,6 +433,7 @@ class DefinitionFinder(TokenProcessor):
def parse_definition(self, typ):
# type: (str) -> None
+ """Parse AST of definition."""
name = self.fetch_token()
self.context.append(name.value)
funcname = '.'.join(self.context)
@@ -447,6 +455,7 @@ class DefinitionFinder(TokenProcessor):
def finalize_block(self):
# type: () -> None
+ """Finalize definition block."""
definition = self.indents.pop()
if definition[0] != 'other':
typ, funcname, start_pos = definition