sphinx-csharp
A Sphinx domain for documenting C# APIs. You can write pages by hand with the cs directives, or generate them from C# sources with Doxygen and Breathe.
The documentation is at djungelorm.github.io/sphinx-csharp.
Usage
Install the package from PyPI:
pip install sphinx-csharp
Enable the extension in your conf.py:
extensions = ['sphinx_csharp']
Then describe your API with the cs directives, and link to it with the cs roles:
.. cs:namespace:: Geometry
.. cs:class:: public class Circle : Shape
.. cs:function:: public double Area ()
The area of a :cs:type:`Circle` is :cs:meth:`Circle.Area`.
Development
The project uses Hatch. The Breathe tests also need Doxygen on the PATH, and the lint check needs the .NET SDK.
Checks
hatch run lint:check # ruff, and dotnet build on the Breathe sources
hatch run types:check # mypy
hatch run package:check # build dist/, check it with twine, and build with the wheel
hatch build # sdist and wheel in dist/
Tests
hatch run matrix:all # tests and coverage in every environment, in parallel
hatch run matrix:all --python 3.14 # every environment for one Python
hatch run matrix:all --full-breathe 5.1 # every test with Breathe 5.1, and the Breathe tests with the others
hatch run test.py3.14-9.1-5.1:all -k parse # selected tests in one environment
hatch run test.py3.14-9.1-5.1:corpus # the corpus test
The tests use pytest, and any warning fails them, except the deprecation warnings that Breathe raises:
tests/test_parse.pycovers the signature parsers.tests/test_render.pychecks rendered signatures and cross-references.tests/test_projects.pybuilds the projects intests/rootsin nitpicky mode.test-breatheruns Doxygen and Breathe, and is skipped without Doxygen.tests/test_corpus.pybuilds Newtonsoft.Json, NodaTime, Polly, MoreLINQ and the CommunityToolkit high performance library through Doxygen and Breathe. pytest leaves it out unless you select it with-m corpus.
The environments cover every supported Python, each Sphinx minor version from 7.2, and Breathe 4.35, 4.36, 5.0 and 5.1.
Snapshots
Each test project compares its rendered signatures with the signatures.txt in its directory. After a change to the rendering, rewrite them with Breathe 5 installed:
pytest tests/test_projects.py --update-snapshots
Doxygen 1.15.0 and 1.9.8 must give the same signatures.
Corpus Test
The corpus test lists the warnings that Doxygen and Breathe cause for each library and Doxygen version. It fails on any other warning, and on a listed warning that matches no warning of the build. It downloads the libraries into .cache/corpus, or the directory in SPHINX_CSHARP_CORPUS_CACHE.
CI
- Every test with Breathe 5.1 and Doxygen 1.15.0.
- The Breathe tests with the other Breathe versions, and with Doxygen 1.9.8 from Ubuntu 24.04.
- Every test on Windows with Python 3.14, Sphinx 9.1, Breathe 5.1 and Doxygen 1.15.0. Sphinx reads serially there, so the parallel build tests skip.
- The corpus test, in a separate job.
package:check. The release publishes thedist/that it checks.
Documentation
hatch run docs:build # the documentation in docs/_build/html
hatch run docs:serve # serve it, and rebuild it on each change
Debugging Breathe Output
A signature that Breathe renders wrongly usually comes from C# syntax that the Parser productions in parser.py do not accept yet. The other cause is the signature that a visit_* method in Breathe's renderer/sphinxrenderer.py writes.
Examples
- The kRPC C# client documentation is the main example of the
csdomain in use. - The vr-modeling documentation by Roger Barton is generated from C# sources through Doxygen and Breathe. Its
conf.pyshows the options in use.
Credits
sphinx-csharp was originally written by djungelorm.
Breathe integration and much of the current parser were contributed by Roger Barton in #8.
Metadata
Release files for sphinx-csharp 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| sphinx_csharp-1.0.0.tar.gz | 73.8 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sphinx_csharp-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 112.6 kB
Release files / sphinx_csharp-1.0.0.tar.gz
| Download URL | sphinx_csharp-1.0.0.tar.gz |
|---|---|
| Size | 73.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
06fa944ea206613fea8d3542c1fea666acb4e8389cfd36c930a9938cca396f79
|
|
BLAKE2b-256 checksum How to use checksums |
35219bebd36ffbad6e5bb5fc3dec2a2a148ee71200fc461c849ba8c8f455b52a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logRelease files / sphinx_csharp-1.0.0-py3-none-any.whl
| Download URL | sphinx_csharp-1.0.0-py3-none-any.whl |
|---|---|
| Size | 38.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
423c28e45ad9a1e36b770dc04b6e4cbb7d6afae497bd2014a788ffe171e5f2d1
|
|
BLAKE2b-256 checksum How to use checksums |
cd9f86d5c5c50fd5a6052a772c46a20236d704e0c7bb1b22af762449138215d7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logSecurity for sphinx-csharp 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for sphinx_csharp-1.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.