Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add auto cli docs #759

Merged
merged 5 commits into from
Jun 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
'myst_parser',
'sphinx.ext.autosummary',
'sphinx.ext.viewcode',
'sphinxarg.ext',
]


Expand Down
2 changes: 2 additions & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ DPGEN's documentation
.. toctree::
:maxdepth: 2
:caption: Overview

overview/cli


.. _installation::
Expand Down
7 changes: 7 additions & 0 deletions doc/overview/cli.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Command line interface
======================

.. argparse::
:module: dpgen.main
:func: main_parser
:prog: dpgen
1 change: 1 addition & 0 deletions doc/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ sphinx>=4.0.2
recommonmark
sphinx_rtd_theme
sphinx_markdown_tables
sphinx-argparse
myst-parser
deepmodeling_sphinx
.
16 changes: 13 additions & 3 deletions dpgen/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@
__email__ = ""


def main():
info()
print("Description\n------------")
def main_parser() -> argparse.ArgumentParser:
"""Returns parser for `dpgen` command.

Returns
-------
argparse.ArgumentParser
parser for `dpgen` command
"""
parser = argparse.ArgumentParser(description="""
dpgen is a convenient script that uses DeepGenerator to prepare initial
data, drive DeepMDkit and analyze results. This script works based on
Expand Down Expand Up @@ -156,8 +161,13 @@ def main():
help="parameter file, json format")

parser_db.set_defaults(func=db_run)
return parser


def main():
info()
print("Description\n------------")
parser = main_parser()
try:
import argcomplete
argcomplete.autocomplete(parser)
Expand Down