Merge lp:~dreid/twistedchecker/blank-lines-before-more-fields into lp:~twisted-dev/twistedchecker/trunk

Proposed by David Reid
Status: Merged
Approved by: Jean-Paul Calderone
Approved revision: 35
Merged at revision: 34
Proposed branch: lp:~dreid/twistedchecker/blank-lines-before-more-fields
Merge into: lp:~twisted-dev/twistedchecker/trunk
Diff against target: 58 lines (+39/-1)
2 files modified
twistedchecker/checkers/docstring.py (+2/-1)
twistedchecker/functionaltests/docstring_pass.py (+37/-0)
To merge this branch: bzr merge lp:~dreid/twistedchecker/blank-lines-before-more-fields
Reviewer Review Type Date Requested Status
Jean-Paul Calderone Approve
Review via email: mp+216202@code.launchpad.net

Description of the change

Not all epytext fields were properly recognized as the beginning of epytext blocks, this adds @cvar, @ivar, and @raises.

There may be others worth adding but these were the ones that were obviously in use and missing.

To post a comment you must log in.
35. By David Reid

Also add @raise.

Revision history for this message
Jean-Paul Calderone (exarkun) wrote :

http://epydoc.sourceforge.net/fields.html#fields might be an interesting thing to consider here.

Perhaps it would be better not to try to match the particular keyword and instead just match something like `@[a-z]+`?

The code in the branch is, however, strictly an improvement over trunk. If you'd rather just land this as-is, that's fine with me too.

In other words, please consider making the code match all documented epytext keywords. If you'd rather not now, please file another bug report. Then merge.

Thank you very much for improving this!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'twistedchecker/checkers/docstring.py'
2--- twistedchecker/checkers/docstring.py 2012-08-20 04:13:42 +0000
3+++ twistedchecker/checkers/docstring.py 2014-04-16 20:13:17 +0000
4@@ -207,7 +207,8 @@
5 @param linenoDocstring: linenumber of docstring
6 """
7 # Check whether there is a blank line before epytext markups.
8- patternEpytext = (r"\n *@(param|type|return|returns|rtype)"
9+ patternEpytext = (r"\n *@(param|type|return|returns|rtype|ivar|cvar"
10+ r"|raises|raise)"
11 r"\s*[a-zA-Z0-9_]*\s*\:")
12 matchedEpytext = re.search(patternEpytext, node.doc)
13 if matchedEpytext:
14
15=== modified file 'twistedchecker/functionaltests/docstring_pass.py'
16--- twistedchecker/functionaltests/docstring_pass.py 2012-08-20 04:13:42 +0000
17+++ twistedchecker/functionaltests/docstring_pass.py 2014-04-16 20:13:17 +0000
18@@ -62,3 +62,40 @@
19 A method returns nothing.
20 """
21 return
22+
23+
24+
25+class Bar(self):
26+ """
27+ A cvar is recognized as being the start of epytext markup.
28+
29+ @cvar foo: bar baz
30+ @type foo: bax
31+ """
32+
33+ def a(self):
34+ """
35+ A raises field is recognized as being the start of epytext markup.
36+
37+ @raises FoobarException: An exception.
38+ @returns: C{int}
39+ """
40+
41+ def b(self):
42+ """
43+ A raise (because we are inconsistent about stuff) should also be
44+ recognized as the start of epytext markup.
45+
46+ @raise BarException: Another exception.
47+ @returns: C{int}
48+ """
49+
50+
51+
52+class Baz(self):
53+ """
54+ An ivar is recognized as being the start of epytext markup.
55+
56+ @ivar foo: bar baz
57+ @type foo: bax
58+ """

Subscribers

People subscribed via source and target branches

to all changes: