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

Doc api cc #663

Merged
merged 10 commits into from
Jun 3, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ venv*
.vscode/**
_build
_templates
API_CC
2,662 changes: 2,662 additions & 0 deletions doc/Doxyfile

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions doc/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
To run the HTML documention build, doxygen have to be installed.
4 changes: 2 additions & 2 deletions doc/development/api.rst → doc/api.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
API
===
Python API
==========

.. toctree::
:maxdepth: 2
Expand Down
58 changes: 57 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import subprocess
# import sys
import recommonmark
from recommonmark.transform import AutoStructify
Expand Down Expand Up @@ -52,6 +53,31 @@ def mkindex(dirname):
copyright = '2020, Deep Potential'
author = 'Deep Potential'

def run_doxygen(folder):
"""Run the doxygen make command in the designated folder"""

try:
retcode = subprocess.call("cd %s; doxygen Doxyfile" % folder, shell=True)
if retcode < 0:
sys.stderr.write("doxygen terminated by signal %s" % (-retcode))
except OSError as e:
sys.stderr.write("doxygen execution failed: %s" % e)


def generate_doxygen_xml(app):
"""Run the doxygen make commands if we're on the ReadTheDocs server"""

read_the_docs_build = os.environ.get('READTHEDOCS', None) == 'True'

if read_the_docs_build:
run_doxygen("./")
else:
subprocess.call("doxygen Doxyfile", shell=True)

def setup(app):

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

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

Expand All @@ -72,9 +98,39 @@ def mkindex(dirname):
extensions = [
"sphinx_rtd_theme",
'myst_parser',
'sphinx.ext.autosummary'
'sphinx.ext.autosummary',
'breathe',
'exhale'
]

# breathe_domain_by_extension = {
# "h" : "cpp",
# }
breathe_projects = {"myproject": "_build/xml/"}
breathe_default_project = "myproject"

exhale_args = {
"containmentFolder": "./API_CC",
"rootFileName": "api_cc.rst",
"rootFileTitle": "C++ API",
"doxygenStripFromPath": "..",
# Suggested optional arguments
# "createTreeView": True,
# TIP: if using the sphinx-bootstrap-theme, you need
# "treeViewIsBootstrap": True,
"exhaleExecutesDoxygen": True,
"exhaleDoxygenStdin": "INPUT = ../source/api_cc/include/",
# "unabridgedOrphanKinds": {"namespace"}
# "listingExclude": [r"namespace_*"]
}

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

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

#
myst_heading_anchors = 4

# Add any paths that contain templates here, relative to this directory.
Expand Down
3 changes: 2 additions & 1 deletion doc/development/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Developer Guide

- [API](api.rst)
- [Python API](../api.rst)
- [C++ API](../API_CC/api_cc.rst)
- [Coding Conventions](coding-conventions.rst)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
cmake_minimum_required_version="3.0",
extras_require={
"test": ["dpdata>=0.1.9", "ase", "pytest", "pytest-cov", "pytest-sugar"],
"docs": ["sphinx", "recommonmark", "sphinx_rtd_theme", "sphinx_markdown_tables", "myst-parser"],
"docs": ["sphinx", "recommonmark", "sphinx_rtd_theme", "sphinx_markdown_tables", "myst-parser", "breathe", "exhale"],
**extras_require,
},
entry_points={"console_scripts": ["dp = deepmd.entrypoints.main:main"]},
Expand Down
Loading