sphinxnotes-render 1.0b2__tar.gz → 1.0b4__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.
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/.cruft.json +3 -3
- {sphinxnotes_render-1.0b2/src/sphinxnotes_render.egg-info → sphinxnotes_render-1.0b4}/PKG-INFO +10 -5
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/README.rst +1 -1
- sphinxnotes_render-1.0b4/docs/api.rst +158 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/docs/conf.py +43 -5
- sphinxnotes_render-1.0b4/docs/conf.rst +31 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/docs/dsl.rst +30 -87
- sphinxnotes_render-1.0b4/docs/ext.rst +252 -0
- sphinxnotes_render-1.0b4/docs/index.rst +181 -0
- sphinxnotes_render-1.0b4/docs/tmpl.rst +425 -0
- sphinxnotes_render-1.0b4/docs/usage.rst +165 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/pyproject.toml +9 -3
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/src/sphinxnotes/render/__init__.py +20 -17
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/src/sphinxnotes/render/ctx.py +14 -19
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/src/sphinxnotes/render/ctxnodes.py +13 -6
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/src/sphinxnotes/render/data.py +11 -11
- sphinxnotes_render-1.0b4/src/sphinxnotes/render/ext/__init__.py +32 -0
- sphinxnotes_render-1.0b4/src/sphinxnotes/render/ext/adhoc.py +220 -0
- sphinxnotes_render-1.0b4/src/sphinxnotes/render/ext/derive.py +74 -0
- sphinxnotes_render-1.0b4/src/sphinxnotes/render/ext/extractx.py +81 -0
- sphinxnotes_render-1.0b4/src/sphinxnotes/render/ext/filters.py +53 -0
- sphinxnotes_render-1.0b4/src/sphinxnotes/render/extractx.py +208 -0
- sphinxnotes_render-1.0b2/src/sphinxnotes/render/template.py → sphinxnotes_render-1.0b4/src/sphinxnotes/render/jinja.py +43 -47
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/src/sphinxnotes/render/markup.py +1 -1
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/src/sphinxnotes/render/meta.py +1 -1
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/src/sphinxnotes/render/pipeline.py +79 -87
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/src/sphinxnotes/render/sources.py +47 -8
- sphinxnotes_render-1.0b4/src/sphinxnotes/render/template.py +66 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/src/sphinxnotes/render/utils/__init__.py +3 -3
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/src/sphinxnotes/render/utils/ctxproxy.py +4 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/src/sphinxnotes/render/utils/freestyle.py +4 -1
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4/src/sphinxnotes_render.egg-info}/PKG-INFO +10 -5
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/src/sphinxnotes_render.egg-info/SOURCES.txt +30 -2
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/src/sphinxnotes_render.egg-info/requires.txt +6 -0
- sphinxnotes_render-1.0b4/tests/conftest.py +9 -0
- sphinxnotes_render-1.0b4/tests/roots/test-base-context-directive-example/conf.py +23 -0
- sphinxnotes_render-1.0b4/tests/roots/test-base-context-directive-example/index.rst +4 -0
- sphinxnotes_render-1.0b4/tests/roots/test-base-data-define-directive-example/conf.py +42 -0
- sphinxnotes_render-1.0b4/tests/roots/test-base-data-define-directive-example/index.rst +14 -0
- sphinxnotes_render-1.0b4/tests/roots/test-data-define/conf.py +1 -0
- sphinxnotes_render-1.0b4/tests/roots/test-data-define/index.rst +18 -0
- sphinxnotes_render-1.0b4/tests/roots/test-derive/conf.py +16 -0
- sphinxnotes_render-1.0b4/tests/roots/test-derive/index.rst +8 -0
- sphinxnotes_render-1.0b4/tests/roots/test-extra-context/cat.json +7 -0
- sphinxnotes_render-1.0b4/tests/roots/test-extra-context/conf.py +25 -0
- sphinxnotes_render-1.0b4/tests/roots/test-extra-context/index.rst +7 -0
- sphinxnotes_render-1.0b4/tests/roots/test-filter-example/conf.py +22 -0
- sphinxnotes_render-1.0b4/tests/roots/test-filter-example/index.rst +6 -0
- sphinxnotes_render-1.0b4/tests/roots/test-strict-data-define-directive-example/conf.py +31 -0
- sphinxnotes_render-1.0b4/tests/roots/test-strict-data-define-directive-example/index.rst +14 -0
- sphinxnotes_render-1.0b4/tests/roots/test-strictdir-card/conf.py +36 -0
- sphinxnotes_render-1.0b4/tests/roots/test-strictdir-card/index.rst +8 -0
- sphinxnotes_render-1.0b4/tests/test_e2e.py +98 -0
- sphinxnotes_render-1.0b2/docs/api.rst +0 -67
- sphinxnotes_render-1.0b2/docs/index.rst +0 -74
- sphinxnotes_render-1.0b2/src/sphinxnotes/render/extractx.py +0 -184
- sphinxnotes_render-1.0b2/src/sphinxnotes/render/render.py +0 -60
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/.github/workflows/lint.yml +0 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/.github/workflows/pages.yml +0 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/.github/workflows/pypi.yml +0 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/.github/workflows/release.yml +0 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/.github/workflows/test.yml +0 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/.gitignore +0 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/.pre-commit-config.yaml +0 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/LICENSE +0 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/MANIFEST.in +0 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/Makefile +0 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/docs/Makefile +0 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/docs/_images/.gitkeep +0 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/docs/_static/.gitkeep +0 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/docs/_static/custom.css +0 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/docs/_static/sphinx-notes.png +0 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/docs/changelog.rst +0 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/docs/make.bat +0 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/ruff.toml +0 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/setup.cfg +0 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/src/sphinxnotes/render/py.typed +0 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/src/sphinxnotes_render.egg-info/dependency_links.txt +0 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/src/sphinxnotes_render.egg-info/top_level.txt +0 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/tests/__init__.py +0 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/tests/test_always_pass.py +0 -0
- {sphinxnotes_render-1.0b2 → sphinxnotes_render-1.0b4}/tests/test_data.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"template": "https://github.com/sphinx-notes/cookiecutter",
|
|
3
|
-
"commit": "
|
|
3
|
+
"commit": "4c6b17aec1a4b8ddca95c4882c6bed2bc230d595",
|
|
4
4
|
"checkout": null,
|
|
5
5
|
"context": {
|
|
6
6
|
"cookiecutter": {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"name": "render",
|
|
9
9
|
"full_name": "sphinxnotes-render",
|
|
10
10
|
"author": "Shengyu Zhang",
|
|
11
|
-
"description": "
|
|
11
|
+
"description": "Define, constrain, and render data in Sphinx documentation",
|
|
12
12
|
"version": "1.0a0",
|
|
13
13
|
"github_owner": "sphinx-notes",
|
|
14
14
|
"github_repo": "data",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"sphinx_version": "7.0",
|
|
21
21
|
"development_status": "3 - Alpha",
|
|
22
22
|
"_template": "https://github.com/sphinx-notes/cookiecutter",
|
|
23
|
-
"_commit": "
|
|
23
|
+
"_commit": "4c6b17aec1a4b8ddca95c4882c6bed2bc230d595"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"directory": null
|
{sphinxnotes_render-1.0b2/src/sphinxnotes_render.egg-info → sphinxnotes_render-1.0b4}/PKG-INFO
RENAMED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sphinxnotes-render
|
|
3
|
-
Version: 1.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 1.0b4
|
|
4
|
+
Summary: Define, constrain, and render data in Sphinx documentation
|
|
5
5
|
Author: Shengyu Zhang
|
|
6
6
|
Maintainer: Shengyu Zhang
|
|
7
7
|
License-Expression: BSD-3-Clause
|
|
8
8
|
Project-URL: homepage, https://sphinx.silverrainz.me/render
|
|
9
9
|
Project-URL: documentation, https://sphinx.silverrainz.me/render
|
|
10
|
-
Project-URL: repository, https://github.com/sphinx-notes/
|
|
10
|
+
Project-URL: repository, https://github.com/sphinx-notes/render
|
|
11
11
|
Project-URL: changelog, https://sphinx.silverrainz.me/render/changelog.html
|
|
12
|
-
Project-URL: tracker, https://github.com/sphinx-notes/
|
|
12
|
+
Project-URL: tracker, https://github.com/sphinx-notes/render/issues
|
|
13
13
|
Keywords: sphinx,extension,documentation,sphinxnotes
|
|
14
14
|
Classifier: Development Status :: 3 - Alpha
|
|
15
15
|
Classifier: Environment :: Plugins
|
|
@@ -24,6 +24,7 @@ Requires-Python: >=3.12
|
|
|
24
24
|
Description-Content-Type: text/x-rst
|
|
25
25
|
License-File: LICENSE
|
|
26
26
|
Requires-Dist: Sphinx>=7.0
|
|
27
|
+
Requires-Dist: Jinja2
|
|
27
28
|
Provides-Extra: dev
|
|
28
29
|
Requires-Dist: build; extra == "dev"
|
|
29
30
|
Requires-Dist: twine; extra == "dev"
|
|
@@ -32,6 +33,7 @@ Requires-Dist: ruff>=0.11.10; extra == "dev"
|
|
|
32
33
|
Requires-Dist: pre-commit; extra == "dev"
|
|
33
34
|
Provides-Extra: test
|
|
34
35
|
Requires-Dist: pytest; extra == "test"
|
|
36
|
+
Requires-Dist: schema; extra == "test"
|
|
35
37
|
Provides-Extra: docs
|
|
36
38
|
Requires-Dist: furo; extra == "docs"
|
|
37
39
|
Requires-Dist: sphinx_design; extra == "docs"
|
|
@@ -42,6 +44,9 @@ Requires-Dist: sphinxext-opengraph; extra == "docs"
|
|
|
42
44
|
Requires-Dist: sphinx-last-updated-by-git; extra == "docs"
|
|
43
45
|
Requires-Dist: sphinxnotes-project; extra == "docs"
|
|
44
46
|
Requires-Dist: sphinxnotes-comboroles; extra == "docs"
|
|
47
|
+
Requires-Dist: schema; extra == "docs"
|
|
48
|
+
Provides-Extra: ext
|
|
49
|
+
Requires-Dist: schema; extra == "ext"
|
|
45
50
|
Dynamic: license-file
|
|
46
51
|
|
|
47
52
|
.. This file is generated from sphinx-notes/cookiecutter.
|
|
@@ -66,7 +71,7 @@ sphinxnotes-render
|
|
|
66
71
|
|
|
67
72
|
|docs| |license| |pypi| |download|
|
|
68
73
|
|
|
69
|
-
|
|
74
|
+
Define, constrain, and render data in Sphinx documentation.
|
|
70
75
|
|
|
71
76
|
.. INTRODUCTION START
|
|
72
77
|
(MUST written in standard reStructuredText, without Sphinx stuff)
|
|
@@ -20,7 +20,7 @@ sphinxnotes-render
|
|
|
20
20
|
|
|
21
21
|
|docs| |license| |pypi| |download|
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Define, constrain, and render data in Sphinx documentation.
|
|
24
24
|
|
|
25
25
|
.. INTRODUCTION START
|
|
26
26
|
(MUST written in standard reStructuredText, without Sphinx stuff)
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
==============
|
|
2
|
+
API References
|
|
3
|
+
==============
|
|
4
|
+
|
|
5
|
+
.. _api-directives:
|
|
6
|
+
.. _api-roles:
|
|
7
|
+
|
|
8
|
+
Roles and Directives
|
|
9
|
+
====================
|
|
10
|
+
|
|
11
|
+
.. seealso::
|
|
12
|
+
|
|
13
|
+
For a minimal end-to-end example of creating your own directive, start with
|
|
14
|
+
:ref:`ext-directives`.
|
|
15
|
+
|
|
16
|
+
Base Role Classes
|
|
17
|
+
-----------------
|
|
18
|
+
|
|
19
|
+
.. autoclass:: sphinxnotes.render.BaseContextRole
|
|
20
|
+
:show-inheritance:
|
|
21
|
+
:members: process_pending_node, queue_pending_node, queue_context, current_context, current_template
|
|
22
|
+
|
|
23
|
+
.. autoclass:: sphinxnotes.render.BaseDataDefineRole
|
|
24
|
+
:show-inheritance:
|
|
25
|
+
:members: process_pending_node, queue_pending_node, queue_context, current_schema, current_template
|
|
26
|
+
|
|
27
|
+
Base Directive Classes
|
|
28
|
+
----------------------
|
|
29
|
+
|
|
30
|
+
.. autoclass:: sphinxnotes.render.BaseContextDirective
|
|
31
|
+
:show-inheritance:
|
|
32
|
+
:members: process_pending_node, queue_pending_node, queue_context, current_raw_data, current_context, current_template
|
|
33
|
+
|
|
34
|
+
.. autoclass:: sphinxnotes.render.BaseDataDefineDirective
|
|
35
|
+
:show-inheritance:
|
|
36
|
+
:members: process_pending_node, queue_pending_node, queue_context, current_raw_data, current_schema, current_template
|
|
37
|
+
|
|
38
|
+
.. autoclass:: sphinxnotes.render.StrictDataDefineDirective
|
|
39
|
+
:show-inheritance:
|
|
40
|
+
:members: derive
|
|
41
|
+
|
|
42
|
+
Node
|
|
43
|
+
=====
|
|
44
|
+
|
|
45
|
+
.. autoclass:: sphinxnotes.render.pending_node
|
|
46
|
+
|
|
47
|
+
.. _api-context:
|
|
48
|
+
|
|
49
|
+
Context
|
|
50
|
+
=======
|
|
51
|
+
|
|
52
|
+
Context refers to the dynamic content of a Jinja template. It can be:
|
|
53
|
+
|
|
54
|
+
:py:class:`~sphinxnotes.render.ResolvedContext`:
|
|
55
|
+
Our dedicated data type (:py:class:`sphinxnotes.render.ParsedData`), or any
|
|
56
|
+
Python ``dict``.
|
|
57
|
+
|
|
58
|
+
:py:class:`~sphinxnotes.render.PendingContext`:
|
|
59
|
+
Context that is not yet available. For example, it may contain
|
|
60
|
+
:py:class:`unparsed data <sphinxnotes.render.RawData>`,
|
|
61
|
+
remote data, and more.
|
|
62
|
+
|
|
63
|
+
:py:class:`PendingContext` can be resolved to
|
|
64
|
+
:py:class:`~sphinxnotes.render.ResolvedContext` by calling
|
|
65
|
+
:py:meth:`~sphinxnotes.render.PendingContext.resolve`.
|
|
66
|
+
|
|
67
|
+
.. autotype:: sphinxnotes.render.ResolvedContext
|
|
68
|
+
|
|
69
|
+
.. autoclass:: sphinxnotes.render.PendingContext
|
|
70
|
+
:members: resolve
|
|
71
|
+
|
|
72
|
+
``PendingContext`` Implementations
|
|
73
|
+
----------------------------------
|
|
74
|
+
|
|
75
|
+
.. autoclass:: sphinxnotes.render.UnparsedData
|
|
76
|
+
:show-inheritance:
|
|
77
|
+
|
|
78
|
+
.. _extractx:
|
|
79
|
+
|
|
80
|
+
Template
|
|
81
|
+
========
|
|
82
|
+
|
|
83
|
+
See :doc:`tmpl` for the higher-level guide.
|
|
84
|
+
|
|
85
|
+
.. autoclass:: sphinxnotes.render.Template
|
|
86
|
+
:members:
|
|
87
|
+
|
|
88
|
+
.. autoclass:: sphinxnotes.render.Phase
|
|
89
|
+
:members:
|
|
90
|
+
|
|
91
|
+
Extra Context
|
|
92
|
+
=============
|
|
93
|
+
|
|
94
|
+
See :doc:`tmpl` for built-in extra-context names such as ``doc`` and
|
|
95
|
+
``sphinx``, plus usage examples.
|
|
96
|
+
|
|
97
|
+
.. autodecorator:: sphinxnotes.render.extra_context
|
|
98
|
+
|
|
99
|
+
.. autoclass:: sphinxnotes.render.ParsingPhaseExtraContext
|
|
100
|
+
:members: phase, generate
|
|
101
|
+
:undoc-members:
|
|
102
|
+
|
|
103
|
+
.. autoclass:: sphinxnotes.render.ParsedPhaseExtraContext
|
|
104
|
+
:members: phase, generate
|
|
105
|
+
:undoc-members:
|
|
106
|
+
|
|
107
|
+
.. autoclass:: sphinxnotes.render.ResolvingPhaseExtraContext
|
|
108
|
+
:members: phase, generate
|
|
109
|
+
:undoc-members:
|
|
110
|
+
|
|
111
|
+
.. autoclass:: sphinxnotes.render.GlobalExtraContext
|
|
112
|
+
:members: phase, generate
|
|
113
|
+
:undoc-members:
|
|
114
|
+
|
|
115
|
+
Filters
|
|
116
|
+
=======
|
|
117
|
+
|
|
118
|
+
.. autodecorator:: sphinxnotes.render.filter
|
|
119
|
+
|
|
120
|
+
Data, Field and Schema
|
|
121
|
+
======================
|
|
122
|
+
|
|
123
|
+
.. autotype:: sphinxnotes.render.PlainValue
|
|
124
|
+
|
|
125
|
+
.. autotype:: sphinxnotes.render.Value
|
|
126
|
+
|
|
127
|
+
.. autoclass:: sphinxnotes.render.RawData
|
|
128
|
+
:members: name, attrs, content
|
|
129
|
+
:undoc-members:
|
|
130
|
+
|
|
131
|
+
.. autoclass:: sphinxnotes.render.ParsedData
|
|
132
|
+
:members: name, attrs, content
|
|
133
|
+
:undoc-members:
|
|
134
|
+
|
|
135
|
+
.. autoclass:: sphinxnotes.render.Field
|
|
136
|
+
:members: parse
|
|
137
|
+
|
|
138
|
+
.. autoclass:: sphinxnotes.render.Schema
|
|
139
|
+
:members: name, attrs, content
|
|
140
|
+
:undoc-members:
|
|
141
|
+
|
|
142
|
+
.. autoclass:: sphinxnotes.render.data.Registry
|
|
143
|
+
:members:
|
|
144
|
+
|
|
145
|
+
.. autotype:: sphinxnotes.render.data.ByOptionStore
|
|
146
|
+
|
|
147
|
+
Registry
|
|
148
|
+
========
|
|
149
|
+
|
|
150
|
+
Developers can extend this extension (for example, to support more data types
|
|
151
|
+
or add new extra context) by adding new items to
|
|
152
|
+
:py:class:`sphinxnotes.render.REGISTRY`.
|
|
153
|
+
|
|
154
|
+
.. autodata:: sphinxnotes.render.REGISTRY
|
|
155
|
+
|
|
156
|
+
.. autoclass:: sphinxnotes.render.Registry
|
|
157
|
+
|
|
158
|
+
.. autoproperty:: data
|
|
@@ -24,6 +24,7 @@ version = release = '1.0a0'
|
|
|
24
24
|
extensions = [
|
|
25
25
|
'sphinx.ext.githubpages',
|
|
26
26
|
'sphinx.ext.doctest',
|
|
27
|
+
'sphinx.ext.viewcode',
|
|
27
28
|
'sphinx_design',
|
|
28
29
|
'sphinx_copybutton',
|
|
29
30
|
'sphinx_last_updated_by_git',
|
|
@@ -118,12 +119,49 @@ primary_domain = 'any'
|
|
|
118
119
|
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
|
119
120
|
import os
|
|
120
121
|
import sys
|
|
121
|
-
sys.path.insert(0, os.path.abspath('../src/
|
|
122
|
-
extensions.append('render')
|
|
122
|
+
sys.path.insert(0, os.path.abspath('../src/'))
|
|
123
|
+
extensions.append('sphinxnotes.render')
|
|
123
124
|
|
|
124
125
|
# CUSTOM CONFIGURATION
|
|
125
126
|
|
|
126
|
-
|
|
127
|
-
|
|
127
|
+
extensions.append('sphinxnotes.render.ext')
|
|
128
|
+
|
|
129
|
+
# [example config start]
|
|
130
|
+
render_ext_data_define_directives = {
|
|
131
|
+
'cat': {
|
|
132
|
+
'schema': {
|
|
133
|
+
'name': 'str, required',
|
|
134
|
+
'attrs': {
|
|
135
|
+
'color': 'str',
|
|
136
|
+
},
|
|
137
|
+
'content': 'str, required'
|
|
138
|
+
},
|
|
139
|
+
'template': {
|
|
140
|
+
'text': '\n'.join([
|
|
141
|
+
'Hi human! I am a cat named {{ name }}, I have {{ color }} fur.',
|
|
142
|
+
'',
|
|
143
|
+
'{{ content }}.',
|
|
144
|
+
]),
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
}
|
|
148
|
+
# [example config end]
|
|
149
|
+
|
|
150
|
+
autodoc_default_options = {
|
|
151
|
+
'member-order': 'bysource',
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
intersphinx_mapping['python'] = ('https://docs.python.org/3', None)
|
|
155
|
+
intersphinx_mapping['sphinx'] = ('https://www.sphinx-doc.org/en/master', None)
|
|
156
|
+
|
|
157
|
+
test_roots = os.path.abspath('../tests/roots')
|
|
158
|
+
|
|
159
|
+
def setup(app):
|
|
160
|
+
app.add_object_type('event', 'event') # for intersphinx
|
|
128
161
|
|
|
129
|
-
|
|
162
|
+
sys.path.insert(0, test_roots)
|
|
163
|
+
__import__('test-extra-context.conf').conf.setup(app)
|
|
164
|
+
__import__('test-base-context-directive-example.conf').conf.setup(app)
|
|
165
|
+
__import__('test-base-data-define-directive-example.conf').conf.setup(app)
|
|
166
|
+
__import__('test-strict-data-define-directive-example.conf').conf.setup(app)
|
|
167
|
+
__import__('test-filter-example.conf').conf.setup(app)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
=============
|
|
2
|
+
Configuration
|
|
3
|
+
=============
|
|
4
|
+
|
|
5
|
+
The extension provides the following configuration:
|
|
6
|
+
|
|
7
|
+
.. autoconfval:: render_ext_data_define_directives
|
|
8
|
+
|
|
9
|
+
A dictionary ``dict[str, directive_def]`` for creating custom directives for
|
|
10
|
+
data definition.
|
|
11
|
+
|
|
12
|
+
The ``str`` key is the name of the directive to be created;
|
|
13
|
+
The ``directive_def`` value is a ``dict`` with the following keys:
|
|
14
|
+
|
|
15
|
+
- ``schema`` (dict): Schema definition, works same as the
|
|
16
|
+
:rst:dir:`data.schema` directive, which has the following keys:
|
|
17
|
+
|
|
18
|
+
- ``name`` (str, optional): same as the directive argument
|
|
19
|
+
- ``attr`` (dict, can be empty): same as the directive options
|
|
20
|
+
- ``content`` (str, optional): same as the directive content
|
|
21
|
+
|
|
22
|
+
- ``template`` (dict): Template definition, works same as the
|
|
23
|
+
:rst:dir:`data.template` directive, which has the following keys:
|
|
24
|
+
|
|
25
|
+
- ``text`` (str): the Jinja2 template text.
|
|
26
|
+
- ``on`` (str, optional): same as :rst:dir:`data.template:on`
|
|
27
|
+
- ``debug`` (bool, optional): same as :rst:dir:`data.template:debug`
|
|
28
|
+
- ``extra`` (list[str], optional): same as :rst:dir:`data.template:extra`
|
|
29
|
+
|
|
30
|
+
See :ref:`usage-custom-directive` for example.
|
|
31
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Field
|
|
3
|
-
|
|
1
|
+
==========================
|
|
2
|
+
Field Description Language
|
|
3
|
+
==========================
|
|
4
4
|
|
|
5
5
|
.. default-domain:: py
|
|
6
6
|
.. highlight:: python
|
|
@@ -8,19 +8,9 @@ Field Declaration DSL
|
|
|
8
8
|
:language: Python
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
The Field
|
|
12
|
-
define the type and structure of field values.
|
|
13
|
-
one or more :term:`modifier
|
|
14
|
-
|
|
15
|
-
Python API
|
|
16
|
-
==========
|
|
17
|
-
|
|
18
|
-
User can create a :class:`sphinxnotes.render.Field` from DSL and use it to parse
|
|
19
|
-
string to :type:`sphinxnotes.render.Value`:
|
|
20
|
-
|
|
21
|
-
>>> from sphinxnotes.render import Field
|
|
22
|
-
>>> Field.from_dsl('list of int').parse('1,2,3')
|
|
23
|
-
[1, 2, 3]
|
|
11
|
+
The Field Description Language is a Domain Specific Language (DSL) that is used to
|
|
12
|
+
define the type and structure of field values. An FDL declaration consists of
|
|
13
|
+
one or more :term:`modifier` entries separated by commas (``,``).
|
|
24
14
|
|
|
25
15
|
Syntax
|
|
26
16
|
======
|
|
@@ -34,17 +24,28 @@ Syntax
|
|
|
34
24
|
Modifier
|
|
35
25
|
There are four categories of modifiers:
|
|
36
26
|
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
Type modifier
|
|
28
|
+
Specifies the element type (scalar value)
|
|
39
29
|
|
|
40
|
-
|
|
41
|
-
|
|
30
|
+
Form modifier
|
|
31
|
+
Specifies a container type with element type
|
|
42
32
|
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
Flag
|
|
34
|
+
A boolean flag (either on or off)
|
|
35
|
+
|
|
36
|
+
By-Option
|
|
37
|
+
A key-value option
|
|
38
|
+
|
|
39
|
+
Python API
|
|
40
|
+
==========
|
|
41
|
+
|
|
42
|
+
Users can create a :class:`sphinxnotes.render.Field` from FDL and use it to parse
|
|
43
|
+
strings into :type:`sphinxnotes.render.Value`:
|
|
44
|
+
|
|
45
|
+
>>> from sphinxnotes.render import Field
|
|
46
|
+
>>> Field.from_dsl('list of int').parse('1,2,3')
|
|
47
|
+
[1, 2, 3]
|
|
45
48
|
|
|
46
|
-
By-Option
|
|
47
|
-
A key-value option
|
|
48
49
|
|
|
49
50
|
Type
|
|
50
51
|
====
|
|
@@ -73,7 +74,7 @@ A type modifier specifies the data type of a single (scalar) value.
|
|
|
73
74
|
* - ``str``
|
|
74
75
|
- :py:class:`str`
|
|
75
76
|
- ``string``
|
|
76
|
-
- String. If looks like a Python literal (e.g., ``"hello"``), it
|
|
77
|
+
- String. If it looks like a Python literal (e.g., ``"hello"``), it is parsed accordingly.
|
|
77
78
|
|
|
78
79
|
Examples:
|
|
79
80
|
|
|
@@ -129,8 +130,8 @@ Flag
|
|
|
129
130
|
|
|
130
131
|
A flag is a boolean modifier that can be either on or off.
|
|
131
132
|
|
|
132
|
-
Every flag is available as
|
|
133
|
-
For example, we have a "required" flag
|
|
133
|
+
Every flag is available as an attribute of the :class:`Field`.
|
|
134
|
+
For example, we have a "required" flag registered, and we can access ``Field.required``
|
|
134
135
|
attribute.
|
|
135
136
|
|
|
136
137
|
.. list-table::
|
|
@@ -154,8 +155,8 @@ By-Option
|
|
|
154
155
|
|
|
155
156
|
A by-option is a key-value modifier with the syntax ``<name> by <value>``.
|
|
156
157
|
|
|
157
|
-
Every by-option is available as
|
|
158
|
-
For example, we have a "sep"
|
|
158
|
+
Every by-option is available as an attribute of the :class:`Field`.
|
|
159
|
+
For example, we have a "sep" by-option registered, and we can get the separator
|
|
159
160
|
from ``Field.sep`` attribute.
|
|
160
161
|
|
|
161
162
|
Built-in by-options:
|
|
@@ -179,61 +180,3 @@ DSL Input Result
|
|
|
179
180
|
``int, sep by ':'`` ``1:2:3`` :py:`[1, 2, 3]`
|
|
180
181
|
=================== ========= ================
|
|
181
182
|
|
|
182
|
-
Extending the DSL
|
|
183
|
-
=================
|
|
184
|
-
|
|
185
|
-
You can extend the DSL by registering custom types, flags, and by-options
|
|
186
|
-
through the :attr:`~sphinxnotes.render.Registry.data` attribute of
|
|
187
|
-
:data:`sphinxnotes.render.REGISTRY`.
|
|
188
|
-
|
|
189
|
-
.. _add-custom-types:
|
|
190
|
-
|
|
191
|
-
Adding Custom Types
|
|
192
|
-
-------------------
|
|
193
|
-
|
|
194
|
-
Use :meth:`~sphinxnotes.render.data.REGISTRY.add_type` method of
|
|
195
|
-
:data:`sphinxnotes.render.REGISTRY` to add a new type:
|
|
196
|
-
|
|
197
|
-
>>> from sphinxnotes.render import REGISTRY
|
|
198
|
-
>>>
|
|
199
|
-
>>> def parse_color(v: str):
|
|
200
|
-
... return tuple(int(x) for x in v.split(';'))
|
|
201
|
-
...
|
|
202
|
-
>>> def color_to_str(v):
|
|
203
|
-
... return ';'.join(str(x) for x in v)
|
|
204
|
-
...
|
|
205
|
-
>>> REGISTRY.data.add_type('color', tuple, parse_color, color_to_str)
|
|
206
|
-
>>> Field.from_dsl('color').parse('255;0;0')
|
|
207
|
-
(255, 0, 0)
|
|
208
|
-
|
|
209
|
-
.. _add-custom-flags:
|
|
210
|
-
|
|
211
|
-
Adding Custom Flags
|
|
212
|
-
-------------------
|
|
213
|
-
|
|
214
|
-
Use :meth:`~sphinxnotes.render.data.Registry.add_flag` method of
|
|
215
|
-
:data:`sphinxnotes.render.REGISTRY` to add a new type:
|
|
216
|
-
|
|
217
|
-
>>> from sphinxnotes.render import REGISTRY
|
|
218
|
-
>>> REGISTRY.data.add_flag('unique', default=False)
|
|
219
|
-
>>> field = Field.from_dsl('int, unique')
|
|
220
|
-
>>> field.unique
|
|
221
|
-
True
|
|
222
|
-
|
|
223
|
-
.. _add-custom-by-options:
|
|
224
|
-
|
|
225
|
-
Adding Custom By-Options
|
|
226
|
-
------------------------
|
|
227
|
-
|
|
228
|
-
Use :meth:`~sphinxnotes.render.data.Registry.add_by_option` method of
|
|
229
|
-
:data:`sphinxnotes.render.REGISTRY` to add a new by-option:
|
|
230
|
-
|
|
231
|
-
>>> from sphinxnotes.render import REGISTRY
|
|
232
|
-
>>> REGISTRY.data.add_by_option('group', str)
|
|
233
|
-
>>> field = Field.from_dsl('str, group by size')
|
|
234
|
-
>>> field.group
|
|
235
|
-
'size'
|
|
236
|
-
>>> REGISTRY.data.add_by_option('index', str, store='append')
|
|
237
|
-
>>> field = Field.from_dsl('str, index by month, index by year')
|
|
238
|
-
>>> field.index
|
|
239
|
-
['month', 'year']
|