diff --git a/docs/conf.py b/docs/conf.py index 51e185639..bed869fd7 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -14,13 +14,14 @@ # import os import sys +from datetime import date sys.path.insert(0, os.path.abspath('..')) # -- Project information ----------------------------------------------------- project = 'dpdata' -copyright = '2019, Han Wang' +copyright = '2019-%d, Deep Modeling ' % date.today().year author = 'Han Wang' # The short X.Y version @@ -39,11 +40,12 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinxcontrib.napoleon', + 'sphinx_rtd_theme', 'sphinx.ext.mathjax', 'sphinx.ext.viewcode', - 'sphinx.ext.githubpages', - 'm2r', + 'sphinx.ext.intersphinx', + 'numpydoc', + 'm2r2', ] # Add any paths that contain templates here, relative to this directory. @@ -79,7 +81,7 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'alabaster' +html_theme = 'sphinx_rtd_theme' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the @@ -90,7 +92,7 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +#html_static_path = ['_static'] # Custom sidebar templates, must be a dictionary that maps document names # to template names. @@ -161,3 +163,18 @@ # -- Extension configuration ------------------------------------------------- +def run_apidoc(_): + from sphinx.ext.apidoc import main + 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, "..", "dpdata") + main(['-M', '--tocfile', 'api', '-H', 'API documentation', '-o', os.path.join(cur_dir, "api"), module, '--force']) + +def setup(app): + app.connect('builder-inited', run_apidoc) + + +intersphinx_mapping = { + "numpy": ("https://docs.scipy.org/doc/numpy/", None), + "python": ("https://docs.python.org/", None), +} diff --git a/docs/index.rst b/docs/index.rst index 5ea8253f2..116e3f690 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -10,22 +10,11 @@ Welcome to dpdata's documentation! :maxdepth: 2 :caption: Contents: + api/api .. mdinclude:: ../README.md -API documentation -================= - -.. automodule:: dpdata - -.. autoclass:: System - :members: __init__, __getitem__, get_nframes, get_natoms, sub_system, append, apply_pbc, to_lammps_lmp, to_vasp_poscar - -.. autoclass:: LabeledSystem - :members: __init__, sub_system, to_deepmd_raw, to_deepmd_npy - - Indices and tables ================== diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 000000000..e9704b8eb --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1 @@ +.[docs] diff --git a/setup.py b/setup.py index 59133b924..c0ded7819 100644 --- a/setup.py +++ b/setup.py @@ -53,6 +53,7 @@ 'ase': ['ase'], 'amber': ['parmed'], 'pymatgen': ['pymatgen'], + 'docs': ['sphinx', 'recommonmark', 'sphinx_rtd_theme>=1.0.0rc1', 'numpydoc', 'm2r2'], } )