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

generate Python API document automatically #998

Merged
merged 3 commits into from
Aug 20, 2021
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ venv*
_build
_templates
API_CC
doc/api_py/
dp/
build_lammps/
build_tests/
build_cc_tests
build_cc_tests
17 changes: 14 additions & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,19 @@ def generate_doxygen_xml(app):
else:
subprocess.call("doxygen Doxyfile", shell=True)

def run_apidoc(_):
from sphinx.ext.apidoc import main
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
cur_dir = os.path.abspath(os.path.dirname(__file__))
module = os.path.join(cur_dir,"..","deepmd")
main(['-M', '--tocfile', 'api_py', '-H', 'Python API', '-o', os.path.join(cur_dir, "api_py"), module, '--force'])

def setup(app):

# Add hook for building doxygen xml when needed
app.connect("builder-inited", generate_doxygen_xml)
app.connect('builder-inited', run_apidoc)

# -- General configuration ---------------------------------------------------

Expand All @@ -158,6 +167,7 @@ def setup(app):
'sphinx.ext.autosummary',
'sphinx.ext.viewcode',
'sphinx.ext.intersphinx',
'numpydoc',
'breathe',
'exhale'
]
Expand All @@ -184,10 +194,10 @@ def setup(app):
}

# Tell sphinx what the primary language being documented is.
primary_domain = 'cpp'
#primary_domain = 'cpp'

# Tell sphinx what the pygments highlight language should be.
highlight_language = 'cpp'
#highlight_language = 'cpp'

#
myst_heading_anchors = 4
Expand All @@ -206,7 +216,8 @@ def setup(app):
"tensorflow": (
"https://www.tensorflow.org/api_docs/python",
"https://github.com/mr-ubik/tensorflow-intersphinx/raw/master/tf2_py_objects.inv",
),
),
"ase": ("https://wiki.fysik.dtu.dk/ase/", None),
}

# -- Options for HTML output -------------------------------------------------
Expand Down
123 changes: 0 additions & 123 deletions doc/development/api.rst

This file was deleted.

3 changes: 2 additions & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ DeePMD-kit is a package written in Python/C++, designed to minimize the effort r
.. _developer-guide:

.. toctree::
:maxdepth: 3
:maxdepth: 5
:caption: Developer Guide
:glob:

development/*
api_py/api_py
API_CC/api_cc


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
cmake_minimum_required_version="3.0",
extras_require={
"test": ["dpdata>=0.1.9", "ase", "pytest", "pytest-cov", "pytest-sugar"],
"docs": ["sphinx<4.1.0", "recommonmark", "sphinx_rtd_theme", "sphinx_markdown_tables", "myst-parser", "breathe", "exhale"],
"docs": ["sphinx>=3.1.1,<4.1.0", "recommonmark", "sphinx_rtd_theme", "sphinx_markdown_tables", "myst-parser", "breathe", "exhale", "numpydoc", "ase"],
**extras_require,
},
entry_points={"console_scripts": ["dp = deepmd.entrypoints.main:main"]},
Expand Down