selfdoc 0.3.1__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.
selfdoc/__init__.py ADDED
@@ -0,0 +1,45 @@
1
+ """selfdoc: Code-aware static site generator with directive-based content extraction."""
2
+
3
+ import os
4
+ import sys
5
+
6
+
7
+ def _detect_version():
8
+ """Detect package version, preferring pyproject.toml over installed metadata.
9
+
10
+ Order: pyproject.toml in the source tree (accurate during editable installs)
11
+ -> importlib.metadata (works for regular installs) -> "unknown".
12
+ """
13
+ # Try reading version from pyproject.toml next to the package source
14
+ try:
15
+ pyproject_path = os.path.realpath(
16
+ os.path.join(os.path.dirname(__file__), "..", "pyproject.toml")
17
+ )
18
+ if os.path.isfile(pyproject_path):
19
+ try:
20
+ import tomllib
21
+ except ModuleNotFoundError:
22
+ import tomli as tomllib # type: ignore[no-redef]
23
+ with open(pyproject_path, "rb") as f:
24
+ data = tomllib.load(f)
25
+ return data["project"]["version"]
26
+ except Exception:
27
+ pass
28
+
29
+ # Fall back to installed dist-info metadata
30
+ try:
31
+ from importlib.metadata import version as _get_version
32
+ return _get_version("selfdoc")
33
+ except Exception:
34
+ pass
35
+
36
+ return "unknown"
37
+
38
+
39
+ __version__ = _detect_version()
40
+
41
+
42
+ def main():
43
+ """Entry point for the selfdoc CLI."""
44
+ from selfdoc.cli import run
45
+ run()
selfdoc/__main__.py ADDED
@@ -0,0 +1,3 @@
1
+ from selfdoc import main
2
+
3
+ main()