sphinxnotes-render 1.0b1__tar.gz → 1.0b2__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.0b1 → sphinxnotes_render-1.0b2}/.cruft.json +2 -2
- sphinxnotes_render-1.0b2/.github/workflows/test.yml +25 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/Makefile +5 -1
- {sphinxnotes_render-1.0b1/src/sphinxnotes_render.egg-info → sphinxnotes_render-1.0b2}/PKG-INFO +1 -1
- sphinxnotes_render-1.0b2/docs/api.rst +67 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/docs/conf.py +3 -0
- sphinxnotes_render-1.0b2/docs/dsl.rst +239 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/docs/index.rst +2 -1
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes/render/ctx.py +3 -5
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes/render/data.py +42 -5
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2/src/sphinxnotes_render.egg-info}/PKG-INFO +1 -1
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes_render.egg-info/SOURCES.txt +2 -0
- sphinxnotes_render-1.0b2/tests/test_always_pass.py +9 -0
- sphinxnotes_render-1.0b1/.github/workflows/test.yml +0 -16
- sphinxnotes_render-1.0b1/docs/api.rst +0 -7
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/.github/workflows/lint.yml +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/.github/workflows/pages.yml +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/.github/workflows/pypi.yml +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/.github/workflows/release.yml +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/.gitignore +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/.pre-commit-config.yaml +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/LICENSE +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/MANIFEST.in +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/README.rst +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/docs/Makefile +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/docs/_images/.gitkeep +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/docs/_static/.gitkeep +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/docs/_static/custom.css +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/docs/_static/sphinx-notes.png +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/docs/changelog.rst +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/docs/make.bat +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/pyproject.toml +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/ruff.toml +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/setup.cfg +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes/render/__init__.py +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes/render/ctxnodes.py +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes/render/extractx.py +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes/render/markup.py +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes/render/meta.py +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes/render/pipeline.py +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes/render/py.typed +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes/render/render.py +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes/render/sources.py +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes/render/template.py +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes/render/utils/__init__.py +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes/render/utils/ctxproxy.py +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes/render/utils/freestyle.py +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes_render.egg-info/dependency_links.txt +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes_render.egg-info/requires.txt +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes_render.egg-info/top_level.txt +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/tests/__init__.py +0 -0
- {sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/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": "62cd96195962da3392cdc34125c95e9144a5f5ca",
|
|
4
4
|
"checkout": null,
|
|
5
5
|
"context": {
|
|
6
6
|
"cookiecutter": {
|
|
@@ -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": "62cd96195962da3392cdc34125c95e9144a5f5ca"
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"directory": null
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: Test
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
pull_request:
|
|
5
|
+
schedule:
|
|
6
|
+
- cron: '0 7 * * 6'
|
|
7
|
+
jobs:
|
|
8
|
+
test:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v2
|
|
12
|
+
- uses: actions/setup-python@v5
|
|
13
|
+
with:
|
|
14
|
+
python-version-file: 'pyproject.toml'
|
|
15
|
+
- run: python3 -m pip install .[test]
|
|
16
|
+
- run: make test
|
|
17
|
+
doctest:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v2
|
|
21
|
+
- uses: actions/setup-python@v5
|
|
22
|
+
with:
|
|
23
|
+
python-version-file: 'pyproject.toml'
|
|
24
|
+
- run: python3 -m pip install .[docs]
|
|
25
|
+
- run: make doctest
|
|
@@ -27,7 +27,11 @@ fmt:
|
|
|
27
27
|
|
|
28
28
|
.PHONY: test
|
|
29
29
|
test:
|
|
30
|
-
$(PY) -m
|
|
30
|
+
$(PY) -m pytest tests/ -v
|
|
31
|
+
|
|
32
|
+
.PHONY: doctest
|
|
33
|
+
doctest:
|
|
34
|
+
$(MAKE) doctest -C docs/
|
|
31
35
|
|
|
32
36
|
################################################################################
|
|
33
37
|
# Distribution Package
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
=============
|
|
2
|
+
API Reference
|
|
3
|
+
=============
|
|
4
|
+
|
|
5
|
+
Data Types
|
|
6
|
+
==========
|
|
7
|
+
|
|
8
|
+
.. autotype:: sphinxnotes.render.PlainValue
|
|
9
|
+
.. autotype:: sphinxnotes.render.Value
|
|
10
|
+
|
|
11
|
+
.. autoclass:: sphinxnotes.render.RawData
|
|
12
|
+
.. autoclass:: sphinxnotes.render.ParsedData
|
|
13
|
+
|
|
14
|
+
.. autoclass:: sphinxnotes.render.Field
|
|
15
|
+
.. autoclass:: sphinxnotes.render.Schema
|
|
16
|
+
|
|
17
|
+
.. autoclass:: sphinxnotes.render.data.Registry
|
|
18
|
+
|
|
19
|
+
.. automethod:: add_type
|
|
20
|
+
.. automethod:: add_form
|
|
21
|
+
.. automethod:: add_flag
|
|
22
|
+
.. automethod:: add_by_option
|
|
23
|
+
|
|
24
|
+
.. autotype:: sphinxnotes.render.data.ByOptionStore
|
|
25
|
+
|
|
26
|
+
The Render Pipeline
|
|
27
|
+
===================
|
|
28
|
+
|
|
29
|
+
Context
|
|
30
|
+
-------
|
|
31
|
+
|
|
32
|
+
.. autoclass:: sphinxnotes.render.PendingContext
|
|
33
|
+
.. autotype:: sphinxnotes.render.ResolvedContext
|
|
34
|
+
.. autoclass:: sphinxnotes.render.UnparsedData
|
|
35
|
+
|
|
36
|
+
.. autoclass:: sphinxnotes.render.pending_node
|
|
37
|
+
|
|
38
|
+
Extra Context
|
|
39
|
+
-------------
|
|
40
|
+
|
|
41
|
+
.. autoclass:: sphinxnotes.render.ExtraContextGenerator
|
|
42
|
+
.. autoclass:: sphinxnotes.render.ExtraContextRegistry
|
|
43
|
+
|
|
44
|
+
Template
|
|
45
|
+
--------
|
|
46
|
+
|
|
47
|
+
.. autoclass:: sphinxnotes.render.Template
|
|
48
|
+
.. autoclass:: sphinxnotes.render.Phase
|
|
49
|
+
|
|
50
|
+
Pipeline
|
|
51
|
+
--------
|
|
52
|
+
|
|
53
|
+
.. autoclass:: sphinxnotes.render.BaseContextRole
|
|
54
|
+
.. autoclass:: sphinxnotes.render.BaseContextDirective
|
|
55
|
+
.. autoclass:: sphinxnotes.render.BaseDataDefineRole
|
|
56
|
+
.. autoclass:: sphinxnotes.render.BaseDataDefineDirective
|
|
57
|
+
.. autoclass:: sphinxnotes.render.StrictDataDefineDirective
|
|
58
|
+
|
|
59
|
+
Registry
|
|
60
|
+
========
|
|
61
|
+
|
|
62
|
+
.. autodata:: sphinxnotes.render.REGISTRY
|
|
63
|
+
|
|
64
|
+
.. autoclass:: sphinxnotes.render.Registry
|
|
65
|
+
|
|
66
|
+
.. autoproperty:: data
|
|
67
|
+
.. autoproperty:: extra_context
|
|
@@ -23,6 +23,7 @@ version = release = '1.0a0'
|
|
|
23
23
|
# ones.
|
|
24
24
|
extensions = [
|
|
25
25
|
'sphinx.ext.githubpages',
|
|
26
|
+
'sphinx.ext.doctest',
|
|
26
27
|
'sphinx_design',
|
|
27
28
|
'sphinx_copybutton',
|
|
28
29
|
'sphinx_last_updated_by_git',
|
|
@@ -124,3 +125,5 @@ extensions.append('render')
|
|
|
124
125
|
|
|
125
126
|
_ = extensions.pop() # no need to load extension
|
|
126
127
|
primary_domain = 'py'
|
|
128
|
+
|
|
129
|
+
extensions.append('sphinx.ext.doctest')
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
=====================
|
|
2
|
+
Field Declaration DSL
|
|
3
|
+
=====================
|
|
4
|
+
|
|
5
|
+
.. default-domain:: py
|
|
6
|
+
.. highlight:: python
|
|
7
|
+
.. role:: py(code)
|
|
8
|
+
:language: Python
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
The Field Declaration DSL is a Domain Specific Language (DSL) that used to
|
|
12
|
+
define the type and structure of field values. A DSL declaration consists of
|
|
13
|
+
one or more :term:`modifier`\ s separated by commas (``,``).
|
|
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]
|
|
24
|
+
|
|
25
|
+
Syntax
|
|
26
|
+
======
|
|
27
|
+
|
|
28
|
+
.. productionlist::
|
|
29
|
+
dsl : modifier ("," modifier)*
|
|
30
|
+
modifier : type_modifier | form_modifier | flag | by_option
|
|
31
|
+
|
|
32
|
+
.. glossary::
|
|
33
|
+
|
|
34
|
+
Modifier
|
|
35
|
+
There are four categories of modifiers:
|
|
36
|
+
|
|
37
|
+
Type modifier
|
|
38
|
+
Specifies the element type (scalar value)
|
|
39
|
+
|
|
40
|
+
Form modifier
|
|
41
|
+
Specifies a container type with element type
|
|
42
|
+
|
|
43
|
+
Flag
|
|
44
|
+
A boolean flag (either on or off)
|
|
45
|
+
|
|
46
|
+
By-Option
|
|
47
|
+
A key-value option
|
|
48
|
+
|
|
49
|
+
Type
|
|
50
|
+
====
|
|
51
|
+
|
|
52
|
+
A type modifier specifies the data type of a single (scalar) value.
|
|
53
|
+
|
|
54
|
+
.. list-table::
|
|
55
|
+
:header-rows: 1
|
|
56
|
+
|
|
57
|
+
* - Modifier
|
|
58
|
+
- Type
|
|
59
|
+
- Aliases
|
|
60
|
+
- Description
|
|
61
|
+
* - ``bool``
|
|
62
|
+
- :py:class:`bool`
|
|
63
|
+
- ``flag``
|
|
64
|
+
- Boolean: ``true``/``yes``/``1``/``on``/``y`` → True, ``false``/``no``/``0``/``off``/``n`` → False
|
|
65
|
+
* - ``int``
|
|
66
|
+
- :py:class:`int`
|
|
67
|
+
- ``integer``
|
|
68
|
+
- Integer
|
|
69
|
+
* - ``float``
|
|
70
|
+
- :py:class:`float`
|
|
71
|
+
- ``number``, ``num``
|
|
72
|
+
- Floating-point number
|
|
73
|
+
* - ``str``
|
|
74
|
+
- :py:class:`str`
|
|
75
|
+
- ``string``
|
|
76
|
+
- String. If looks like a Python literal (e.g., ``"hello"``), it's parsed accordingly.
|
|
77
|
+
|
|
78
|
+
Examples:
|
|
79
|
+
|
|
80
|
+
======= ========= =============
|
|
81
|
+
DSL Input Result
|
|
82
|
+
------- --------- -------------
|
|
83
|
+
``int`` ``42`` :py:`42`
|
|
84
|
+
``str`` ``hello`` :py:`"hello"`
|
|
85
|
+
======= ========= =============
|
|
86
|
+
|
|
87
|
+
Form
|
|
88
|
+
====
|
|
89
|
+
|
|
90
|
+
A form modifier specifies a container type with its element type, using
|
|
91
|
+
``<form> of <type>`` syntax.
|
|
92
|
+
|
|
93
|
+
.. list-table::
|
|
94
|
+
:header-rows: 1
|
|
95
|
+
|
|
96
|
+
* - Modifier
|
|
97
|
+
- Container
|
|
98
|
+
- Separator
|
|
99
|
+
- Description
|
|
100
|
+
* - ``list of <type>``
|
|
101
|
+
- :py:class:`list`
|
|
102
|
+
- ``,``
|
|
103
|
+
- Comma-separated list
|
|
104
|
+
* - ``lines of <type>``
|
|
105
|
+
- :py:class:`list`
|
|
106
|
+
- ``\n``
|
|
107
|
+
- Newline-separated list
|
|
108
|
+
* - ``words of <type>``
|
|
109
|
+
- :py:class:`list`
|
|
110
|
+
- whitespace
|
|
111
|
+
- Whitespace-separated list
|
|
112
|
+
* - ``set of <type>``
|
|
113
|
+
- :py:class:`set`
|
|
114
|
+
- whitespace
|
|
115
|
+
- Whitespace-separated set (unique values)
|
|
116
|
+
|
|
117
|
+
Examples:
|
|
118
|
+
|
|
119
|
+
================ =========== =====================
|
|
120
|
+
DSL Input Result
|
|
121
|
+
---------------- ----------- ---------------------
|
|
122
|
+
``list of int`` ``1, 2, 3`` :py:`[1, 2, 3]`
|
|
123
|
+
``lines of str`` ``a\nb`` :py:`['a', 'b']`
|
|
124
|
+
``words of str`` ``a b c`` :py:`['a', 'b', 'c']`
|
|
125
|
+
================ =========== =====================
|
|
126
|
+
|
|
127
|
+
Flag
|
|
128
|
+
====
|
|
129
|
+
|
|
130
|
+
A flag is a boolean modifier that can be either on or off.
|
|
131
|
+
|
|
132
|
+
Every flag is available as a attribute of the :class:`Field`.
|
|
133
|
+
For example, we have a "required" flag registed, we can access ``Field.required``
|
|
134
|
+
attribute.
|
|
135
|
+
|
|
136
|
+
.. list-table::
|
|
137
|
+
:header-rows: 1
|
|
138
|
+
|
|
139
|
+
* - Modifier
|
|
140
|
+
- Aliases
|
|
141
|
+
- Default
|
|
142
|
+
- Description
|
|
143
|
+
* - ``required``
|
|
144
|
+
- ``require``, ``req``
|
|
145
|
+
- ``False``
|
|
146
|
+
- Field must have a value
|
|
147
|
+
|
|
148
|
+
Examples::
|
|
149
|
+
|
|
150
|
+
int, required
|
|
151
|
+
|
|
152
|
+
By-Option
|
|
153
|
+
=========
|
|
154
|
+
|
|
155
|
+
A by-option is a key-value modifier with the syntax ``<name> by <value>``.
|
|
156
|
+
|
|
157
|
+
Every by-option is available as a attribute of the :class:`Field`.
|
|
158
|
+
For example, we have a "sep" flag registed, we can get the value of separator
|
|
159
|
+
from ``Field.sep`` attribute.
|
|
160
|
+
|
|
161
|
+
Built-in by-options:
|
|
162
|
+
|
|
163
|
+
.. list-table::
|
|
164
|
+
:header-rows: 1
|
|
165
|
+
|
|
166
|
+
* - Modifier
|
|
167
|
+
- Type
|
|
168
|
+
- Description
|
|
169
|
+
* - ``sep by '<sep>'``
|
|
170
|
+
- :py:class:`str`
|
|
171
|
+
- Custom separator for value form. Implies ``list`` if no form specified.
|
|
172
|
+
|
|
173
|
+
Examples:
|
|
174
|
+
|
|
175
|
+
=================== ========= ================
|
|
176
|
+
DSL Input Result
|
|
177
|
+
------------------- --------- ----------------
|
|
178
|
+
``str, sep by '|'`` ``a|b`` :py:`['a', 'b']`
|
|
179
|
+
``int, sep by ':'`` ``1:2:3`` :py:`[1, 2, 3]`
|
|
180
|
+
=================== ========= ================
|
|
181
|
+
|
|
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']
|
|
@@ -43,7 +43,7 @@ Getting Started
|
|
|
43
43
|
.. ADDITIONAL CONTENT START
|
|
44
44
|
|
|
45
45
|
This extension is not intended to be used directly by Sphinx user.
|
|
46
|
-
It is for Sphinx extension developer, please refer to :doc:`api`.
|
|
46
|
+
It is for Sphinx extension developer, please refer to :doc:`dsl` and :doc:`api`.
|
|
47
47
|
|
|
48
48
|
.. ADDITIONAL CONTENT END
|
|
49
49
|
|
|
@@ -53,6 +53,7 @@ Contents
|
|
|
53
53
|
.. toctree::
|
|
54
54
|
:caption: Contents
|
|
55
55
|
|
|
56
|
+
dsl
|
|
56
57
|
api
|
|
57
58
|
changelog
|
|
58
59
|
|
|
@@ -8,17 +8,15 @@ sphinxnotes.render.ctx
|
|
|
8
8
|
This module wraps the :mod:`data` into context for rendering the template.
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
|
-
from
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
from typing import Any
|
|
12
13
|
from abc import ABC, abstractmethod
|
|
13
14
|
from collections.abc import Hashable
|
|
14
15
|
from dataclasses import dataclass
|
|
15
16
|
|
|
17
|
+
from .data import ParsedData
|
|
16
18
|
from .utils import Unpicklable
|
|
17
19
|
|
|
18
|
-
if TYPE_CHECKING:
|
|
19
|
-
from typing import Any
|
|
20
|
-
from .data import ParsedData
|
|
21
|
-
|
|
22
20
|
type ResolvedContext = ParsedData | dict[str, Any]
|
|
23
21
|
|
|
24
22
|
|
|
@@ -9,7 +9,7 @@ Context data type definitions.
|
|
|
9
9
|
"""
|
|
10
10
|
|
|
11
11
|
from __future__ import annotations
|
|
12
|
-
from typing import TYPE_CHECKING
|
|
12
|
+
from typing import TYPE_CHECKING, Literal
|
|
13
13
|
import re
|
|
14
14
|
from dataclasses import dataclass, asdict, field as dataclass_field
|
|
15
15
|
from ast import literal_eval
|
|
@@ -17,7 +17,7 @@ from ast import literal_eval
|
|
|
17
17
|
from .utils import Unpicklable
|
|
18
18
|
|
|
19
19
|
if TYPE_CHECKING:
|
|
20
|
-
from typing import Any, Callable, Generator, Self
|
|
20
|
+
from typing import Any, Callable, Generator, Self
|
|
21
21
|
|
|
22
22
|
# ===================================
|
|
23
23
|
# Basic types: Value, Form, Flag, ...
|
|
@@ -150,9 +150,6 @@ class Registry:
|
|
|
150
150
|
# later usage.
|
|
151
151
|
self._sep_by_option = self.byopts['sep']
|
|
152
152
|
|
|
153
|
-
# from pprint import pprint
|
|
154
|
-
# pprint(cls.__dict__)
|
|
155
|
-
|
|
156
153
|
def add_type(
|
|
157
154
|
self,
|
|
158
155
|
name: str,
|
|
@@ -161,6 +158,17 @@ class Registry:
|
|
|
161
158
|
strify: Callable[[PlainValue], str],
|
|
162
159
|
aliases: list[str] = [],
|
|
163
160
|
) -> None:
|
|
161
|
+
"""Register a value type for :class:`PlainValue`.
|
|
162
|
+
|
|
163
|
+
:param name: The name for this scalar type,
|
|
164
|
+
available as a :term:`Type modifier` in the DSL
|
|
165
|
+
:param etype: The Python type object
|
|
166
|
+
:param conv: A callable that converts a string to the *etype*
|
|
167
|
+
:param strify: A callable that converts the *etype* to a string
|
|
168
|
+
:param aliases: Alternative names for this type
|
|
169
|
+
|
|
170
|
+
.. seealso:: :ref:`add-custom-types`
|
|
171
|
+
"""
|
|
164
172
|
self.etypes[name] = etype
|
|
165
173
|
self.convs[etype] = conv
|
|
166
174
|
self.strifys[etype] = strify
|
|
@@ -171,6 +179,16 @@ class Registry:
|
|
|
171
179
|
def add_form(
|
|
172
180
|
self, name: str, ctype: type, sep: str, aliases: list[str] = []
|
|
173
181
|
) -> None:
|
|
182
|
+
"""Register an value form with its container type and separator for
|
|
183
|
+
:class:`Value`.
|
|
184
|
+
|
|
185
|
+
:param name: The name for this form, available as a :term:`Form modifier`
|
|
186
|
+
in the DSL
|
|
187
|
+
:param ctype: The container type.
|
|
188
|
+
(for now, it is :class:`list`, :class:`tuple`, or :class:`set`)
|
|
189
|
+
:param sep: The separator string used to split/join values
|
|
190
|
+
:param aliases: Alternative names for this form
|
|
191
|
+
"""
|
|
174
192
|
if ctype not in self.ctypes:
|
|
175
193
|
raise ValueError(f'Unsupported type: "{ctype}". Available: {self.ctypes}')
|
|
176
194
|
|
|
@@ -183,6 +201,14 @@ class Registry:
|
|
|
183
201
|
def add_flag(
|
|
184
202
|
self, name: str, default: bool = False, aliases: list[str] = []
|
|
185
203
|
) -> None:
|
|
204
|
+
"""Register a flag.
|
|
205
|
+
|
|
206
|
+
:param name: The name for this flag, available as a :term:`Flag` in the DSL
|
|
207
|
+
:param default: The default value for this flag
|
|
208
|
+
:param aliases: Alternative names for this flag
|
|
209
|
+
|
|
210
|
+
.. seealso:: :ref:`add-custom-flags`
|
|
211
|
+
"""
|
|
186
212
|
flag = Flag(name, default)
|
|
187
213
|
|
|
188
214
|
self.flags[flag.name] = flag
|
|
@@ -197,6 +223,17 @@ class Registry:
|
|
|
197
223
|
store: ByOptionStore = 'assign',
|
|
198
224
|
aliases: list[str] = [],
|
|
199
225
|
) -> None:
|
|
226
|
+
"""Register a by-option.
|
|
227
|
+
|
|
228
|
+
:param name: The name for this option, available as a :ref:`By-Option`
|
|
229
|
+
in the DSL
|
|
230
|
+
:param etype: The value type for this option
|
|
231
|
+
:param default: The default value for this option
|
|
232
|
+
:param store: How to store multiple values
|
|
233
|
+
:param aliases: Alternative names for this option
|
|
234
|
+
|
|
235
|
+
.. seealso:: :ref:`add-custom-by-options`
|
|
236
|
+
"""
|
|
200
237
|
opt = ByOption(name, etype, default, store)
|
|
201
238
|
|
|
202
239
|
self.byopts[opt.name] = opt
|
{sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes_render.egg-info/SOURCES.txt
RENAMED
|
@@ -16,6 +16,7 @@ docs/Makefile
|
|
|
16
16
|
docs/api.rst
|
|
17
17
|
docs/changelog.rst
|
|
18
18
|
docs/conf.py
|
|
19
|
+
docs/dsl.rst
|
|
19
20
|
docs/index.rst
|
|
20
21
|
docs/make.bat
|
|
21
22
|
docs/_images/.gitkeep
|
|
@@ -43,4 +44,5 @@ src/sphinxnotes_render.egg-info/dependency_links.txt
|
|
|
43
44
|
src/sphinxnotes_render.egg-info/requires.txt
|
|
44
45
|
src/sphinxnotes_render.egg-info/top_level.txt
|
|
45
46
|
tests/__init__.py
|
|
47
|
+
tests/test_always_pass.py
|
|
46
48
|
tests/test_data.py
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
name: Test
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
pull_request:
|
|
5
|
-
schedule:
|
|
6
|
-
- cron: '0 7 * * 6'
|
|
7
|
-
jobs:
|
|
8
|
-
test:
|
|
9
|
-
runs-on: ubuntu-latest
|
|
10
|
-
steps:
|
|
11
|
-
- uses: actions/checkout@v2
|
|
12
|
-
- uses: actions/setup-python@v5
|
|
13
|
-
with:
|
|
14
|
-
python-version-file: 'pyproject.toml'
|
|
15
|
-
- run: python3 -m pip install .[dev]
|
|
16
|
-
- run: make test
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes/render/utils/__init__.py
RENAMED
|
File without changes
|
{sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes/render/utils/ctxproxy.py
RENAMED
|
File without changes
|
{sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes/render/utils/freestyle.py
RENAMED
|
File without changes
|
|
File without changes
|
{sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes_render.egg-info/requires.txt
RENAMED
|
File without changes
|
{sphinxnotes_render-1.0b1 → sphinxnotes_render-1.0b2}/src/sphinxnotes_render.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|