You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/usage.rst
+29-17Lines changed: 29 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -248,12 +248,12 @@ either from the defaults or from the docstring.
248
248
``@command`` Arguments
249
249
----------------------
250
250
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
257
257
the display of the docstring.
258
258
259
259
Aliasing Commands
@@ -275,31 +275,34 @@ And call it as follows:
275
275
276
276
Note that the original name will be discarded and won't be usable.
277
277
278
+
279
+
.. _docstring-style:
280
+
278
281
Other Docstring Formats
279
282
~~~~~~~~~~~~~~~~~~~~~~~
280
283
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.
287
290
288
291
An example of using a Numpy formatted docstring in mando::
289
292
290
293
@command(doctype='numpy')
291
294
def simple_numpy_docstring(arg1, arg2="string"):
292
295
'''One line summary.
293
-
296
+
294
297
Extended description.
295
-
298
+
296
299
Parameters
297
300
----------
298
301
arg1 : int
299
302
Description of `arg1`
300
303
arg2 : str
301
304
Description of `arg2`
302
-
305
+
303
306
Returns
304
307
-------
305
308
str
@@ -327,12 +330,14 @@ An example of using a Google formatted docstring in mando::
327
330
Formatter Class
328
331
~~~~~~~~~~~~~~~
329
332
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.
331
336
332
337
The ANSI formatter class has to be imported from mando and used as follows::
333
338
334
339
from mando.rst_text_formatter import RSTHelpFormatter
335
-
340
+
336
341
@command(formatter_class=RSTHelpFormatter)
337
342
def pow(a, b, mod=None):
338
343
'''Mimic Python's pow() function.
@@ -346,3 +351,10 @@ The ANSI formatter class has to be imported from mando and used as follows::
346
351
else:
347
352
print(a ** b)
348
353
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
0 commit comments