Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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:

  1. Doxygen generates XML from the C# sources.
  2. Breathe and sphinx-csharp convert the XML to Sphinx documentation.

Usage

Install using pip:

pip install sphinx-csharp

Enable the extension in your conf.py:

extensions = ['sphinx_csharp']

See tests/roots/test-basic/index.rst for examples of the cs directives and roles.

Each object gets an entry in the general index, such as MyNamespace.MyClass (C# class). To leave an object out, add the :no-index-entry: option:

.. cs:function:: void Helper ()
   :no-index-entry:

conf.py Options

The options below can be set in conf.py. They are registered in __init__.py, and the defaults for external references are in extrefs_data.py. Values you set are merged with these defaults.

Here are all the options. The lists and dictionaries hold example values, which are added to the defaults:

# Are other languages used in the sphinx project, if yes add language (domain) prefix to reference labels
sphinx_csharp_multi_language = False

# Should generated external links be tested for validity
sphinx_csharp_test_links = False

# Show types in these namespaces, and in namespaces nested inside them, without their namespace
sphinx_csharp_unqualified_namespaces = [
    'UnityEngine',
]

# Never link these types
sphinx_csharp_ignore_xref = [
    'Vector2',
    ...
]

# How to generate external doc links, replace %s with type. Use the format
#    'package name': ('direct link to %s', 'alternate backup link or search page')
sphinx_csharp_ext_search_pages = {
    'upm.xrit': ('https://docs.unity3d.com/Packages/com.unity.xr.interaction.toolkit@0.9/api/%s.html',
                 'https://docs.unity3d.com/Packages/com.unity.xr.interaction.toolkit@0.9/?%s'),
    ...
}

# Types that are in an external package. Use the format
#   'package name': {
#      'Namespace1': ['Type1', 'Type2'],
sphinx_csharp_ext_type_map = {
    'unity': {
        '': ['MonoBehaviour', 'ScriptableObject'],
        'XR': ['InputDevice', 'InputDeviceCharacteristics'],
        ...
    },
   ...
}

# [Advanced] Rename type before generating external link. Commonly used for generic types
sphinx_csharp_external_type_rename = {
    'List': 'List-1',
    'NativeArray': 'NativeArray_1',
    ...
}

# Debug options, these enable various verbose logging features.
sphinx_csharp_debug = False # enables all debug options
sphinx_csharp_debug_parse = False # enables all parsing options
sphinx_csharp_debug_parse_func = False
sphinx_csharp_debug_parse_var = False
sphinx_csharp_debug_parse_prop = False
sphinx_csharp_debug_parse_attr = False
sphinx_csharp_debug_parse_idxr = False
sphinx_csharp_debug_parse_type = False
sphinx_csharp_debug_xref = False
sphinx_csharp_debug_ext_links = False

Development

The project uses Hatch. The Breathe test also needs Doxygen on the PATH.

hatch run lint:check                   # ruff
hatch run types:check                  # mypy
hatch run test:all                     # tests and coverage on every supported Python
hatch run +py=3.14 test:all -k parse   # selected tests on one Python
hatch build                            # sdist and wheel in dist/

The tests use pytest. tests/test_parse.py covers the signature parsers, and tests/test_render.py checks rendered signatures and cross-references. tests/test_projects.py builds the projects in tests/roots in nitpicky mode and fails on any warning. test-breathe renders C# sources through Doxygen and Breathe, and is skipped if Doxygen is not installed.

Common Bug Sources

  • Newer C# syntax that is not supported yet, see regexes at beginning of csharp.py for parsing
  • Incorrect xml reconstruction in breathe, see def visit_* in breathe render/sphinxrenderer.py
    • e.g. visit_variable will create the signature that is given to csharp.py

Examples

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.0rc1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sphinx-csharp 1.0.0rc1
File Size Uploaded Provenance
sphinx_csharp-1.0.0rc1.tar.gz 24.0 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for sphinx-csharp 1.0.0rc1
File Interpreter ABI Platform
sphinx_csharp-1.0.0rc1-py3-none-any.whl Python 3 none any Details

Total release size: 41.0 kB

Release files / sphinx_csharp-1.0.0rc1.tar.gz

Download URL sphinx_csharp-1.0.0rc1.tar.gz
Size 24.0 kB
Tags Source
SHA-256 checksum
How to use checksums
77b6efdefe8ec3c5fdf1b4b20fdcfdc59b275448c208a5109aa1045b1044a017
BLAKE2b-256 checksum
How to use checksums
aa7fe639bbaffe6d56bec050ac8556e811da4399eceabb9e9b1235df7bf47f42
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 15, 2026.

Transparency log

Release files / sphinx_csharp-1.0.0rc1-py3-none-any.whl

Download URL sphinx_csharp-1.0.0rc1-py3-none-any.whl
Size 17.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
53e42168dd91801e50278dfcb35cb0b08cec7ac694fd54a95bebd8ea1db54a48
BLAKE2b-256 checksum
How to use checksums
07d94fb429eb0ee8f47076df92d1ae0632febbab0386d93deb990d9070c0eb8f
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 15, 2026.

Transparency log

Security for sphinx-csharp 1.0.0rc1

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.

Select from 2 files

Attestation for sphinx_csharp-1.0.0rc1.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 15, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page