cython-sphinx-plugin 1.0.0__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.
@@ -0,0 +1,6 @@
1
+ """Sphinx extension for documenting Cython declarations."""
2
+
3
+ from cython_sphinx_plugin._metadata import __version__
4
+ from cython_sphinx_plugin.sphinx.setup import setup
5
+
6
+ __all__ = ["__version__", "setup"]
@@ -0,0 +1,27 @@
1
+ """Package metadata: the installed distribution version."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import logging
6
+ from importlib.metadata import PackageNotFoundError, version
7
+
8
+ logger = logging.getLogger(__name__)
9
+
10
+ DISTRIBUTION = "cython-sphinx-plugin"
11
+ UNKNOWN_VERSION = "0+unknown"
12
+
13
+
14
+ def resolve_version(distribution: str = DISTRIBUTION) -> str:
15
+ """Return the installed version of ``distribution``, or ``0+unknown``."""
16
+ try:
17
+ resolved = version(distribution)
18
+ except PackageNotFoundError:
19
+ logger.debug(
20
+ "%s is not installed; using version %s", distribution, UNKNOWN_VERSION
21
+ )
22
+ return UNKNOWN_VERSION
23
+ logger.debug("Resolved %s version %s", distribution, resolved)
24
+ return resolved
25
+
26
+
27
+ __version__ = resolve_version()
@@ -0,0 +1,19 @@
1
+ """Cython compiler adapter and normalized declaration models."""
2
+
3
+ from cython_sphinx_plugin.cython_core.model import (
4
+ Declaration,
5
+ DeclarationKind,
6
+ ModuleParseResult,
7
+ ParseDiagnostic,
8
+ ParseStageMetadata,
9
+ )
10
+ from cython_sphinx_plugin.cython_core.parser import parse_module_sources
11
+
12
+ __all__ = [
13
+ "Declaration",
14
+ "DeclarationKind",
15
+ "ModuleParseResult",
16
+ "ParseDiagnostic",
17
+ "ParseStageMetadata",
18
+ "parse_module_sources",
19
+ ]
@@ -0,0 +1,62 @@
1
+ """Sphinx-independent records returned by the Cython compiler adapter."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass, field
6
+ from pathlib import Path
7
+ from typing import Literal
8
+
9
+ DeclarationKind = Literal["function", "python_class", "extension_type", "field"]
10
+ DiagnosticSeverity = Literal["error", "warning", "note"]
11
+
12
+
13
+ @dataclass(frozen=True)
14
+ class Declaration:
15
+ """A normalized Cython declaration with its compiler source location."""
16
+
17
+ qualified_name: str
18
+ kind: DeclarationKind
19
+ signature: str | None
20
+ type_spelling: str | None
21
+ docstring: str | None
22
+ visibility: str
23
+ source_path: Path
24
+ line: int
25
+ member_parent: str | None = None
26
+ signature_key: tuple[str, ...] = field(default=(), repr=False)
27
+
28
+
29
+ @dataclass(frozen=True)
30
+ class ParseDiagnostic:
31
+ """A compiler diagnostic normalized without discarding its raw text."""
32
+
33
+ code: str
34
+ severity: DiagnosticSeverity
35
+ message: str
36
+ source_path: Path | None
37
+ line: int | None
38
+ column: int | None
39
+ raw_message: str
40
+
41
+
42
+ @dataclass(frozen=True)
43
+ class ParseStageMetadata:
44
+ """The pipeline boundary and declaration totals for one parsed file."""
45
+
46
+ source_path: Path
47
+ stages: tuple[str, ...]
48
+ declaration_count: int
49
+ error_count: int
50
+
51
+
52
+ @dataclass(frozen=True)
53
+ class ModuleParseResult:
54
+ """Declarations, diagnostics, and parser metadata for a Cython module."""
55
+
56
+ module_name: str
57
+ declarations: tuple[Declaration, ...]
58
+ diagnostics: tuple[ParseDiagnostic, ...]
59
+ stages: tuple[ParseStageMetadata, ...]
60
+ declaration_counts: tuple[tuple[str, int], ...]
61
+ source_files: tuple[Path, ...]
62
+ raw_diagnostics: str