Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple lines in sections (including "returns") #42

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 25 additions & 6 deletions doxypypy/doxypypy.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def __start(*args, **kwargs):
return __cr
return __start


class AstWalker(NodeVisitor):
"""
A walker that'll recursively progress through an AST.
Expand Down Expand Up @@ -223,16 +222,19 @@ def __alterDocstring(self, tail='', writer=None):
len(line.expandtabs(self.options.tablength).lstrip())
if indent <= sectionHeadingIndent:
inSection = False
else:
if lines[-1] == '#':
# If the last line was empty, but we're still in a section
# then we need to start a new paragraph.
lines[-1] = '# @par'
lines[-1] += "{0}# \endparbock".format(linesep)
# else:
# if lines[-1] == '#':
# # If the last line was empty, but we're still in a section
# # then we need to start a new paragraph.
# lines[-1] = '# @par'

match = AstWalker.__returnsStartRE.match(line)
if match:
# We've got a "returns" section
line = line.replace(match.group(0), ' @return\t').rstrip()
line += " \parblock".format(linesep)
inSection = True
prefix = '@return\t'
else:
match = AstWalker.__argsStartRE.match(line)
Expand Down Expand Up @@ -308,6 +310,8 @@ def __alterDocstring(self, tail='', writer=None):
lines[-1], inCodeBlock = self._endCodeIfNeeded(
lines[-1], inCodeBlock)
lines.append('#' + line)
lines[-1] += "{0}# @parblock".format(linesep)
inParBlock = True
continue
elif prefix:
match = AstWalker.__singleListItemRE.match(line)
Expand All @@ -329,6 +333,21 @@ def __alterDocstring(self, tail='', writer=None):
lineNum - firstLineNum
)
)
else:
if self.options.autocode and inCodeBlock:
proseChecker.send(
(
line, lines,
lineNum - firstLineNum
)
)
elif self.options.autocode:
codeChecker.send(
(
line, lines,
lineNum - firstLineNum
)
)

# If we were passed a tail, append it to the docstring.
# Note that this means that we need a docstring for this
Expand Down