Sphinx Combine
Extension for Sphinx which enables combining code blocks.
Installation
sphinx-combine is compatible with Sphinx 7.2.0+ using Python 3.11+.
$ pip install sphinx-combine
Setup
Add the following to conf.py to enable the extension:
"""Configuration for Sphinx."""
extensions = ["sphinxcontrib.spelling"] # Example existing extensions
extensions += ["sphinx_combine"]
Using combined-code-block
The extension provides a new directive, combined-code-block, which allows you to combine multiple code blocks into a single code block.
The directive takes a language argument which is used to determine the syntax, as well as all options that the code-block directive supports.
Languages and options of code blocks within the directive are ignored.
.. combined-code-block:: python
.. literalinclude:: my_code.js
:language: javascript
.. code-block:: python
"""First code block."""
.. code-block:: cpp
// Second code block.
By default, there are no blank lines between the code blocks. To add a blank line, use |.
Only nested code blocks (and literalinclude) are merged. Other nested content is skipped, and Sphinx emits a warning for each skipped node. Use -W to treat those warnings as errors.
MyST Markdown
With MyST Parser, nest directives using a longer outer fence so inner fenced blocks are not truncated:
````{combined-code-block} python
```{code-block} python
x = 1
```
```{code-block} python
y = 2
```
````
Contributing
See CONTRIBUTING.rst.
Metadata
Release files for sphinx-combine 2026.8.23.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sphinx_combine-2026.8.23.1.tar.gz | 30.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sphinx_combine-2026.8.23.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 42.2 kB
Release files / sphinx_combine-2026.8.23.1.tar.gz
| Download URL | sphinx_combine-2026.8.23.1.tar.gz |
|---|---|
| Size | 30.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1195c726487119ac8dba2a513d65bda730ccac0330b58142a1edbdca8d9dacfc
|
|
BLAKE2b-256 checksum How to use checksums |
7df1f7679b6c9b31ec3d6f78454338977847b5aa21ebf3edb3c95de48a97956f
|
| 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 Aug 23, 2026.
Transparency logRelease files / sphinx_combine-2026.8.23.1-py3-none-any.whl
| Download URL | sphinx_combine-2026.8.23.1-py3-none-any.whl |
|---|---|
| Size | 12.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c8b930dba3229894a5d60a33a3a365192a9e161af5c2029fbb78b4adc90194eb
|
|
BLAKE2b-256 checksum How to use checksums |
6d2af6260cdb172af5f2f0f8db4dfa59dd1596d20d8d9d266dd800675fb787b8
|
| 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 Aug 23, 2026.
Transparency log