diff --git a/docs/cli.rst b/docs/cli.rst new file mode 100644 index 000000000..ebcf19e62 --- /dev/null +++ b/docs/cli.rst @@ -0,0 +1,7 @@ +Command line interface +====================== + +.. argparse:: + :module: dpdata.cli + :func: dpdata_parser + :prog: dpdata diff --git a/docs/conf.py b/docs/conf.py index d82fa6a48..7931ff700 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -48,6 +48,7 @@ 'sphinx.ext.intersphinx', 'numpydoc', 'm2r2', + 'sphinxarg.ext', ] # Add any paths that contain templates here, relative to this directory. diff --git a/docs/index.rst b/docs/index.rst index 85e837169..64d9183af 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -10,6 +10,7 @@ Welcome to dpdata's documentation! :maxdepth: 2 :caption: Contents: + cli formats api/api diff --git a/dpdata/cli.py b/dpdata/cli.py index eaa7c76eb..ef6eeab77 100644 --- a/dpdata/cli.py +++ b/dpdata/cli.py @@ -5,14 +5,13 @@ from .system import System, LabeledSystem, MultiSystems -def dpdata_cli(): - """dpdata cli. +def dpdata_parser() -> argparse.ArgumentParser: + """Returns dpdata cli parser. - Examples - -------- - .. code-block:: bash - - $ dpdata -iposcar POSCAR -odeepmd/npy -O data -n + Returns + ------- + argparse.ArgumentParser + dpdata cli parser """ parser = argparse.ArgumentParser( description="dpdata: Manipulating multiple atomic simulation data formats", @@ -28,7 +27,19 @@ def dpdata_cli(): parser.add_argument("--type-map", "-t", type=str, nargs="+", help="type map") parser.add_argument('--version', action='version', version='dpdata v%s' % __version__) + return parser + +def dpdata_cli(): + """dpdata cli. + + Examples + -------- + .. code-block:: bash + + $ dpdata -iposcar POSCAR -odeepmd/npy -O data -n + """ + parser = dpdata_parser() parsed_args = parser.parse_args() convert(**vars(parsed_args)) diff --git a/setup.py b/setup.py index a0ee7c336..d04124ab5 100644 --- a/setup.py +++ b/setup.py @@ -54,7 +54,7 @@ 'ase': ['ase'], 'amber': ['parmed'], 'pymatgen': ['pymatgen'], - 'docs': ['sphinx', 'recommonmark', 'sphinx_rtd_theme>=1.0.0rc1', 'numpydoc', 'm2r2', 'deepmodeling-sphinx'], + 'docs': ['sphinx', 'recommonmark', 'sphinx_rtd_theme>=1.0.0rc1', 'numpydoc', 'm2r2', 'deepmodeling-sphinx', 'sphinx-argparse'], }, entry_points={"console_scripts": ["dpdata = dpdata.cli:dpdata_cli"]}, )