sphinx-vite-builder 0.0.1a16.dev3__tar.gz → 0.0.1a16.dev4__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 (17) hide show
  1. {sphinx_vite_builder-0.0.1a16.dev3 → sphinx_vite_builder-0.0.1a16.dev4}/PKG-INFO +1 -1
  2. {sphinx_vite_builder-0.0.1a16.dev3 → sphinx_vite_builder-0.0.1a16.dev4}/pyproject.toml +1 -1
  3. {sphinx_vite_builder-0.0.1a16.dev3 → sphinx_vite_builder-0.0.1a16.dev4}/src/sphinx_vite_builder/__init__.py +1 -1
  4. {sphinx_vite_builder-0.0.1a16.dev3 → sphinx_vite_builder-0.0.1a16.dev4}/src/sphinx_vite_builder/_internal/hooks.py +38 -2
  5. {sphinx_vite_builder-0.0.1a16.dev3 → sphinx_vite_builder-0.0.1a16.dev4}/.gitignore +0 -0
  6. {sphinx_vite_builder-0.0.1a16.dev3 → sphinx_vite_builder-0.0.1a16.dev4}/AGENTS.md +0 -0
  7. {sphinx_vite_builder-0.0.1a16.dev3 → sphinx_vite_builder-0.0.1a16.dev4}/CLAUDE.md +0 -0
  8. {sphinx_vite_builder-0.0.1a16.dev3 → sphinx_vite_builder-0.0.1a16.dev4}/README.md +0 -0
  9. {sphinx_vite_builder-0.0.1a16.dev3 → sphinx_vite_builder-0.0.1a16.dev4}/src/sphinx_vite_builder/_internal/__init__.py +0 -0
  10. {sphinx_vite_builder-0.0.1a16.dev3 → sphinx_vite_builder-0.0.1a16.dev4}/src/sphinx_vite_builder/_internal/bus.py +0 -0
  11. {sphinx_vite_builder-0.0.1a16.dev3 → sphinx_vite_builder-0.0.1a16.dev4}/src/sphinx_vite_builder/_internal/config.py +0 -0
  12. {sphinx_vite_builder-0.0.1a16.dev3 → sphinx_vite_builder-0.0.1a16.dev4}/src/sphinx_vite_builder/_internal/errors.py +0 -0
  13. {sphinx_vite_builder-0.0.1a16.dev3 → sphinx_vite_builder-0.0.1a16.dev4}/src/sphinx_vite_builder/_internal/process.py +0 -0
  14. {sphinx_vite_builder-0.0.1a16.dev3 → sphinx_vite_builder-0.0.1a16.dev4}/src/sphinx_vite_builder/_internal/vite.py +0 -0
  15. {sphinx_vite_builder-0.0.1a16.dev3 → sphinx_vite_builder-0.0.1a16.dev4}/src/sphinx_vite_builder/build.py +0 -0
  16. {sphinx_vite_builder-0.0.1a16.dev3 → sphinx_vite_builder-0.0.1a16.dev4}/src/sphinx_vite_builder/hatch_plugin.py +0 -0
  17. {sphinx_vite_builder-0.0.1a16.dev3 → sphinx_vite_builder-0.0.1a16.dev4}/src/sphinx_vite_builder/py.typed +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sphinx-vite-builder
3
- Version: 0.0.1a16.dev3
3
+ Version: 0.0.1a16.dev4
4
4
  Summary: PEP 517 build backend + Sphinx extension that orchestrates Vite via pnpm
5
5
  Project-URL: Repository, https://github.com/git-pull/gp-sphinx
6
6
  Author-email: Tony Narlock <tony@git-pull.com>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "sphinx-vite-builder"
3
- version = "0.0.1a16.dev3"
3
+ version = "0.0.1a16.dev4"
4
4
  description = "PEP 517 build backend + Sphinx extension that orchestrates Vite via pnpm"
5
5
  requires-python = ">=3.10,<4.0"
6
6
  authors = [
@@ -24,7 +24,7 @@ import typing as t
24
24
  if t.TYPE_CHECKING:
25
25
  from sphinx.application import Sphinx
26
26
 
27
- __version__ = "0.0.1a16.dev3"
27
+ __version__ = "0.0.1a16.dev4"
28
28
 
29
29
  logger = logging.getLogger(__name__)
30
30
  logger.addHandler(logging.NullHandler())
@@ -33,10 +33,12 @@ import signal
33
33
  import typing as t
34
34
  import weakref
35
35
 
36
+ from sphinx.errors import ExtensionError
36
37
  from sphinx.util import logging as sphinx_logging
37
38
 
38
39
  from .bus import AsyncioBus
39
40
  from .config import Mode, SphinxViteBuilderConfig, detect_mode, resolve_vite_root
41
+ from .errors import SphinxViteBuilderError
40
42
  from .process import AsyncProcess
41
43
  from .vite import pnpm_install_command, run_vite_build, vite_watch_command
42
44
 
@@ -62,6 +64,27 @@ _active_handles: weakref.WeakValueDictionary[int, AsyncioBus] = (
62
64
  )
63
65
 
64
66
 
67
+ def _raise_as_extension_error(exc: Exception) -> t.NoReturn:
68
+ """Re-raise ``exc`` as :class:`sphinx.errors.ExtensionError`.
69
+
70
+ Sphinx's ``EventManager.emit()`` (``sphinx/events.py:405-456``)
71
+ auto-wraps non-``SphinxError`` exceptions raised from event handlers
72
+ using ``safe_getattr(listener.handler, '__module__', None)`` for the
73
+ ``modname`` kwarg — which for our hooks resolves to
74
+ ``'sphinx_vite_builder._internal.hooks'``. Wrapping explicitly with
75
+ ``modname='sphinx_vite_builder'`` keeps the user-facing
76
+ ``Extension error (sphinx_vite_builder)`` category clean and points
77
+ consumers at the published package, not the internal module path.
78
+ Because :class:`ExtensionError` IS a :class:`SphinxError`, the
79
+ auto-wrap path skips it: no double-wrap risk.
80
+ """
81
+ raise ExtensionError(
82
+ str(exc),
83
+ orig_exc=exc,
84
+ modname="sphinx_vite_builder",
85
+ ) from exc
86
+
87
+
65
88
  def _build_config(app: Sphinx) -> SphinxViteBuilderConfig:
66
89
  """Snapshot the live config values into a frozen dataclass."""
67
90
  return SphinxViteBuilderConfig(
@@ -136,7 +159,10 @@ def on_builder_inited(app: Sphinx) -> None:
136
159
  # same fast-fail diagnostics as the PEP 517 backend uses.
137
160
  # ``run_vite_build`` resolves ``web/`` relative to its
138
161
  # ``project_root`` argument, so pass the parent of vite_root.
139
- run_vite_build(project_root=config.vite_root.parent)
162
+ try:
163
+ run_vite_build(project_root=config.vite_root.parent)
164
+ except SphinxViteBuilderError as exc:
165
+ _raise_as_extension_error(exc)
140
166
  return
141
167
 
142
168
  existing_proc: AsyncProcess | None = getattr(app, _PROC_ATTR, None)
@@ -167,7 +193,17 @@ def on_builder_inited(app: Sphinx) -> None:
167
193
 
168
194
  command = vite_watch_command()
169
195
  logger.info("[vite] spawning %s in %s", " ".join(command), config.vite_root)
170
- bus.call_sync(proc.start(command, cwd=config.vite_root))
196
+ try:
197
+ bus.call_sync(proc.start(command, cwd=config.vite_root))
198
+ except (SphinxViteBuilderError, OSError) as exc:
199
+ # OSError covers the FileNotFoundError that
200
+ # ``asyncio.create_subprocess_exec`` raises when the package
201
+ # manager (pnpm) is not on PATH. SphinxViteBuilderError covers
202
+ # any typed diagnostic raised through the bus from inside
203
+ # AsyncProcess.start. Both get the same modname-attributed
204
+ # ExtensionError treatment so users see "Extension error
205
+ # (sphinx_vite_builder)" instead of the internal module path.
206
+ _raise_as_extension_error(exc)
171
207
 
172
208
  if not getattr(app, _TEARDOWN_REGISTERED_ATTR, False):
173
209
  _install_teardown_handlers(app)