Unify documentation rules across languages and fix the Python template

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Jan Doubravský
2026-08-18 10:33:00 +02:00
co-authored by Claude Opus 5
parent 19e9b8f2fa
commit 5c0f2f758f
19 changed files with 502 additions and 244 deletions
+21 -12
View File
@@ -1,6 +1,8 @@
"""
Generic application constants template.
Requires Python 3.11+ (uses the stdlib `tomllib` module).
Usage in your project:
1. Copy this file to src/constants.py
2. Fill in APP_NAME and APP_FULL_NAME
@@ -14,14 +16,14 @@ Version loading priority:
Debug mode:
Controlled exclusively via .env: ENV_DEBUG=true
Accepted true-values: true, 1, yes (case-insensitive)
When enabled, VERSION carries a "DEV" suffix with no separator: v1.2.3DEV
"""
import os
import tomllib
from pathlib import Path
import tomllib
from dotenv import load_dotenv
from loguru import logger
load_dotenv()
@@ -38,22 +40,28 @@ def _load_version() -> str:
# 1. pyproject.toml
try:
with open(_PYPROJECT, "rb") as f:
version = tomllib.load(f)["project"]["version"]
# Write fallback for frozen/PyInstaller builds
_VERSION_FILE.write_text(
f'"""Auto-generated — do not edit manually."""\n__version__ = "{version}"\n',
encoding="utf-8",
)
return version
except (FileNotFoundError, KeyError):
version: str = tomllib.load(f)["project"]["version"]
except (OSError, KeyError, tomllib.TOMLDecodeError):
pass
else:
# Write the fallback used by frozen/PyInstaller builds, which do not ship
# pyproject.toml. A read-only or missing target is not a fatal condition.
try:
_VERSION_FILE.write_text(
f'"""Auto-generated — do not edit manually."""\n__version__ = "{version}"\n',
encoding="utf-8",
)
except OSError:
pass
return version
# 2. _version.py
try:
from src._version import __version__ # type: ignore[import]
return __version__
from src._version import __version__
except ImportError:
pass
else:
return __version__
# 3. last resort
return "0.0.0"
@@ -63,6 +71,7 @@ def _load_version() -> str:
# Debug mode
# ---------------------------------------------------------------------------
def _load_debug() -> bool:
return os.getenv("ENV_DEBUG", "false").lower() in ("true", "1", "yes")