Merge lp:~jtv/maas/skip-lint-in-generated-docs into lp:~maas-committers/maas/trunk

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: no longer in the source branch.
Merged at revision: 2995
Proposed branch: lp:~jtv/maas/skip-lint-in-generated-docs
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 61 lines (+12/-5)
3 files modified
src/maasserver/api/doc_handler.py (+7/-2)
src/maasserver/forms_settings.py (+4/-2)
utilities/doc-lint (+1/-1)
To merge this branch: bzr merge lp:~jtv/maas/skip-lint-in-generated-docs
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+234771@code.launchpad.net

Commit message

Remove trailing spaces from generated api.rst; make the documentation linter skip some generated files where trailing spaces are hard to avoid.

Description of the change

This should fix lint errors on a branch where the documentation has been built.

I tried making the trailing-whitespace check print line numbers, but “grep -ln” doesn't do anything more than “grep -l”.

Jeroen

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/api/doc_handler.py'
2--- src/maasserver/api/doc_handler.py 2014-08-18 12:25:10 +0000
3+++ src/maasserver/api/doc_handler.py 2014-09-16 08:06:16 +0000
4@@ -123,7 +123,7 @@
5 section_name = doc.handler.api_doc_section_name
6 line(section_name)
7 line('=' * len(section_name))
8- line(doc.handler.__doc__)
9+ line(doc.handler.__doc__.strip())
10 line()
11 line()
12 for (http_method, op), function in sorted(exports):
13@@ -134,7 +134,12 @@
14 docstring = getdoc(function)
15 if docstring is not None:
16 for docline in docstring.splitlines():
17- line(" ", docline, sep="")
18+ if docline.strip() == '':
19+ # Blank line. Don't indent.
20+ line()
21+ else:
22+ # Print documentation line, indented.
23+ line(" ", docline, sep="")
24 line()
25
26 line()
27
28=== modified file 'src/maasserver/forms_settings.py'
29--- src/maasserver/forms_settings.py 2014-07-18 17:05:57 +0000
30+++ src/maasserver/forms_settings.py 2014-09-16 08:06:16 +0000
31@@ -18,8 +18,9 @@
32 'get_config_field',
33 'get_config_form',
34 'validate_config_name',
35-]
36+ ]
37
38+import re
39 from socket import gethostname
40
41 from django import forms
42@@ -304,4 +305,5 @@
43 choice_descr = describe_choices(choices)
44 doc.append("Available choices are: %s." % choice_descr)
45 doc.append("\n")
46- return (' ' * indentation).join(doc)
47+ full_text = (' ' * indentation).join(doc)
48+ return re.sub('\s+$', '', full_text, flags=re.MULTILINE)
49
50=== modified file 'utilities/doc-lint'
51--- utilities/doc-lint 2014-02-25 06:48:39 +0000
52+++ utilities/doc-lint 2014-09-16 08:06:16 +0000
53@@ -2,7 +2,7 @@
54 #
55 # Rudimentary lint check for the documentation.
56 DOCS_WITH_TRAILING_SPACES="$(
57- find docs -name '*.rst' -print0 |
58+ find docs -name '*.rst' -not -path 'docs/_autosummary/*' -print0 |
59 xargs -r0 grep -l '[[:space:]]$')"
60 if [ -n "$DOCS_WITH_TRAILING_SPACES" ]
61 then