Sphinx extension providing the custom DSL for generating structured documentation blocks.
Project description
Doc Lang – Sphinx extension
Sphinx Documentation Language Extension with Custom Commands and Templates
This Sphinx extension introduces DocLang, a lightweight domain‑specific language designed to generate structured, expressive and automation‑friendly documentation blocks inside Python docstrings.
Why DocLang Exists
DocLang began as a simple keyword replacer — a lightweight way to inject small pieces of text into docstrings. Over time, it evolved into a flexible inline command system with templates, introspection, and automation features. Despite this growth, the core idea has remained the same:
DocLang helps automate repetitive parts of documentation.
Most projects contain patterns that repeat across multiple classes. In UI/UX
libraries, this is especially common: attributes such as background,
background_color, text_color, font_size, font_name or font_family
appear in many widgets and their descriptions often differ only by a few words.
DocLang allows you to define custom commands and templates that encapsulate these
repetitive descriptions, letting you focus on the actual implementation instead
of rewriting boilerplate documentation.
The same applies to event systems. For example, in a button or other behavior class, events often follow predictable naming and implementation patterns. With DocLang, you can create a command that scan a class for events, locate their implementations, extract the docstring descriptions and automatically generate an event list at the top of the page. This means you can add or remove events without worrying about manually updating the documentation — DocLang handles it for you.
DocLang is designed to be extended. Users are encouraged to define their own commands based on the needs of their project, creating a documentation workflow that is both expressive and maintainable.
Features
- New commands: Creating custom commands.
- Overwrite commands: Override existing commands with your own implementations.
- Default commands: Simple built‑in commands for generating delimiters, titles, sections, and lists.
- Self‑introspection commands: Retrieve the object's name, type, documentation, and signature.
- Fully compatible with Sphinx autodoc
- Zero configuration required beyond enabling the extension
DocLang is designed to keep your docstrings readable while producing rich, structured documentation output.
Requirements
- Python • 3.12+
- Sphinx • 9.1.0+
Installation
pip install sphinx-doclang
Usage
Enable the extension
In your conf.py, add the extension to the extensions list.
Below is an example of a typical Sphinx configuration:
extensions = [
"sphinx.ext.autodoc", # pull in docstrings from code
"sphinx.ext.autosummary", # generate summary/API pages
"sphinx.ext.napoleon", # support Google/NumPy-style docstrings
"sphinx.ext.intersphinx", # link to external docs (Kivy, Python, etc.)
"sphinx.ext.todo", # support for exposing todo notes
"sphinx_localtoc", # stylizing the local ToC
"sphinx_doclang" # DSL for documentation language
]
Example of usage
DocLang commands can be used directly inside docstrings:
class Example:
"""
A simple example class.
§ list : First item, Second item, Third item ¶
§ section : debug purpose only, style = camel ¶
§ debug object ¶
"""
DocLang commands always begin with § command : arguments ¶.
The DSL is intentionally minimal and easy to read inside source code.
Configuration options
The extension provides the following configuration variables, shown here with their default values:
# Character that marks the beginning of a DocLang command.
doclang_command_start = "§"
# Character that marks the end of a DocLang command.
doclang_command_end = "¶"
# Character used to separate the command name from its arguments.
doclang_command_splitter = ":"
# Characters used to separate multiple arguments inside a command.
# Each character acts as a valid separator.
doclang_argument_separator = ",;"
# Character used to separate keywords from their assigned values.
doclang_keyword_separator = "="
# Character used to mark comments inside DocLang command blocks.
doclang_comment_marker = "#"
# Characters used to escape DocLang syntax when literal text is required.
# Each character acts as a valid escaper.
doclang_escape_marker = "/|"
# Whether unknown or unregistered commands should be preserved instead of removed.
doclang_keep_unknown = False
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sphinx_doclang-26.7.8.tar.gz.
File metadata
- Download URL: sphinx_doclang-26.7.8.tar.gz
- Upload date:
- Size: 20.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b2f64c3eb5e382bfbfc3530f7e86aa699edbbf6190496c11880d2cc7da7517bb
|
|
| MD5 |
457000af5a7db190b0baab343cf0e2a2
|
|
| BLAKE2b-256 |
53fdcf70699b1065273da0de6e84f7ce2fb7edebe62eb053c416f3828f9013d4
|
File details
Details for the file sphinx_doclang-26.7.8-py3-none-any.whl.
File metadata
- Download URL: sphinx_doclang-26.7.8-py3-none-any.whl
- Upload date:
- Size: 19.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13c431d307cfacfc7adbcaf799a3bb962288e39a02160f30b8cb96452e141128
|
|
| MD5 |
3711e7d4a6b1c4ccce97608f14699b0d
|
|
| BLAKE2b-256 |
dbea6b2450a10e11f6a21fa94fb5c5462159bf83d267020bbe71186a692c95a8
|