Skip to content

Commit f7ddf51

Browse files
committed
feat(docs): add complete C++ API reference
1 parent 173eb24 commit f7ddf51

File tree

7 files changed

+144
-1
lines changed

7 files changed

+144
-1
lines changed

.github/workflows/docs.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,16 @@ jobs:
3131
run: |
3232
python -m pip install tox
3333
sudo apt install doxygen
34+
wget -qO- https://apt.fury.io/nushell/gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/fury-nushell.gpg
35+
echo "deb [signed-by=/etc/apt/keyrings/fury-nushell.gpg] https://apt.fury.io/nushell/ /" | sudo tee /etc/apt/sources.list.d/fury-nushell.list
36+
sudo apt update
37+
sudo apt install nushell liblua5.2-0
3438
3539
- name: build documentation
3640
env:
3741
# Use the CPU only version of torch when building/running the code
3842
PIP_EXTRA_INDEX_URL: https://download.pytorch.org/whl/cpu
39-
run: tox -e docs
43+
run: nu scripts/mkdoc.nu
4044

4145
- name: store documentation as github artifact to be downloaded by users
4246
uses: actions/upload-artifact@v6

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.tmp
12
# Python stuff
23
__pycache__
34
*.egg-info/
@@ -7,3 +8,5 @@ build/
78
htmlcov/
89
.coverage*
910
coverage.xml
11+
/docs/src/api/
12+
/docs/subprojects/

docs/Doxyfile.metatomic

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Customized Options
2+
# Make changes here to prevent things from being overwritten when the main file
3+
# is updated
4+
5+
# Defaults
6+
@INCLUDE = "./Doxyfile"
7+
8+
# XML
9+
GENERATE_XML = YES
10+
XML_PROGRAMLISTING = NO
11+
# Sphinx uses lowercase references so..
12+
CASE_SENSE_NAMES = NO
13+
# Prevents links to template arguments
14+
HIDE_UNDOC_RELATIONS = YES
15+
16+
# HTML
17+
GENERATE_HTML = NO
18+
USE_MATHJAX = NO
19+
20+
# LaTeX
21+
GENERATE_LATEX = NO
22+
23+
# Project Settings
24+
PROJECT_NAME = "metatomic"
25+
26+
# Doxygen Settings
27+
RECURSIVE = YES
28+
INPUT = ../metatomic-torch/include/metatomic \
29+
../metatomic-torch/include/metatomic/torch
30+
OUTPUT_DIRECTORY = build/doxygen
31+
CREATE_SUBDIRS = YES
32+
33+
# Language additions
34+
OPTIMIZE_OUTPUT_FOR_C = NO
35+
BUILTIN_STL_SUPPORT = NO
36+
37+
# Style
38+
JAVADOC_BANNER = YES
39+
JAVADOC_AUTOBRIEF = NO
40+
INHERIT_DOCS = YES
41+
INLINE_SOURCES = YES
42+
SOURCE_BROWSER = YES
43+
DISABLE_INDEX = NO
44+
GENERATE_TREEVIEW = NO
45+
HAVE_DOT = YES
46+
DOT_IMAGE_FORMAT = YES
47+
HTML_DYNAMIC_SECTIONS = YES
48+
INTERACTIVE_SVG = YES
49+
# # We link to standard definitions
50+
# TAGFILES += "./tags/cppreference-doxygen-web.tag.xml=http://en.cppreference.com/w/"
51+
52+
# Extract everything
53+
EXTRACT_ALL = NO
54+
EXTRACT_PRIVATE = YES
55+
EXTRACT_PRIV_VIRTUAL = YES
56+
EXTRACT_PACKAGE = YES
57+
EXTRACT_STATIC = YES
58+
MACRO_EXPANSION = YES
59+
ENABLE_PREPROCESSING = YES
60+
61+
# Local Variables:
62+
# mode: conf
63+
# End:

docs/doxyrest-config.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
INPUT_FILE = "build/doxygen/xml/index.xml"
2+
OUTPUT_FILE = "src/api/index.rst"
3+
INDEX_TITLE = "C++ API Reference"
4+
5+
FRAME_DIR_LIST = {
6+
"subprojects/doxyrest/frame/common",
7+
"subprojects/doxyrest/frame/cfamily"
8+
}
9+
10+
LANGUAGE = "cpp"
11+
ESCAPE_ASTERISKS = true
12+
ESCAPE_TRAILING_UNDERSCORES = true

docs/src/conf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
1818
sys.path.append(os.path.join(ROOT, "docs", "extensions"))
1919

20+
# For doxyrest
21+
sys.path.insert(0, os.path.join(ROOT, "docs", "subprojects", "doxyrest", "sphinx"))
2022

2123
# We use a second (pseudo) sphinx project located in `docs/generate_examples` to run the
2224
# examples and generate the actual output for our sphinx-gallery. This is necessary
@@ -135,6 +137,9 @@ def setup(app):
135137
"myst_parser",
136138
"sphinx_design",
137139
"chemiscope.sphinx",
140+
# c++ helpers
141+
"doxyrest",
142+
"cpplexer",
138143
# local extensions
139144
"versions_list",
140145
]

docs/src/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,6 @@ existing trained models, look into the metatrain_ project instead.
9595
outputs/index
9696
engines/index
9797
examples/index
98+
api/global
99+
api/index
98100
cite

scripts/mkdoc.nu

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env nu
2+
3+
def main [] {
4+
let root = ($env.PWD)
5+
let deps_dir = ($root | path join "docs/subprojects")
6+
let doxyrest_src = ($deps_dir | path join "doxyrest")
7+
let install_dir = ($deps_dir | path join "install")
8+
let has_doxyrest = (which doxyrest | is-not-empty)
9+
10+
# Setup Directory Structure
11+
if not ($deps_dir | path exists) {
12+
mkdir $deps_dir
13+
}
14+
15+
# Grab Doxyrest if missing
16+
if not $has_doxyrest and not ($install_dir | path exists) {
17+
print "Downloading Doxyrest binary release..."
18+
let version = "2.1.3"
19+
let target = "linux-amd64"
20+
let archive = $"doxyrest-($version)-($target).tar.xz"
21+
let url = $"https://github.com/vovkos/doxyrest/releases/download/doxyrest-($version)/($archive)"
22+
23+
cd $deps_dir
24+
http get $url | save $archive
25+
tar -xJf $archive
26+
27+
if ($install_dir | path exists) { rm -rf $install_dir }
28+
mv $"doxyrest-($version)-($target)" $install_dir
29+
30+
rm $archive
31+
cd $root
32+
}
33+
34+
# Still needed for the frames..
35+
if not ($doxyrest_src | path exists) {
36+
print $"Cloning doxyrest into ($doxyrest_src)..."
37+
git clone --depth 1 --single-branch https://github.com/vovkos/doxyrest $doxyrest_src
38+
}
39+
40+
# Run the Pipeline
41+
print "Generating XML with Doxygen..."
42+
cd docs
43+
mkdir build/doxygen/xml
44+
doxygen Doxyfile.metatomic
45+
46+
print "Generating RST with local Doxyrest..."
47+
# Add local bin to path for this execution
48+
with-env { PATH: ($env.PATH | prepend ($install_dir | path join "bin")) } {
49+
doxyrest -c doxyrest-config.lua
50+
}
51+
52+
print "Building HTML with Sphinx (tox)..."
53+
tox -e docs
54+
}

0 commit comments

Comments
 (0)