sphinxnotes-project 1.0a44__tar.gz → 1.0a46__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.
Files changed (46) hide show
  1. {sphinxnotes_project-1.0a44/src/sphinxnotes_project.egg-info → sphinxnotes_project-1.0a46}/PKG-INFO +2 -1
  2. sphinxnotes_project-1.0a46/docs/conf.rst +12 -0
  3. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/docs/index.rst +1 -0
  4. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/docs/sphinxnotes_any.rst +4 -0
  5. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/pyproject.toml +1 -0
  6. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/src/sphinxnotes/project/__init__.py +1 -0
  7. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/src/sphinxnotes/project/sphinxnotes_any.py +22 -1
  8. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/src/sphinxnotes/project/sphinxnotes_render_ext.py +22 -0
  9. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/src/sphinxnotes/project/templates/autoconfval.rst +1 -8
  10. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/src/sphinxnotes/project/templates/example.rst +3 -2
  11. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46/src/sphinxnotes_project.egg-info}/PKG-INFO +2 -1
  12. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/src/sphinxnotes_project.egg-info/SOURCES.txt +1 -0
  13. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/src/sphinxnotes_project.egg-info/requires.txt +1 -0
  14. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/.cruft.json +0 -0
  15. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/.github/workflows/lint.yml +0 -0
  16. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/.github/workflows/pages.yml +0 -0
  17. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/.github/workflows/pypi.yml +0 -0
  18. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/.github/workflows/release.yml +0 -0
  19. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/.github/workflows/tag.yml +0 -0
  20. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/.github/workflows/test.yml +0 -0
  21. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/.gitignore +0 -0
  22. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/.pre-commit-config.yaml +0 -0
  23. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/LICENSE +0 -0
  24. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/MANIFEST.in +0 -0
  25. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/Makefile +0 -0
  26. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/README.rst +0 -0
  27. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/docs/Makefile +0 -0
  28. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/docs/_images/.gitkeep +0 -0
  29. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/docs/_static/.gitkeep +0 -0
  30. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/docs/_static/custom.css +0 -0
  31. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/docs/_static/sphinx-notes.png +0 -0
  32. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/docs/changelog.rst +0 -0
  33. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/docs/conf.py +0 -0
  34. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/docs/make.bat +0 -0
  35. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/ruff.toml +0 -0
  36. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/setup.cfg +0 -0
  37. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/src/sphinxnotes/project/meta.py +0 -0
  38. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/src/sphinxnotes/project/py.typed +0 -0
  39. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/src/sphinxnotes/project/templates/autoobj.rst +0 -0
  40. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/src/sphinxnotes/project/templates/internal-only.rst +0 -0
  41. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/src/sphinxnotes/project/templates/version.rst +0 -0
  42. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/src/sphinxnotes/project/utils/__init__.py +0 -0
  43. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/src/sphinxnotes_project.egg-info/dependency_links.txt +0 -0
  44. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/src/sphinxnotes_project.egg-info/top_level.txt +0 -0
  45. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/tests/__init__.py +0 -0
  46. {sphinxnotes_project-1.0a44 → sphinxnotes_project-1.0a46}/tests/test_always_pass.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sphinxnotes-project
3
- Version: 1.0a44
3
+ Version: 1.0a46
4
4
  Summary: A Sphinx extension that provides useful directives for creating project documentation
5
5
  Author: Shengyu Zhang
6
6
  Maintainer: Shengyu Zhang
@@ -25,6 +25,7 @@ Description-Content-Type: text/x-rst
25
25
  License-File: LICENSE
26
26
  Requires-Dist: Sphinx>=7.0
27
27
  Requires-Dist: sphinxnotes-any>=3.0b0
28
+ Requires-Dist: sphinx_design
28
29
  Provides-Extra: dev
29
30
  Requires-Dist: build; extra == "dev"
30
31
  Requires-Dist: twine; extra == "dev"
@@ -0,0 +1,12 @@
1
+ =============
2
+ Configuration
3
+ =============
4
+
5
+ The extension provides the following configuration:
6
+
7
+ .. autoconfval:: project_example_style
8
+
9
+ Controls the default value of the :rst:dir:`example` directive's
10
+ ``:style:`` option.
11
+
12
+ Supported values are ``grid`` and ``tab``. The default is ``grid``.
@@ -75,6 +75,7 @@ Contents
75
75
  .. toctree::
76
76
  :caption: Contents
77
77
 
78
+ conf
78
79
  sphinxnotes_any
79
80
  changelog
80
81
 
@@ -13,3 +13,7 @@ The ``example`` Object
13
13
  ======================
14
14
 
15
15
  .. autoobj:: any:example
16
+
17
+ The default value of the ``:style:`` option can be controlled by the
18
+ :confval:`project_example_style` config, which accepts ``grid`` and ``tab``
19
+ and defaults to ``grid``.
@@ -44,6 +44,7 @@ dependencies = [
44
44
 
45
45
  # CUSTOM DEPENDENCIES START
46
46
  "sphinxnotes-any >= 3.0b0",
47
+ "sphinx_design",
47
48
  # CUSTOM DEPENDENCIES END
48
49
  ]
49
50
 
@@ -21,6 +21,7 @@ def setup(app: Sphinx):
21
21
  meta.pre_setup(app)
22
22
 
23
23
  from . import sphinxnotes_any, sphinxnotes_render_ext
24
+
24
25
  sphinxnotes_any.setup(app)
25
26
  sphinxnotes_render_ext.setup(app)
26
27
 
@@ -14,6 +14,9 @@ from __future__ import annotations
14
14
  from typing import TYPE_CHECKING
15
15
  from os import path
16
16
 
17
+ from sphinx.config import ENUM
18
+ from sphinx.errors import ConfigError
19
+
17
20
  if TYPE_CHECKING:
18
21
  from sphinx.application import Sphinx
19
22
  from sphinx.config import Config
@@ -37,6 +40,14 @@ def _read_template_file(name: str) -> str:
37
40
  return open(_get_template_file(name), 'r').read()
38
41
 
39
42
 
43
+ def _validate_project_example_style(style: str) -> str:
44
+ if style not in {'tab', 'grid'}:
45
+ raise ConfigError(
46
+ 'The "project_example_style" config value must be "tab" or "grid".'
47
+ )
48
+ return style
49
+
50
+
40
51
  ANY_OBJECT_TYPES = {
41
52
  'version': {
42
53
  'schema': {
@@ -61,11 +72,15 @@ ANY_OBJECT_TYPES = {
61
72
  'templates': {
62
73
  'obj': _read_template_file('example'),
63
74
  },
64
- }
75
+ },
65
76
  }
66
77
 
67
78
 
68
79
  def _config_inited(app: Sphinx, config: Config) -> None:
80
+ config.project_example_style = _validate_project_example_style(
81
+ config.project_example_style
82
+ )
83
+
69
84
  if v := config.any_object_types:
70
85
  v.update(ANY_OBJECT_TYPES)
71
86
  else:
@@ -75,5 +90,11 @@ def _config_inited(app: Sphinx, config: Config) -> None:
75
90
 
76
91
  def setup(app: Sphinx):
77
92
  app.setup_extension('sphinxnotes.any')
93
+ app.add_config_value(
94
+ 'project_example_style',
95
+ 'grid',
96
+ 'env',
97
+ types=ENUM('tab', 'grid'),
98
+ )
78
99
  # Should have priority over sphinxnotes.any's "config-inited" callback.
79
100
  app.connect('config-inited', _config_inited, priority=400)
@@ -9,14 +9,35 @@ See also https://sphinx.silverrainz.me/render/.
9
9
  :copyright: Copyright 2025 Shengyu Zhang
10
10
  :license: BSD, see LICENSE for details.
11
11
  """
12
+
12
13
  from __future__ import annotations
13
14
  from typing import TYPE_CHECKING
14
15
 
16
+ from sphinx.config import ENUM
17
+ from sphinxnotes.render import filter
18
+
15
19
  from .sphinxnotes_any import _read_template_file
16
20
 
17
21
  if TYPE_CHECKING:
22
+ from collections.abc import Iterable
18
23
  from sphinx.application import Sphinx
19
24
  from sphinx.config import Config
25
+ from sphinx.environment import BuildEnvironment
26
+
27
+
28
+ def _format_autoconfval_types(valid_types) -> list[str]:
29
+ if isinstance(valid_types, ENUM):
30
+ return [f'``{c!r}``' for c in sorted(valid_types._candidates)] # pyright: ignore[reportPrivateUsage]
31
+ return [f':py:`{t.__name__}`' for t in valid_types]
32
+
33
+
34
+ @filter('autoconfval_types')
35
+ def autoconfval_types(_: BuildEnvironment):
36
+ def _filter(valid_types) -> Iterable[str]:
37
+ return _format_autoconfval_types(valid_types)
38
+
39
+ return _filter
40
+
20
41
 
21
42
  DATA_DEFINE_DIRECTIVES = {
22
43
  'autoconfval': {
@@ -47,6 +68,7 @@ DATA_DEFINE_DIRECTIVES = {
47
68
  },
48
69
  }
49
70
 
71
+
50
72
  def _config_inited(app: Sphinx, config: Config) -> None:
51
73
  if v := config.render_ext_data_define_directives:
52
74
  v.update(DATA_DEFINE_DIRECTIVES)
@@ -3,15 +3,8 @@
3
3
  .. role:: py(code)
4
4
  :language: Python
5
5
 
6
- {% set types = [] %}
7
- {% for t in opt.valid_types %}
8
- {# "<class 'str'>" → "str" #}
9
- {% set t = t | string %}
10
- {% do types.append(t[8:-2]) %}
11
- {% endfor %}
12
-
13
6
  .. confval:: {{ name }}
14
- :type: {{ types | roles('py') | join(',') }}
7
+ :type: {{ opt.valid_types | autoconfval_types | join(', ') }}
15
8
  :default: :py:`{{ opt.default | pprint }}`
16
9
 
17
10
  {%- for line in opt.description.split('\n') %}
@@ -1,4 +1,5 @@
1
- {% if not style or style == 'tab' %}
1
+ {% set effective_style = style or load_extra('env').config.project_example_style %}
2
+ {% if effective_style == 'tab' %}
2
3
  .. tab-set::
3
4
 
4
5
  .. tab-item:: Result
@@ -14,7 +15,7 @@
14
15
  {% for line in content.split('\n') -%}
15
16
  {{ line }}
16
17
  {% endfor %}
17
- {% elif style == 'grid' %}
18
+ {% elif effective_style == 'grid' %}
18
19
  .. grid:: 1 1 2 2
19
20
  :gutter: 1
20
21
  :margin: 0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sphinxnotes-project
3
- Version: 1.0a44
3
+ Version: 1.0a46
4
4
  Summary: A Sphinx extension that provides useful directives for creating project documentation
5
5
  Author: Shengyu Zhang
6
6
  Maintainer: Shengyu Zhang
@@ -25,6 +25,7 @@ Description-Content-Type: text/x-rst
25
25
  License-File: LICENSE
26
26
  Requires-Dist: Sphinx>=7.0
27
27
  Requires-Dist: sphinxnotes-any>=3.0b0
28
+ Requires-Dist: sphinx_design
28
29
  Provides-Extra: dev
29
30
  Requires-Dist: build; extra == "dev"
30
31
  Requires-Dist: twine; extra == "dev"
@@ -16,6 +16,7 @@ ruff.toml
16
16
  docs/Makefile
17
17
  docs/changelog.rst
18
18
  docs/conf.py
19
+ docs/conf.rst
19
20
  docs/index.rst
20
21
  docs/make.bat
21
22
  docs/sphinxnotes_any.rst
@@ -1,5 +1,6 @@
1
1
  Sphinx>=7.0
2
2
  sphinxnotes-any>=3.0b0
3
+ sphinx_design
3
4
 
4
5
  [dev]
5
6
  build