sphinx-doclang 26.7.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Afanase Ioan (ASI)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,180 @@
1
+ Metadata-Version: 2.4
2
+ Name: sphinx-doclang
3
+ Version: 26.7.8
4
+ Summary: Sphinx extension providing the custom DSL for generating structured documentation blocks.
5
+ Author: ASI
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Afanase Ioan (ASI)
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+ Project-URL: Source, https://github.com/kmcasi/sphinx-doclang
28
+ Project-URL: Issues, https://github.com/kmcasi/sphinx-doclang/issues
29
+ Keywords: sphinx,extension,dsl,doclang,documentation,autodoc,command
30
+ Classifier: Programming Language :: Python :: 3
31
+ Classifier: Programming Language :: Python :: 3.12
32
+ Classifier: License :: OSI Approved :: MIT License
33
+ Classifier: Framework :: Sphinx
34
+ Classifier: Framework :: Sphinx :: Extension
35
+ Classifier: Intended Audience :: Developers
36
+ Classifier: Topic :: Documentation
37
+ Classifier: Topic :: Documentation :: Sphinx
38
+ Classifier: Topic :: Software Development :: Documentation
39
+ Requires-Python: >=3.12
40
+ Description-Content-Type: text/markdown
41
+ Requires-Dist: Sphinx>=9.1.0
42
+
43
+ # Doc Lang – Sphinx extension
44
+
45
+ ## Sphinx Documentation Language Extension with Custom Commands and Templates
46
+
47
+ This Sphinx extension introduces **DocLang**, a lightweight domain‑specific language designed to generate structured,
48
+ expressive and automation‑friendly documentation blocks inside Python docstrings.
49
+
50
+ ## Why DocLang Exists
51
+
52
+ DocLang began as a simple keyword replacer — a lightweight way to inject small
53
+ pieces of text into docstrings. Over time, it evolved into a flexible inline
54
+ command system with templates, introspection, and automation features. Despite
55
+ this growth, the core idea has remained the same:
56
+
57
+ **DocLang helps automate repetitive parts of documentation.**
58
+
59
+ Most projects contain patterns that repeat across multiple classes. In UI/UX
60
+ libraries, this is especially common: attributes such as `background`,
61
+ `background_color`, `text_color`, `font_size`, `font_name` or `font_family`
62
+ appear in many widgets and their descriptions often differ only by a few words.
63
+ DocLang allows you to define custom commands and templates that encapsulate these
64
+ repetitive descriptions, letting you focus on the actual implementation instead
65
+ of rewriting boilerplate documentation.
66
+
67
+ The same applies to event systems. For example, in a button or other behavior
68
+ class, events often follow predictable naming and implementation patterns. With
69
+ DocLang, you can create a command that scan a class for events, locate
70
+ their implementations, extract the docstring descriptions and automatically
71
+ generate an event list at the top of the page. This means you can add or remove
72
+ events without worrying about manually updating the documentation — DocLang
73
+ handles it for you.
74
+
75
+ DocLang is designed to be extended. Users are encouraged to define their own
76
+ commands based on the needs of their project, creating a documentation workflow
77
+ that is both expressive and maintainable.
78
+
79
+ ---
80
+
81
+ ## Features
82
+
83
+ - **New commands**: Creating custom commands.
84
+ - **Overwrite commands**: Override existing commands with your own implementations.
85
+ - **Default commands**: Simple built‑in commands for generating *delimiters*, *titles*, *sections*, and *lists*.
86
+ - **Self‑introspection commands**: Retrieve the object's *name*, *type*, *documentation*, and *signature*.
87
+ - Fully compatible with **Sphinx autodoc**
88
+ - Zero configuration required beyond enabling the extension
89
+
90
+ DocLang is designed to keep your docstrings readable while producing rich, structured documentation output.
91
+
92
+ ---
93
+
94
+ ## Requirements
95
+
96
+ - **Python** • ***3.12+***
97
+ - **Sphinx** • ***9.1.0+***
98
+
99
+ ---
100
+
101
+ ## Installation
102
+
103
+ ```bash
104
+ pip install sphinx-doclang
105
+ ```
106
+
107
+ ---
108
+
109
+ ## Usage
110
+
111
+ ### Enable the extension
112
+ In your `conf.py`, add the extension to the `extensions` list.
113
+ Below is an example of a typical Sphinx configuration:
114
+
115
+ ```python
116
+ extensions = [
117
+ "sphinx.ext.autodoc", # pull in docstrings from code
118
+ "sphinx.ext.autosummary", # generate summary/API pages
119
+ "sphinx.ext.napoleon", # support Google/NumPy-style docstrings
120
+ "sphinx.ext.intersphinx", # link to external docs (Kivy, Python, etc.)
121
+ "sphinx.ext.todo", # support for exposing todo notes
122
+
123
+ "sphinx_localtoc", # stylizing the local ToC
124
+ "sphinx_doclang" # DSL for documentation language
125
+ ]
126
+ ```
127
+
128
+ ### Example of usage
129
+
130
+ DocLang commands can be used directly inside docstrings:
131
+
132
+ ```python
133
+ class Example:
134
+ """
135
+ A simple example class.
136
+
137
+ § list : First item, Second item, Third item ¶
138
+
139
+ § section : debug purpose only, style = camel ¶
140
+
141
+ § debug object ¶
142
+ """
143
+ ```
144
+
145
+ DocLang commands always begin with ```§ command : arguments ¶```.
146
+ The DSL is intentionally minimal and easy to read inside source code.
147
+
148
+ ---
149
+
150
+ ### Configuration options
151
+
152
+ The extension provides the following configuration variables, shown here with their default values:
153
+
154
+ ```python
155
+ # Character that marks the beginning of a DocLang command.
156
+ doclang_command_start = "§"
157
+
158
+ # Character that marks the end of a DocLang command.
159
+ doclang_command_end = "¶"
160
+
161
+ # Character used to separate the command name from its arguments.
162
+ doclang_command_splitter = ":"
163
+
164
+ # Characters used to separate multiple arguments inside a command.
165
+ # Each character acts as a valid separator.
166
+ doclang_argument_separator = ",;"
167
+
168
+ # Character used to separate keywords from their assigned values.
169
+ doclang_keyword_separator = "="
170
+
171
+ # Character used to mark comments inside DocLang command blocks.
172
+ doclang_comment_marker = "#"
173
+
174
+ # Characters used to escape DocLang syntax when literal text is required.
175
+ # Each character acts as a valid escaper.
176
+ doclang_escape_marker = "/|"
177
+
178
+ # Whether unknown or unregistered commands should be preserved instead of removed.
179
+ doclang_keep_unknown = False
180
+ ```
@@ -0,0 +1,138 @@
1
+ # Doc Lang – Sphinx extension
2
+
3
+ ## Sphinx Documentation Language Extension with Custom Commands and Templates
4
+
5
+ This Sphinx extension introduces **DocLang**, a lightweight domain‑specific language designed to generate structured,
6
+ expressive and automation‑friendly documentation blocks inside Python docstrings.
7
+
8
+ ## Why DocLang Exists
9
+
10
+ DocLang began as a simple keyword replacer — a lightweight way to inject small
11
+ pieces of text into docstrings. Over time, it evolved into a flexible inline
12
+ command system with templates, introspection, and automation features. Despite
13
+ this growth, the core idea has remained the same:
14
+
15
+ **DocLang helps automate repetitive parts of documentation.**
16
+
17
+ Most projects contain patterns that repeat across multiple classes. In UI/UX
18
+ libraries, this is especially common: attributes such as `background`,
19
+ `background_color`, `text_color`, `font_size`, `font_name` or `font_family`
20
+ appear in many widgets and their descriptions often differ only by a few words.
21
+ DocLang allows you to define custom commands and templates that encapsulate these
22
+ repetitive descriptions, letting you focus on the actual implementation instead
23
+ of rewriting boilerplate documentation.
24
+
25
+ The same applies to event systems. For example, in a button or other behavior
26
+ class, events often follow predictable naming and implementation patterns. With
27
+ DocLang, you can create a command that scan a class for events, locate
28
+ their implementations, extract the docstring descriptions and automatically
29
+ generate an event list at the top of the page. This means you can add or remove
30
+ events without worrying about manually updating the documentation — DocLang
31
+ handles it for you.
32
+
33
+ DocLang is designed to be extended. Users are encouraged to define their own
34
+ commands based on the needs of their project, creating a documentation workflow
35
+ that is both expressive and maintainable.
36
+
37
+ ---
38
+
39
+ ## Features
40
+
41
+ - **New commands**: Creating custom commands.
42
+ - **Overwrite commands**: Override existing commands with your own implementations.
43
+ - **Default commands**: Simple built‑in commands for generating *delimiters*, *titles*, *sections*, and *lists*.
44
+ - **Self‑introspection commands**: Retrieve the object's *name*, *type*, *documentation*, and *signature*.
45
+ - Fully compatible with **Sphinx autodoc**
46
+ - Zero configuration required beyond enabling the extension
47
+
48
+ DocLang is designed to keep your docstrings readable while producing rich, structured documentation output.
49
+
50
+ ---
51
+
52
+ ## Requirements
53
+
54
+ - **Python** • ***3.12+***
55
+ - **Sphinx** • ***9.1.0+***
56
+
57
+ ---
58
+
59
+ ## Installation
60
+
61
+ ```bash
62
+ pip install sphinx-doclang
63
+ ```
64
+
65
+ ---
66
+
67
+ ## Usage
68
+
69
+ ### Enable the extension
70
+ In your `conf.py`, add the extension to the `extensions` list.
71
+ Below is an example of a typical Sphinx configuration:
72
+
73
+ ```python
74
+ extensions = [
75
+ "sphinx.ext.autodoc", # pull in docstrings from code
76
+ "sphinx.ext.autosummary", # generate summary/API pages
77
+ "sphinx.ext.napoleon", # support Google/NumPy-style docstrings
78
+ "sphinx.ext.intersphinx", # link to external docs (Kivy, Python, etc.)
79
+ "sphinx.ext.todo", # support for exposing todo notes
80
+
81
+ "sphinx_localtoc", # stylizing the local ToC
82
+ "sphinx_doclang" # DSL for documentation language
83
+ ]
84
+ ```
85
+
86
+ ### Example of usage
87
+
88
+ DocLang commands can be used directly inside docstrings:
89
+
90
+ ```python
91
+ class Example:
92
+ """
93
+ A simple example class.
94
+
95
+ § list : First item, Second item, Third item ¶
96
+
97
+ § section : debug purpose only, style = camel ¶
98
+
99
+ § debug object ¶
100
+ """
101
+ ```
102
+
103
+ DocLang commands always begin with ```§ command : arguments ¶```.
104
+ The DSL is intentionally minimal and easy to read inside source code.
105
+
106
+ ---
107
+
108
+ ### Configuration options
109
+
110
+ The extension provides the following configuration variables, shown here with their default values:
111
+
112
+ ```python
113
+ # Character that marks the beginning of a DocLang command.
114
+ doclang_command_start = "§"
115
+
116
+ # Character that marks the end of a DocLang command.
117
+ doclang_command_end = "¶"
118
+
119
+ # Character used to separate the command name from its arguments.
120
+ doclang_command_splitter = ":"
121
+
122
+ # Characters used to separate multiple arguments inside a command.
123
+ # Each character acts as a valid separator.
124
+ doclang_argument_separator = ",;"
125
+
126
+ # Character used to separate keywords from their assigned values.
127
+ doclang_keyword_separator = "="
128
+
129
+ # Character used to mark comments inside DocLang command blocks.
130
+ doclang_comment_marker = "#"
131
+
132
+ # Characters used to escape DocLang syntax when literal text is required.
133
+ # Each character acts as a valid escaper.
134
+ doclang_escape_marker = "/|"
135
+
136
+ # Whether unknown or unregistered commands should be preserved instead of removed.
137
+ doclang_keep_unknown = False
138
+ ```
@@ -0,0 +1,47 @@
1
+ [build-system]
2
+ requires = ["setuptools>=69", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "sphinx-doclang"
7
+ version = "26.7.8"
8
+ description = "Sphinx extension providing the custom DSL for generating structured documentation blocks."
9
+ readme = "README.md"
10
+ requires-python = ">=3.12"
11
+ license = { file = "LICENSE" }
12
+ authors = [{ name = "ASI" }]
13
+ keywords = [
14
+ "sphinx",
15
+ "extension",
16
+ "dsl",
17
+ "doclang",
18
+ "documentation",
19
+ "autodoc",
20
+ "command"
21
+ ]
22
+ classifiers = [
23
+ "Programming Language :: Python :: 3",
24
+ "Programming Language :: Python :: 3.12",
25
+ "License :: OSI Approved :: MIT License",
26
+ "Framework :: Sphinx",
27
+ "Framework :: Sphinx :: Extension",
28
+ "Intended Audience :: Developers",
29
+ "Topic :: Documentation",
30
+ "Topic :: Documentation :: Sphinx",
31
+ "Topic :: Software Development :: Documentation",
32
+ ]
33
+ dependencies = [
34
+ "Sphinx>=9.1.0",
35
+ ]
36
+
37
+ [project.urls]
38
+ Source = "https://github.com/kmcasi/sphinx-doclang"
39
+ Issues = "https://github.com/kmcasi/sphinx-doclang/issues"
40
+
41
+ [tool.setuptools]
42
+ package-dir = {"" = "src"}
43
+ license-files = []
44
+ include-package-data = true
45
+
46
+ [tool.setuptools.packages.find]
47
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,31 @@
1
+ #//|>-----------------------------------------------------------------------------------------------------------------<|
2
+ #//| Copyright (c) 15 Feb 2026. All rights are reserved by ASI
3
+ #//|>-----------------------------------------------------------------------------------------------------------------<|
4
+
5
+ #// IMPORT
6
+ # from importlib.resources import files
7
+ from sphinx.application import Sphinx
8
+ from sphinx.util.typing import ExtensionMetadata
9
+
10
+ from ._version import VERSION_STRING
11
+ from .processor import setup_processor, validate_command_configuration_values
12
+ from .manager import TemplateManager
13
+
14
+
15
+ #// RUN
16
+ def setup(app: Sphinx) -> ExtensionMetadata:
17
+ # root = files(__name__)
18
+ # app.config.html_static_path.append(str(root / "_static"))
19
+ # app.add_css_file("styles/localtoc.css")
20
+
21
+ setup_processor(app)
22
+
23
+ validate_command_configuration_values(app)
24
+
25
+ TemplateManager._init_app(app)
26
+
27
+ return {
28
+ "version": VERSION_STRING,
29
+ "parallel_read_safe": True,
30
+ "parallel_write_safe": False,
31
+ }
@@ -0,0 +1,32 @@
1
+ #//|>-----------------------------------------------------------------------------------------------------------------<|
2
+ #//| Copyright (c) 15 Feb 2026. All rights are reserved by ASI
3
+ #//|>-----------------------------------------------------------------------------------------------------------------<|
4
+ __all__ = (
5
+ "MAJOR", "MINOR", "MICRO", "REVISION",
6
+ "S_STABLE", "VERSION_STRING"
7
+ )
8
+
9
+ #//| Version variables
10
+ #//|>--------------------------------------------------------<|
11
+ MAJOR: int = 26
12
+ MINOR: int = 7
13
+ MICRO: int = 8
14
+ VERSION_STRING: str = f"{MAJOR}.{MINOR}.{MICRO}"
15
+
16
+
17
+ #//| Development | Revision
18
+ #//|>--------------------------------------------------------<|
19
+ REVISION: int = 0
20
+ S_STABLE: bool = True
21
+
22
+ # If is not a stable state, update `VERSION_STRING` to reflect that
23
+ if not S_STABLE:
24
+ VERSION_STRING = f"{VERSION_STRING}.dev{max(1, REVISION)}"
25
+ elif REVISION > 0:
26
+ VERSION_STRING = f"{VERSION_STRING}.rev{REVISION}"
27
+
28
+
29
+ #//| exec'd
30
+ #//|>--------------------------------------------------------<|
31
+ __version__: str = VERSION_STRING
32
+
@@ -0,0 +1,62 @@
1
+ #//|>-----------------------------------------------------------------------------------------------------------------<|
2
+ #//| Copyright (c) 18 Feb 2026. All rights are reserved by ASI
3
+ #//|>-----------------------------------------------------------------------------------------------------------------<|
4
+ __all__ = ("DocLangError","InvalidCommandError","InvalidConfigError")
5
+
6
+
7
+ #// LOGIC
8
+ class DocLangError(Exception):
9
+ """Base exception for all DocLang‑related errors."""
10
+
11
+ def __init__(self, message: str, *args) -> None:
12
+ super().__init__(f"[DocLang Error] {message}", *args)
13
+
14
+ def note(self, title: str, message: str|list[str], indent: int = 0) -> None:
15
+ """
16
+ Attach a formatted note to the current error.
17
+
18
+ Notes provide additional context, suggestions or multi‑line guidance
19
+ that appears alongside the main error message in Sphinx output.
20
+
21
+ :param title: A short label describing the purpose of the note.
22
+ :param message: Either a single string or a list of strings.
23
+ :param indent: Number of spaces to indent multi‑line messages.
24
+
25
+ :return: Nothing.
26
+ """
27
+ # Local variables
28
+ formatted: str = ""
29
+
30
+ # Single-line message
31
+ if isinstance(message, str):
32
+ formatted = message
33
+
34
+ else:
35
+ # One-line list ➜ treat as a normal string
36
+ if len(message) == 1:
37
+ formatted = message[0]
38
+
39
+ # Multi-line list ➜ format with indentation
40
+ else:
41
+ prefix: str = f"\n\t{' ' * (len(title) + 3 + indent)}"
42
+
43
+ for message_index in range(len(message)):
44
+ formatted = f"{formatted}{prefix if message_index else ''}{message[message_index]}"
45
+
46
+ # Only add the note if the message contains meaningful content
47
+ if formatted.strip():
48
+ self.add_note(f"\t[{title}] {formatted}")
49
+
50
+
51
+ class InvalidCommandError(DocLangError):
52
+ """Raised when a DSL command is invalid or cannot be registered."""
53
+
54
+ def __init__(self, message: str) -> None:
55
+ super().__init__(message)
56
+
57
+
58
+ class InvalidConfigError(DocLangError):
59
+ """Raised when attempting to use a configuration value with an invalid signature."""
60
+
61
+ def __init__(self, message: str) -> None:
62
+ super().__init__(message)