Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
Fixes #213, remove cmdref in function exposed as command line
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Dec 10, 2018
1 parent afe268f commit a08129a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
8 changes: 7 additions & 1 deletion HISTORY.rst
Expand Up @@ -5,9 +5,15 @@
History
=======

current - 2018-12-09 - 0.00Mb
current - 2018-12-10 - 0.00Mb
=============================

* `213`: removes cmdref from documentation when creating a parser for a function (2018-12-10)
* `212`: issue when the default value is None when building the parser for a specific function (2018-12-09)

1.8.2884 - 2018-12-09 - 2.03Mb
==============================

* `211`: automatically git tag when publishing (2018-12-05)
* `210`: add __main__ command line (2018-11-29)

Expand Down
12 changes: 9 additions & 3 deletions src/pyquickhelper/cli/cli_helper.py
Expand Up @@ -19,8 +19,12 @@ def clean_documentation_for_cli(doc, cleandoc):
@param cleandoc a string which tells how to clean,
or a function which takes a function and
returns a string
The function removes everything after ``.. cmdref::`` and ``.. cmdreflist``
as it creates an infinite loop of processus if this command
is part of the documentation of the command line itself.
"""
for st in ('.. versionchanged::', '.. versionadded'):
for st in ('.. versionchanged::', '.. versionadded::', '.. cmdref::', '.. cmdreflist::'):
if st in doc:
doc = doc.split(st)[0]
if isinstance(cleandoc, (list, tuple)):
Expand Down Expand Up @@ -64,7 +68,7 @@ def create_cli_parser(f, prog=None, layout="sphinx", skip_parameters=('fLOG',),
richer requires :epkg:`sphinx`
@param skip_parameters do not expose these parameters
@param cleandoc cleans the documentation before converting it into text,
see @fn clean_documentation_for_cli
@see fn clean_documentation_for_cli
@param options additional :epkg:`Sphinx` options
@return :epkg:`*py:argparse:ArgumentParser`
Expand Down Expand Up @@ -198,7 +202,7 @@ def call_cli_function(f, args=None, parser=None, fLOG=print, skip_parameters=('f
@param fLOG logging function
@param skip_parameters see @see fn create_cli_parser
@param cleandoc cleans the documentation before converting it into text,
see @fn clean_documentation_for_cli
@see fn clean_documentation_for_cli
@param options additional :epkg:`Sphinx` options
This function is used in command line @see fn pyq_sync.
Expand Down Expand Up @@ -333,6 +337,8 @@ def main(args, fLOG=print):
.. cmdref::
:title: Clean files
:cmd: -m pyquickhelper clean_files --help
The command line cleans files in a folder.
"""
if fLOG is None:
raise ValueError("fLOG must be defined.")
Expand Down
1 change: 0 additions & 1 deletion src/pyquickhelper/sphinxext/sphinx_cmdref_extension.py
Expand Up @@ -138,7 +138,6 @@ def run(self):
fullname = fullname.strip()
name_cmd = name_cmd.strip()

#
fullname = "{0}.{1}".format(fullname, name_fct)
try:
obj, name = import_object(fullname, kind="function")
Expand Down

0 comments on commit a08129a

Please sign in to comment.