Skip to main content

Build Status PyPI

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

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

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-combine 2026.8.23
File Size Uploaded
sphinx_combine-2026.8.23.tar.gz 29.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sphinx-combine 2026.8.23
File Interpreter ABI Platform
sphinx_combine-2026.8.23-py3-none-any.whl Python 3 none any Details

Total release size: 41.2 kB

Release files / sphinx_combine-2026.8.23.tar.gz

Download URL sphinx_combine-2026.8.23.tar.gz
Size 29.3 kB
Tags Source
SHA-256 checksum
How to use checksums
bec59d713178295ac6eedb2275c19a046fe485b7ff287e90c4fc39bcaae88ea9
BLAKE2b-256 checksum
How to use checksums
4b63f41eb81f43ec95c664519bd690741beb0feec6ef41993e7fc0d6161fbd57
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

Release files / sphinx_combine-2026.8.23-py3-none-any.whl

Download URL sphinx_combine-2026.8.23-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6607129c0944797b101f93ccc420e5958f0443ad66e941a92490542674711923
BLAKE2b-256 checksum
How to use checksums
f0cbb741ecd60ae4b4a1fb8807e99baeebd70a264580bdff9484f99bec115875
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
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