Skip to content

Commit c65077b

Browse files
committed
docs(*): mention argcomplete and general fixes
Fixes #33
1 parent 74f03ef commit c65077b

File tree

2 files changed

+40
-18
lines changed

2 files changed

+40
-18
lines changed

docs/index.rst

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,17 @@ This example should showcase most of mando's features::
5555
main()
5656

5757
mando extracts information from your command's docstring. So you can document
58-
your code and create the CLI application at once! The first paragraph is taken
58+
your code and create the CLI application at once! In the above example the
59+
Sphinx format is used, but mando does not force you to write ReST docstrings.
60+
Currently, it supports the following styles:
61+
62+
- Sphinx (the default one)
63+
- Google
64+
- Numpy
65+
66+
To see how to specify the docstring format, see :ref:`docstring-style`.
67+
68+
The first paragraph is taken
5969
to generate the command's *help*. The remaining part (after removing all
6070
``:param:``'s) is the *description*. For everything that does not fit in the
6171
docstring, mando provides the ``@arg`` decorator, to override arbitrary

docs/usage.rst

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,12 @@ either from the defaults or from the docstring.
248248
``@command`` Arguments
249249
----------------------
250250

251-
There are three special arguments to the ``@command()`` decorator to allow for
252-
special processing for the decorated function. The first argument, also
253-
available as keyword "name='alias_name'" will allow for an alias of the
254-
command. The second argument, also available as keyword "doctype='rest'"
255-
allows for Numpy or Google formatted docstrings to be used. The third is only
256-
available as keyword "formatter_class='argparse_formatter_class'" to format
251+
There are three special arguments to the ``@command()`` decorator to allow for
252+
special processing for the decorated function. The first argument, also
253+
available as keyword ``name='alias_name'`` will allow for an alias of the
254+
command. The second argument, also available as keyword ``doctype='rest'``
255+
allows for Numpy or Google formatted docstrings to be used. The third is only
256+
available as keyword ``formatter_class='argparse_formatter_class'`` to format
257257
the display of the docstring.
258258

259259
Aliasing Commands
@@ -275,31 +275,34 @@ And call it as follows:
275275
276276
Note that the original name will be discarded and won't be usable.
277277

278+
279+
.. _docstring-style:
280+
278281
Other Docstring Formats
279282
~~~~~~~~~~~~~~~~~~~~~~~
280283

281-
There are three commonly accepted formats for docstrings. The Sphinx docstring,
282-
and the mando dialect of Sphinx described in this documentation are treated
283-
equally and is the default documentation style named "rest" for REStructured
284-
Text. The other two available styles are "numpy" and "google". This allows
285-
projects that use mando, but already have docstrings in these other formats to
286-
not have to convert the docstrings.
284+
There are three commonly accepted formats for docstrings. The Sphinx docstring,
285+
and the mando dialect of Sphinx described in this documentation are treated
286+
equally and is the default documentation style named ``rest`` for REStructured
287+
Text. The other two available styles are ``numpy`` and ``google``. This allows
288+
projects that use mando, but already have docstrings in these other formats not
289+
to have to convert the docstrings.
287290

288291
An example of using a Numpy formatted docstring in mando::
289292

290293
@command(doctype='numpy')
291294
def simple_numpy_docstring(arg1, arg2="string"):
292295
'''One line summary.
293-
296+
294297
Extended description.
295-
298+
296299
Parameters
297300
----------
298301
arg1 : int
299302
Description of `arg1`
300303
arg2 : str
301304
Description of `arg2`
302-
305+
303306
Returns
304307
-------
305308
str
@@ -327,12 +330,14 @@ An example of using a Google formatted docstring in mando::
327330
Formatter Class
328331
~~~~~~~~~~~~~~~
329332

330-
For the help display there is the opportunity to use special formatters. Any argparse compatible formatter class can be used. There is an alternative formatter class available with mando that will display on ANSI terminals.
333+
For the help display there is the opportunity to use special formatters. Any
334+
argparse compatible formatter class can be used. There is an alternative
335+
formatter class available with mando that will display on ANSI terminals.
331336

332337
The ANSI formatter class has to be imported from mando and used as follows::
333338

334339
from mando.rst_text_formatter import RSTHelpFormatter
335-
340+
336341
@command(formatter_class=RSTHelpFormatter)
337342
def pow(a, b, mod=None):
338343
'''Mimic Python's pow() function.
@@ -346,3 +351,10 @@ The ANSI formatter class has to be imported from mando and used as follows::
346351
else:
347352
print(a ** b)
348353

354+
355+
Shell autocompletion
356+
--------------------
357+
358+
Mando supports autocompletion via the optional dependency ``argcomplete``. If
359+
that package is installed, mando detects it automatically without the need to
360+
do anything else.

0 commit comments

Comments
 (0)