Skip to main content

Parse Doxygen-documented C++ with libclang and generate MyST Markdown API docs for Sphinx

Project description

clangquill

ClangQuill Logo

image

Parse Doxygen-documented C++ with libclang and generate MyST Markdown API docs for Sphinx.

clangquill reads your C++ headers with libclang, extracts classes, functions, namespaces, enums and their documentation comments into a SQLite intermediate representation, and renders MyST Markdown pages. Every symbol becomes a real Sphinx C++ domain object ({cpp:class}, {cpp:function}, …) — so the generated API appears in objects.inv and cross-references like any hand-written page, with inter-symbol links resolved through {cpp:any}.

Features

  • libclang-based parsing of real C++ (c++20 / c++23 / c++26), including Doxygen comments and compile_commands.json support.
  • First-class Sphinx integration — output is MyST Markdown backed by the Sphinx C++ domain, so symbols cross-reference and show up in the search index.
  • Three front-ends for the same pipeline: a Sphinx extension, a clangquill CLI, and a Python API.
  • Incremental builds — a persistent SQLite IR plus a hash cache skip re-parsing unchanged inputs, rewrite only pages whose content changed, and delete pages for symbols that disappeared.
  • Customizable output via per-kind Jinja2 templates you can override one file at a time.
  • Pluggable comment parsers (Doxygen by default).

Installation

clangquill is published on PyPI. Install it with uv:

uv pip install clangquill

(Plain pip install clangquill works too.)

The Linux wheels bundle a self-contained libclang 22 from the official LLVM release, so parsing works out of the box with no system LLVM required. That bundled libclang needs glibc ≥ 2.34 (manylinux_2_34); on older distributions, build from source against your own libclang instead.

Quick start

Sphinx extension

For the common case you do not need to drive the parser yourself: enable the bundled extension and it runs the whole pipeline — parse → SQLite → MyST — at build time, regenerating pages into your source tree before Sphinx reads them.

# conf.py
extensions = ["clangquill.sphinx_ext"]  # pulls in myst_parser automatically

clangquill_input = ["../include/**/*.hpp"]
clangquill_output_dir = "api"          # written under the Sphinx srcdir
clangquill_std = "c++20"
clangquill_include_dirs = ["../include"]

Then reference the generated toctree from your root document:

```{toctree}
api/index
```

Every knob is a clangquill_* config value mirroring a field of clangquill.config.Config — including clangquill_compile_commands, clangquill_template_dirs, clangquill_include_undocumented, clangquill_comment_parser and clangquill_group_by. See the configuration guide for the full reference.

Command line

The same pipeline is available standalone, handy for previewing output or wiring clangquill into a non-Sphinx build:

$ clangquill build include/geo.hpp -o docs/api --std c++20 -I include
Parsed 7 symbol(s) from 1 file(s).
Wrote 1 page(s) to /path/to/docs/api.

Run clangquill build --help for the full set of options, which mirror the clangquill_* config values.

Python API

Once a project has been parsed into the SQLite IR, the generator renders it into MyST Markdown: one page per top-level symbol plus an index.md toctree.

from clangquill.generator import Generator
from clangquill.store import Store

with Store.open("api.sqlite") as store:
    Generator(store).generate("docs/api")

Incremental builds

Set clangquill_cache_dir (or the matching CLI/API option) to make rebuilds incremental. clangquill keeps the SQLite IR and a small bookkeeping cache between runs and:

  • skips the parse when no input — or transitively #included header — changed, reusing the cached IR instead of invoking libclang again;
  • rewrites only the pages whose content changed; and
  • deletes pages whose symbols disappeared.

Without a cache directory the build is stateless: it re-parses into a throwaway database and rewrites every page each time.

Templates

Templates are the customization point. The Jinja environment looks up {kind}.md.jinja (e.g. class.md.jinja, function.md.jinja) in your own template directories before the bundled defaults, so dropping in a file of the same name overrides just that kind:

Generator(store, template_dirs=["my_templates"]).generate("docs/api")

See the templates guide for the available templates and context variables.

Building from source

clangquill ships a compiled C++ core (clangquill._core) built with scikit-build-core, CMake and nanobind. A standard install builds it:

uv pip install .
uv run python -c "from clangquill import _core; print(_core.have_libclang())"

The core optionally links libclang; when libclang-dev (or an LLVM prefix via LibClang_ROOT) is available at build time the extraction backend is enabled. Pass -DCLANGQUILL_WITH_LIBCLANG=ON to require it.

Documentation

Contributing

Contributions are welcome — see CONTRIBUTING.md. In short:

uv sync --extra dev
uvx pre-commit install
uv run pytest      # Python test suite
make cpp-test      # C++ (Catch2) unit tests

License

clangquill is released under the BSD 2-Clause License — see LICENSE. The Linux wheels additionally bundle libclang, distributed under the Apache-2.0 WITH LLVM-exception license.

Credits

This package was created with Cookiecutter and the renefritze/python_cookiecutter project template.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

clangquill-0.5.0.tar.gz (1.6 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

clangquill-0.5.0-cp313-cp313-manylinux_2_34_x86_64.whl (60.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ x86-64

clangquill-0.5.0-cp313-cp313-manylinux_2_34_aarch64.whl (56.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.34+ ARM64

File details

Details for the file clangquill-0.5.0.tar.gz.

File metadata

  • Download URL: clangquill-0.5.0.tar.gz
  • Upload date:
  • Size: 1.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for clangquill-0.5.0.tar.gz
Algorithm Hash digest
SHA256 06eb78e8f84c3aefdea69491e0a25aaf7400be544f668072ed2f68a3c43f2626
MD5 3d5a5fba1b15923f5825e153410f38c7
BLAKE2b-256 ba253260c18cef346646942a90b5c5d8fe673ac677589caf273e44ea33283254

See more details on using hashes here.

Provenance

The following attestation bundles were made for clangquill-0.5.0.tar.gz:

Publisher: deploy.yml on renefritze/clangquill

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file clangquill-0.5.0-cp313-cp313-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for clangquill-0.5.0-cp313-cp313-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 ffad419e109cc7f3cee6df4de07f2fe307262565b0c56eb572f160fd57d3e060
MD5 a858abe813c79c6133e96f3eba52d78f
BLAKE2b-256 d648c401b7bba1d562f2e54eb00de8e68ac4fa9adc85b1264ffd290c5cabd350

See more details on using hashes here.

Provenance

The following attestation bundles were made for clangquill-0.5.0-cp313-cp313-manylinux_2_34_x86_64.whl:

Publisher: deploy.yml on renefritze/clangquill

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file clangquill-0.5.0-cp313-cp313-manylinux_2_34_aarch64.whl.

File metadata

File hashes

Hashes for clangquill-0.5.0-cp313-cp313-manylinux_2_34_aarch64.whl
Algorithm Hash digest
SHA256 e3e2df0c83093aac2c02938c8fb027523485d4f967105bf03ec2f264e0cf411b
MD5 e4a9693e682db95fdee684d0287feead
BLAKE2b-256 1d14a1769581ef1801b9318c922120d53fbe2fee4c1849890e0ef07b2fde0147

See more details on using hashes here.

Provenance

The following attestation bundles were made for clangquill-0.5.0-cp313-cp313-manylinux_2_34_aarch64.whl:

Publisher: deploy.yml on renefritze/clangquill

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page