Skip to content

Commit e194663

Browse files
committed
Merge branch 'master' into develop
2 parents 1443853 + 8699f76 commit e194663

File tree

9 files changed

+49
-21
lines changed

9 files changed

+49
-21
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ install:
1111

1212
script:
1313
- py.test
14-
- flake8 . --ignore=E501 --exclude=docs/conf.py
14+
- flake8 . --ignore=E501,E722,E741 --exclude=docs/conf.py

docs/changelog.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
Change log
33
**********
44

5+
0.2.2
6+
#####
7+
8+
* CommonMark is now only imported if absolutely required. This should fix failures on read the docs. Thanks to @Chilipp for fixing this!
9+
510
0.2.1
611
#####
712

@@ -13,7 +18,7 @@ Change log
1318
* Section titles can now be used in tables of contents and linked to. The title itself is also used as the anchor. In the case of repeated names `_replicateX`, where `X` is a number, is prepended to ensure that all titles are uniquely linkable. This was bug `#46 <https://github.com/ribozz/sphinx-argparse/issues/46>`_.
1419
* The positional (aka required) and named (aka optional) option sections are now named "Positional Arguments" and "Named Arguments", for the sake of clarity (e.g., named arguments can be required). This was issue `#58 <https://github.com/ribozz/sphinx-argparse/issues/58>`_.
1520
* Fixed quoting of default strings (issue `#59 <https://github.com/ribozz/sphinx-argparse/issues/59>`_).
16-
* Added the `:noepilogue:` and `:nodescription:` options, thanks to @arewm.
21+
* Added the `:noepilog:` and `:nodescription:` options, thanks to @arewm.
1722
* Added the `:nosubcommand:` option, thanks to @arewm.
1823

1924
0.1.17

docs/extend.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ You can also add classifiers, which will change how these definitions are incorp
6262
--upgrade : @after
6363
The after directive is the default, so you needn't specify it.
6464

65+
advanced arguments : @skip
66+
skip advanced arguments
67+
6568

6669
@before
6770
Insert content before the parsed help/description message of the argument/option/subcommand/argument-group.
@@ -71,3 +74,6 @@ You can also add classifiers, which will change how these definitions are incorp
7174

7275
@replace
7376
Replace content of help/description message of argument/option/subcommand/argument-group.
77+
78+
@skip
79+
Skip the content of help/description message of subcommand/argument-group.

docs/usage.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,6 @@ Other useful directives
9595

9696
:nosubcommands: Do not show subcommands.
9797

98-
:noepilogue: Do not parse the epilogue, which can be useful if it contains text that could be incorrectly parse as reStructuredText.
98+
:noepilog: Do not parse the epilogue, which can be useful if it contains text that could be incorrectly parse as reStructuredText.
9999

100100
:nodescription: Do not parse the description, which can be useful if it contains text that could be incorrectly parse as reStructuredText.

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ def getVersion():
3737
'Topic :: Software Development :: Documentation'
3838
],
3939
install_requires=[
40-
'sphinx>=1.2.0',
41-
'CommonMark>=0.5.6'
40+
'sphinx>=1.2.0'
4241
],
4342
extras_require={
44-
'dev': ['pytest', 'sphinx_rtd_theme']
43+
'dev': ['pytest', 'sphinx_rtd_theme'],
44+
'markdown': ['CommonMark>=0.5.6']
4545
}
4646
)

sphinxarg/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.2.1'
1+
__version__ = '0.2.2'

sphinxarg/ext.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from sphinx.util.nodes import nested_parse_with_titles
1111

1212
from sphinxarg.parser import parse_parser, parser_navigate
13-
from sphinxarg.markdown import parseMarkDownBlock
1413

1514

1615
def map_nested_definitions(nested_content):
@@ -33,7 +32,7 @@ def map_nested_definitions(nested_content):
3332
if len(ci.children) > 0:
3433
classifier = ci.children[0].astext()
3534
if classifier is not None and classifier not in (
36-
'@replace', '@before', '@after'):
35+
'@replace', '@before', '@after', '@skip'):
3736
raise Exception('Unknown classifier: %s' % classifier)
3837
idx = subitem.first_child_matching_class(nodes.term)
3938
if idx is not None:
@@ -58,6 +57,7 @@ def renderList(l, markDownHelp, settings=None):
5857
if len(l) == 0:
5958
return []
6059
if markDownHelp:
60+
from sphinxarg.markdown import parseMarkDownBlock
6161
return parseMarkDownBlock('\n\n'.join(l) + '\n')
6262
else:
6363
if settings is None:
@@ -93,16 +93,19 @@ def print_action_groups(data, nested_content, markDownHelp=False, settings=None)
9393
desc.append(s)
9494
elif classifier == '@before':
9595
desc.insert(0, s)
96-
for k, v in subContent.items():
97-
definitions[k] = v
96+
elif classifier == '@skip':
97+
continue
98+
if len(subContent) > 0:
99+
for k, v in map_nested_definitions(subContent).items():
100+
definitions[k] = v
98101
# Render appropriately
99102
for element in renderList(desc, markDownHelp):
100103
section += element
101104

102105
localDefinitions = definitions
103106
if len(subContent) > 0:
104107
localDefinitions = {k: v for k, v in definitions.items()}
105-
for k, v in map_nested_definitions(subContent):
108+
for k, v in map_nested_definitions(subContent).items():
106109
localDefinitions[k] = v
107110

108111
items = []
@@ -151,7 +154,7 @@ def print_action_groups(data, nested_content, markDownHelp=False, settings=None)
151154
return nodes_list
152155

153156

154-
def print_subcommands(data, nested_content, markDownHelp=False):
157+
def print_subcommands(data, nested_content, markDownHelp=False, settings=None):
155158
"""
156159
Each subcommand is a dictionary with the following keys:
157160
@@ -192,12 +195,18 @@ def print_subcommands(data, nested_content, markDownHelp=False):
192195
for element in renderList(desc, markDownHelp):
193196
sec += element
194197
sec += nodes.literal_block(text=child['bare_usage'])
195-
for x in print_action_groups(child, nested_content + subContent, markDownHelp):
198+
for x in print_action_groups(child, nested_content + subContent, markDownHelp,
199+
settings=settings):
196200
sec += x
197201

198-
for x in print_subcommands(child, nested_content + subContent, markDownHelp):
202+
for x in print_subcommands(child, nested_content + subContent, markDownHelp,
203+
settings=settings):
199204
sec += x
200205

206+
if 'epilog' in child and child['epilog']:
207+
for element in renderList([child['epilog']], markDownHelp):
208+
sec += element
209+
201210
subCommands += sec
202211
items.append(subCommands)
203212

@@ -457,6 +466,7 @@ def run(self):
457466
items = []
458467
nested_content = nodes.paragraph()
459468
if 'markdown' in self.options:
469+
from sphinxarg.markdown import parseMarkDownBlock
460470
items.extend(parseMarkDownBlock('\n'.join(self.content) + '\n'))
461471
else:
462472
self.state.nested_parse(
@@ -479,7 +489,8 @@ def run(self):
479489
items.extend(print_action_groups(result, nested_content, markDownHelp,
480490
settings=self.state.document.settings))
481491
if 'nosubcommands' not in self.options:
482-
items.extend(print_subcommands(result, nested_content, markDownHelp))
492+
items.extend(print_subcommands(result, nested_content, markDownHelp,
493+
settings=self.state.document.settings))
483494
if 'epilog' in result and 'noepilog' not in self.options:
484495
items.append(self._nested_parse_paragraph(result['epilog']))
485496

sphinxarg/markdown.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
from CommonMark import Parser # >= 0.5.6
2-
from CommonMark.node import Node
1+
try:
2+
from commonmark import Parser
3+
except ImportError:
4+
from CommonMark import Parser # >= 0.5.6
5+
try:
6+
from commonmark.node import Node
7+
except ImportError:
8+
from CommonMark.node import Node
39
from docutils import nodes
410
from docutils.utils.code_analyzer import Lexer
511

tox.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[tox]
2-
envlist = py26,py27,py33,py34
2+
envlist = py26,py27,py33,py34,py35,py36
33
[testenv]
4-
deps=pytest # install pytest in the venvs
5-
commands=py.test # or 'nosetests' or .
4+
deps=pytest
5+
commands=py.test

0 commit comments

Comments
 (0)