Skip to content

Commit 400e198

Browse files
authored
add dpdata cli docs (#317)
1 parent 0b0d9a9 commit 400e198

File tree

5 files changed

+28
-8
lines changed

5 files changed

+28
-8
lines changed

docs/cli.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Command line interface
2+
======================
3+
4+
.. argparse::
5+
:module: dpdata.cli
6+
:func: dpdata_parser
7+
:prog: dpdata

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
'sphinx.ext.intersphinx',
4949
'numpydoc',
5050
'm2r2',
51+
'sphinxarg.ext',
5152
]
5253

5354
# Add any paths that contain templates here, relative to this directory.

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Welcome to dpdata's documentation!
1010
:maxdepth: 2
1111
:caption: Contents:
1212

13+
cli
1314
formats
1415
api/api
1516

dpdata/cli.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
from .system import System, LabeledSystem, MultiSystems
66

77

8-
def dpdata_cli():
9-
"""dpdata cli.
8+
def dpdata_parser() -> argparse.ArgumentParser:
9+
"""Returns dpdata cli parser.
1010
11-
Examples
12-
--------
13-
.. code-block:: bash
14-
15-
$ dpdata -iposcar POSCAR -odeepmd/npy -O data -n
11+
Returns
12+
-------
13+
argparse.ArgumentParser
14+
dpdata cli parser
1615
"""
1716
parser = argparse.ArgumentParser(
1817
description="dpdata: Manipulating multiple atomic simulation data formats",
@@ -28,7 +27,19 @@ def dpdata_cli():
2827
parser.add_argument("--type-map", "-t", type=str, nargs="+", help="type map")
2928

3029
parser.add_argument('--version', action='version', version='dpdata v%s' % __version__)
30+
return parser
3131

32+
33+
def dpdata_cli():
34+
"""dpdata cli.
35+
36+
Examples
37+
--------
38+
.. code-block:: bash
39+
40+
$ dpdata -iposcar POSCAR -odeepmd/npy -O data -n
41+
"""
42+
parser = dpdata_parser()
3243
parsed_args = parser.parse_args()
3344
convert(**vars(parsed_args))
3445

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
'ase': ['ase'],
5555
'amber': ['parmed'],
5656
'pymatgen': ['pymatgen'],
57-
'docs': ['sphinx', 'recommonmark', 'sphinx_rtd_theme>=1.0.0rc1', 'numpydoc', 'm2r2', 'deepmodeling-sphinx'],
57+
'docs': ['sphinx', 'recommonmark', 'sphinx_rtd_theme>=1.0.0rc1', 'numpydoc', 'm2r2', 'deepmodeling-sphinx', 'sphinx-argparse'],
5858
},
5959
entry_points={"console_scripts": ["dpdata = dpdata.cli:dpdata_cli"]},
6060
)

0 commit comments

Comments
 (0)