sphinxnotes.render 1.0a42__py3-none-any.whl
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/__init__.py +93 -0
- sphinxnotes/render/ctx.py +76 -0
- sphinxnotes/render/ctxnodes.py +254 -0
- sphinxnotes/render/data.py +546 -0
- sphinxnotes/render/extractx.py +184 -0
- sphinxnotes/render/markup.py +122 -0
- sphinxnotes/render/meta.py +35 -0
- sphinxnotes/render/pipeline.py +300 -0
- sphinxnotes/render/py.typed +0 -0
- sphinxnotes/render/render.py +60 -0
- sphinxnotes/render/sources.py +129 -0
- sphinxnotes/render/template.py +146 -0
- sphinxnotes/render/utils/__init__.py +211 -0
- sphinxnotes/render/utils/ctxproxy.py +144 -0
- sphinxnotes/render/utils/freestyle.py +93 -0
- sphinxnotes_render-1.0a42.dist-info/METADATA +78 -0
- sphinxnotes_render-1.0a42.dist-info/RECORD +20 -0
- sphinxnotes_render-1.0a42.dist-info/WHEEL +5 -0
- sphinxnotes_render-1.0a42.dist-info/licenses/LICENSE +29 -0
- sphinxnotes_render-1.0a42.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from typing import Callable, Any
|
|
3
|
+
|
|
4
|
+
from docutils import nodes
|
|
5
|
+
from docutils.utils import assemble_option_dict
|
|
6
|
+
from docutils.parsers.rst import directives
|
|
7
|
+
from docutils.parsers.rst.states import Body
|
|
8
|
+
|
|
9
|
+
from sphinx.util import logging
|
|
10
|
+
from sphinx.util.docutils import SphinxDirective
|
|
11
|
+
|
|
12
|
+
from ..utils import parse_text_to_nodes
|
|
13
|
+
|
|
14
|
+
logger = logging.getLogger(__name__)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class FreeStyleOptionSpec(dict):
|
|
18
|
+
"""
|
|
19
|
+
An option_spec that accepts any key and always return the same conversion
|
|
20
|
+
function.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
def __init__(self, conv: Callable[[str], Any] = directives.unchanged):
|
|
24
|
+
self.conv = conv
|
|
25
|
+
|
|
26
|
+
def __getitem__(self, _):
|
|
27
|
+
return self.conv
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class FreeStyleDirective(SphinxDirective):
|
|
31
|
+
"""
|
|
32
|
+
TODO: https://docutils.sourceforge.io/docs/ref/rst/directives.html#role
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
final_argument_whitespace = True
|
|
36
|
+
option_spec = FreeStyleOptionSpec()
|
|
37
|
+
|
|
38
|
+
_arguments: list[str]
|
|
39
|
+
_options: dict[str, str]
|
|
40
|
+
|
|
41
|
+
@property
|
|
42
|
+
def arguments(self) -> list[str]:
|
|
43
|
+
return self._arguments
|
|
44
|
+
|
|
45
|
+
@arguments.setter
|
|
46
|
+
def arguments(self, value: list[str]) -> None: # type: ignore
|
|
47
|
+
if len(value) == 0:
|
|
48
|
+
self._arguments, self._options = [], {}
|
|
49
|
+
return
|
|
50
|
+
|
|
51
|
+
last_arg_and_opts = value.pop()
|
|
52
|
+
self._arguments = value
|
|
53
|
+
last_arg, self._options = self._parse_options(last_arg_and_opts)
|
|
54
|
+
self._arguments.append(last_arg)
|
|
55
|
+
|
|
56
|
+
@property
|
|
57
|
+
def options(self) -> dict[str, str]:
|
|
58
|
+
return self._options
|
|
59
|
+
|
|
60
|
+
@options.setter
|
|
61
|
+
def options(self, _: dict[str, str]) -> None: ... # type: ignore
|
|
62
|
+
|
|
63
|
+
def _parse_options(self, args_and_opts: str) -> tuple[str, dict[str, str]]:
|
|
64
|
+
"""Returns (last argument, parsed options)."""
|
|
65
|
+
arg_block = args_and_opts.split('\n')
|
|
66
|
+
opt_block = None
|
|
67
|
+
|
|
68
|
+
# Extract options from arguments.
|
|
69
|
+
# See also :meth:`docutils.parsers.rst.Body::parse_directive_options`.
|
|
70
|
+
for i, line in enumerate(arg_block):
|
|
71
|
+
if re.match(Body.patterns['field_marker'], line):
|
|
72
|
+
opt_block = arg_block[i:]
|
|
73
|
+
arg_block = arg_block[:i]
|
|
74
|
+
break
|
|
75
|
+
|
|
76
|
+
# Parse options raw text to dict[str, str].
|
|
77
|
+
options = {}
|
|
78
|
+
if opt_block:
|
|
79
|
+
option_list = self._parse_field_list('\n'.join(opt_block))
|
|
80
|
+
options = assemble_option_dict(option_list, self.option_spec)
|
|
81
|
+
|
|
82
|
+
return '\n'.join(arg_block), options
|
|
83
|
+
|
|
84
|
+
@staticmethod
|
|
85
|
+
def _parse_field_list(text: str) -> list[tuple[str, str]]:
|
|
86
|
+
field_lists = []
|
|
87
|
+
for node in parse_text_to_nodes(text):
|
|
88
|
+
for field_list in node.findall(nodes.field_list):
|
|
89
|
+
for field in field_list:
|
|
90
|
+
name = field.children[0].astext()
|
|
91
|
+
value = field.children[1].astext()
|
|
92
|
+
field_lists.append((name, value))
|
|
93
|
+
return field_lists
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sphinxnotes.render
|
|
3
|
+
Version: 1.0a42
|
|
4
|
+
Summary: A framework to define, constrain, and render data in Sphinx documentation
|
|
5
|
+
Author: Shengyu Zhang
|
|
6
|
+
Maintainer: Shengyu Zhang
|
|
7
|
+
License-Expression: BSD-3-Clause
|
|
8
|
+
Project-URL: homepage, https://sphinx.silverrainz.me/render
|
|
9
|
+
Project-URL: documentation, https://sphinx.silverrainz.me/render
|
|
10
|
+
Project-URL: repository, https://github.com/sphinx-notes/data
|
|
11
|
+
Project-URL: changelog, https://sphinx.silverrainz.me/render/changelog.html
|
|
12
|
+
Project-URL: tracker, https://github.com/sphinx-notes/data/issues
|
|
13
|
+
Keywords: sphinx,extension,documentation,sphinxnotes
|
|
14
|
+
Classifier: Development Status :: 3 - Alpha
|
|
15
|
+
Classifier: Environment :: Plugins
|
|
16
|
+
Classifier: Framework :: Sphinx
|
|
17
|
+
Classifier: Framework :: Sphinx :: Extension
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python
|
|
20
|
+
Classifier: Programming Language :: Python :: 3
|
|
21
|
+
Classifier: Topic :: Documentation
|
|
22
|
+
Classifier: Topic :: Documentation :: Sphinx
|
|
23
|
+
Requires-Python: >=3.12
|
|
24
|
+
Description-Content-Type: text/x-rst
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: Sphinx>=7.0
|
|
27
|
+
Provides-Extra: dev
|
|
28
|
+
Requires-Dist: build; extra == "dev"
|
|
29
|
+
Requires-Dist: twine; extra == "dev"
|
|
30
|
+
Requires-Dist: cruft; extra == "dev"
|
|
31
|
+
Requires-Dist: ruff>=0.11.10; extra == "dev"
|
|
32
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
33
|
+
Provides-Extra: test
|
|
34
|
+
Requires-Dist: pytest; extra == "test"
|
|
35
|
+
Provides-Extra: docs
|
|
36
|
+
Requires-Dist: furo; extra == "docs"
|
|
37
|
+
Requires-Dist: sphinx_design; extra == "docs"
|
|
38
|
+
Requires-Dist: sphinx_copybutton; extra == "docs"
|
|
39
|
+
Requires-Dist: sphinxcontrib-gtagjs; extra == "docs"
|
|
40
|
+
Requires-Dist: sphinx-sitemap; extra == "docs"
|
|
41
|
+
Requires-Dist: sphinxext-opengraph; extra == "docs"
|
|
42
|
+
Requires-Dist: sphinx-last-updated-by-git; extra == "docs"
|
|
43
|
+
Requires-Dist: sphinxnotes-project; extra == "docs"
|
|
44
|
+
Requires-Dist: sphinxnotes-comboroles; extra == "docs"
|
|
45
|
+
Dynamic: license-file
|
|
46
|
+
|
|
47
|
+
.. This file is generated from sphinx-notes/cookiecutter.
|
|
48
|
+
You need to consider modifying the TEMPLATE or modifying THIS FILE.
|
|
49
|
+
|
|
50
|
+
==================
|
|
51
|
+
sphinxnotes.render
|
|
52
|
+
==================
|
|
53
|
+
|
|
54
|
+
.. |docs| image:: https://img.shields.io/github/deployments/sphinx-notes/render/github-pages
|
|
55
|
+
:target: https://sphinx.silverrainz.me/render
|
|
56
|
+
:alt: Documentation Status
|
|
57
|
+
.. |license| image:: https://img.shields.io/github/license/sphinx-notes/render
|
|
58
|
+
:target: https://github.com/sphinx-notes/data/blob/master/LICENSE
|
|
59
|
+
:alt: Open Source License
|
|
60
|
+
.. |pypi| image:: https://img.shields.io/pypi/v/sphinxnotes.render.svg
|
|
61
|
+
:target: https://pypi.python.org/pypi/sphinxnotes.render
|
|
62
|
+
:alt: PyPI Package
|
|
63
|
+
.. |download| image:: https://img.shields.io/pypi/dm/sphinxnotes.render
|
|
64
|
+
:target: https://pypistats.org/packages/sphinxnotes.render
|
|
65
|
+
:alt: PyPI Package Downloads
|
|
66
|
+
|
|
67
|
+
|docs| |license| |pypi| |download|
|
|
68
|
+
|
|
69
|
+
A framework to define, constrain, and render data in Sphinx documentation.
|
|
70
|
+
|
|
71
|
+
.. INTRODUCTION START
|
|
72
|
+
(MUST written in standard reStructuredText, without Sphinx stuff)
|
|
73
|
+
|
|
74
|
+
.. INTRODUCTION END
|
|
75
|
+
|
|
76
|
+
Please refer to Documentation_ for more details.
|
|
77
|
+
|
|
78
|
+
.. _Documentation: https://sphinx.silverrainz.me/render
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
sphinxnotes/render/__init__.py,sha256=7jEnIimijWH1PXHl1jOOEYvHK23k8FQq4mQzQyuihx8,1808
|
|
2
|
+
sphinxnotes/render/ctx.py,sha256=M86AeXz07ywOWQ5Rf4exCl9xZ56pe7DcdY6UKCVAtwI,2096
|
|
3
|
+
sphinxnotes/render/ctxnodes.py,sha256=1k1rx3B8d2h_muXoiVm0IAf_GMMhluxUC28II5MSpao,8713
|
|
4
|
+
sphinxnotes/render/data.py,sha256=cun57jHVdyDLQHHBeUiTPYTG2RNxwbNgVlUyLCQzlJM,16363
|
|
5
|
+
sphinxnotes/render/extractx.py,sha256=1pamKe0mkgIxIXtIHMlLN8vvQuiX5-4lTWtjnHIFs1o,5509
|
|
6
|
+
sphinxnotes/render/markup.py,sha256=Rpdx1uIBg9haWW8iWJRJPlZKX2WGhkjB9s3_Ino3fIE,4318
|
|
7
|
+
sphinxnotes/render/meta.py,sha256=_NhgwS4FtVHuk5QnVYZrZ3xZHI_svV35bVlzXO8rNmo,996
|
|
8
|
+
sphinxnotes/render/pipeline.py,sha256=zwRx28EPH-oOgcttxng_GZEAV2xIfxwZe8wVz_6nTJs,8928
|
|
9
|
+
sphinxnotes/render/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
sphinxnotes/render/render.py,sha256=AJWwpvrunCgbfNid0euxfF1AkPV5owlvt0cX93LkfEI,1638
|
|
11
|
+
sphinxnotes/render/sources.py,sha256=WVgySvyIDVIRfweT94vuxapcUgFnsbTmjU0JbtZktR0,3530
|
|
12
|
+
sphinxnotes/render/template.py,sha256=Es4qYDvkqIDW-3E8Y_n5YAAhETf0qZy25Rt4ShBgP6E,4247
|
|
13
|
+
sphinxnotes/render/utils/__init__.py,sha256=cqNoc9loXOEWgB09xN9zflHMO2ALNz2IKPCBQ6zbUes,6750
|
|
14
|
+
sphinxnotes/render/utils/ctxproxy.py,sha256=-dD7IFliyPwXD_50oBAYlbwXmmdkUBiNeHNZbJKzMP0,3589
|
|
15
|
+
sphinxnotes/render/utils/freestyle.py,sha256=aLgfeUnRNxu-GoE2nPpf9GbpO2TXCYz7qsYJev1ud9M,2852
|
|
16
|
+
sphinxnotes_render-1.0a42.dist-info/licenses/LICENSE,sha256=Sa0uIqyOtooTO3N9W29mvi1uHW1uL0lmU7oRYumv8sA,1520
|
|
17
|
+
sphinxnotes_render-1.0a42.dist-info/METADATA,sha256=FXP0Iq0vXtEYJTJR1_mmat83lyBEvSR8Em3CnsYChw4,3055
|
|
18
|
+
sphinxnotes_render-1.0a42.dist-info/WHEEL,sha256=YCfwYGOYMi5Jhw2fU4yNgwErybb2IX5PEwBKV4ZbdBo,91
|
|
19
|
+
sphinxnotes_render-1.0a42.dist-info/top_level.txt,sha256=V-VWtuPpvntuonwz7_KceUnT4-CbPR1gJ26BTFpvcJI,12
|
|
20
|
+
sphinxnotes_render-1.0a42.dist-info/RECORD,,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025, Shengyu Zhang
|
|
4
|
+
All rights reserved.
|
|
5
|
+
|
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
|
7
|
+
modification, are permitted provided that the following conditions are met:
|
|
8
|
+
|
|
9
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
10
|
+
list of conditions and the following disclaimer.
|
|
11
|
+
|
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
13
|
+
this list of conditions and the following disclaimer in the documentation
|
|
14
|
+
and/or other materials provided with the distribution.
|
|
15
|
+
|
|
16
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
17
|
+
contributors may be used to endorse or promote products derived from
|
|
18
|
+
this software without specific prior written permission.
|
|
19
|
+
|
|
20
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
21
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
22
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
23
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
24
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
25
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
26
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
27
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
28
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
29
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
sphinxnotes
|