Skip to main content
author:

Lele Gaifax

contact:

lele@metapensiero.it

license:

GNU General Public License version 3 or later

This is a very simple extension to Sphinx that injects the ability to recognize and pretty print SQLAlchemy statements into its automodule and autoclass directives.

To use it, first of all you must register the extension within the Sphinx environment, adding the full name of the package to the extensions list in the file conf.py, for example:

# Add any Sphinx extension module names here, as strings.
extensions = ['metapensiero.sphinx.autodoc_sa']

Without further settings it uses the default SQLAlchemy stringification strategy, but you can explicitly choose the right dialect by setting autodoc_sa_dialect to a string containing its fully qualified name, for example:

autodoc_sa_dialect = 'sqlalchemy.dialects.postgresql.dialect'

Otherwise, you can set it using the -D option of the sphinx-build command, e.g. adding -D autodoc_sa_dialect=my.own.dialect to the SPHINXOPTS of the Makefile created by sphinx-quickstart.

At this point, any documented SQLAlchemy core statement or ORM query, appearing either at the module level or as a class attribute, will be compiled into SQL, beautified using sqlparse.format() and added to the documentation wrapped within a code-block:: sql directive.

If you chose a specific SQLAlchemy dialect, by any chance you may want to select the right Pygments lexer to adjust the highlighting rules, instead of the default sql:

autodoc_sa_pygments_lang = 'postgresql'

If you are using PostgreSQL, you may prefer using the pglast SQL prettifier over the default one based on sqlparse:

autodoc_sa_prettifier = 'pglast'

Metadata

Release files for metapensiero.sphinx.autodoc-sa 2.2

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

Source distribution (sdist)

Source distribution for metapensiero.sphinx.autodoc-sa 2.2
File Size Uploaded Provenance
metapensiero_sphinx_autodoc_sa-2.2.tar.gz 11.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for metapensiero.sphinx.autodoc-sa 2.2
File Interpreter ABI Platform
metapensiero_sphinx_autodoc_sa-2.2-py3-none-any.whl Python 3 none any Details

Total release size: 17.0 kB

Release files / metapensiero_sphinx_autodoc_sa-2.2.tar.gz

Download URL metapensiero_sphinx_autodoc_sa-2.2.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5caa1df612973ef8527c4cdf23600e3cf39c110c078ba9ef9667b474a083f276
BLAKE2b-256 checksum
How to use checksums
63cfe58fe0fdde0e698031b0fc37de093f323a1a5255337eeeb4fae23e910ff3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Release files / metapensiero_sphinx_autodoc_sa-2.2-py3-none-any.whl

Download URL metapensiero_sphinx_autodoc_sa-2.2-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b845fdad56cb953fbc1f9183047a1d5c83044611274630ff1ac9a7ba840cef36
BLAKE2b-256 checksum
How to use checksums
18843ceb4f6eb64f3e4580d0f8301461d4ab0997b0e36bb60c8ba19d680c3036
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.10

Security for metapensiero.sphinx.autodoc-sa 2.2

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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