Skip to content

Latest commit

 

History

History
179 lines (130 loc) · 5.73 KB

README.md

File metadata and controls

179 lines (130 loc) · 5.73 KB

DEM-Engine documentation

Browse the online documentation, including the Python API and methods and C++ API reference.

Start with the documentation index, installation, or Python quickstart. Maintainers can find hosting options and wheel packaging in the developer guide.

Building and publishing documentation

The documentation index collects the guide sources. The online site is currently hosted by the Ruochun fork. GitHub Actions rebuilds and publishes it on pushes to the branch selected by that repository's DOCS_PUBLISH_BRANCH variable. See Hosting for setup and switching publication to main. The C++ reference is generated from headers; the Python reference must be regenerated and committed when bindings change.

The documentation site combines:

  • authored Sphinx pages for installation, concepts, and Python usage;
  • a C++ API reference generated by Doxygen and Breathe; and
  • a static Python API reference generated from the installed pybind11 module.

Generated HTML, Doxygen XML, and other files under docs/_build/ are ignored by Git.

Install the documentation tools

Doxygen must be installed as an executable. Create a Python environment and install the Sphinx dependencies:

python3 -m venv .venv-docs
source .venv-docs/bin/activate
python -m pip install -r docs/requirements.txt

Install Doxygen through the operating system or Conda if it is not already available:

conda install -c conda-forge doxygen

Check the toolchain:

doxygen --version
sphinx-build --version

Build the complete site

From the repository root:

/usr/bin/make -C docs html

Using /usr/bin/make is helpful on machines where make is aliased to ninja. This command:

  1. syntax-checks the Python examples;
  2. generates Doxygen XML for the C++ public API; and
  3. builds the complete Sphinx HTML site with warnings treated as errors.

The resulting entry page is:

docs/_build/html/index.html

To remove generated output:

/usr/bin/make -C docs clean

The equivalent CMake documentation target is:

cmake -S . -B build-docs -DDEME_BUILD_DOCS=ON
cmake --build build-docs --target docs

Regenerate the Python API reference

Normal HTML builds use the committed docs/python/reference.rst and therefore do not import DEME or require a CUDA GPU.

Regenerate that file after changing pybind11 signatures or docstrings. From the repository root, activate the Python environment used to build the extension and run this complete sequence. Doxygen and Sphinx must also be available:

# Build and stage the current Python extension.
cmake -S . -B build-python \
    -DDEME_BUILD_PYTHON=ON \
    -DCMAKE_BUILD_TYPE=Release
cmake --build build-python --target _deme --parallel
cmake --install build-python \
    --component python \
    --prefix /tmp/deme-python-reference

# Generate the reference using the same Python interpreter.
PYTHONPATH=/tmp/deme-python-reference \
    /usr/bin/make -C docs python-reference PYTHON="$(command -v python)"

# Rebuild the documentation (requires Doxygen and Sphinx).
/usr/bin/make -C docs html

# Review the generated changes.
git diff -- docs/python/reference.rst

Do not edit docs/python/reference.rst directly. Improve the corresponding docstring in src/DEM/python/bindings.cpp, rebuild the extension, and regenerate the page.

Publish to GitHub Pages

In Settings → Secrets and variables → Actions → Variables, create or update the repository variable DOCS_PUBLISH_BRANCH to the branch that should publish the documentation. Set it to develop to publish from develop instead of DEME3_docs. This must be a repository variable, not a secret or an environment variable: the workflow reads vars.DOCS_PUBLISH_BRANCH.

Set Settings → Pages → Build and deployment → Source to GitHub Actions, and allow the selected branch in the github-pages environment's deployment branch rules under Settings → Environments.

Commit the documentation sources, including the regenerated Python reference, and push to the selected branch. The Build and publish documentation workflow builds and publishes the site automatically. Keep generated docs/_build/ files out of Git.

An unset variable or a branch mismatch causes push and manual runs to skip the build and deployment. Changing the variable alone does not trigger a build; push a new commit or, when Run workflow is available, select the matching branch and run it manually. Pull requests build for validation without deploying. See hosting options for the full setup details.

Preview on the same machine

Run a local HTTP server from the repository root:

python3 -m http.server 8000 \
    --bind 127.0.0.1 \
    --directory docs/_build/html

Open http://127.0.0.1:8000/ in a browser. Stop the server with Ctrl+C.

Preview a remote build through SSH

Start the same loopback-only HTTP server on the remote build machine. From the local workstation, create an SSH tunnel:

ssh -L 8000:127.0.0.1:8000 username@remote-host

Keep the SSH connection open and visit http://127.0.0.1:8000/ locally.

For a trusted local network, the server can instead listen on every interface:

python3 -m http.server 8000 \
    --bind 0.0.0.0 \
    --directory docs/_build/html

The site is then available at http://HOST_IP:8000/, subject to firewall rules. Prefer SSH forwarding when the remote host should not expose the documentation server publicly.