babyreqs 0.2.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.
@@ -0,0 +1,175 @@
1
+ Metadata-Version: 2.4
2
+ Name: babyreqs
3
+ Version: 0.2.1
4
+ Summary: Git-backed YAML requirements editor with Markdown, math and PlantUML support
5
+ Author: babyreqs contributors
6
+ License: MIT
7
+ Requires-Python: >=3.9
8
+ Description-Content-Type: text/markdown
9
+ Requires-Dist: PyYAML>=6.0
10
+ Provides-Extra: gui
11
+ Requires-Dist: wxPython>=4.2; extra == "gui"
12
+ Provides-Extra: math
13
+ Requires-Dist: matplotlib>=3.7; extra == "math"
14
+ Provides-Extra: dev
15
+ Requires-Dist: pytest>=7.0; extra == "dev"
16
+ Requires-Dist: matplotlib>=3.7; extra == "dev"
17
+ Requires-Dist: pyinstaller>=6.0; extra == "dev"
18
+ Provides-Extra: all
19
+ Requires-Dist: wxPython>=4.2; extra == "all"
20
+ Requires-Dist: matplotlib>=3.7; extra == "all"
21
+ Provides-Extra: cli
22
+ Requires-Dist: PyYAML>=6.0; extra == "cli"
23
+
24
+ # babyreqs
25
+
26
+ A graphical editor for requirements stored as one `REQ-*.yaml` file per
27
+ requirement in a git repository. It also ships a headless CLI for validation
28
+ and export.
29
+
30
+ ## Features
31
+
32
+ - Grid + hierarchy tree with status colours, status visibility and root/leaf
33
+ filter toggles, filtering and custom columns
34
+ - Markdown editing with math (`$...$`, `$$...$$`) and locally rendered
35
+ PlantUML diagrams
36
+ - Atomic saves with a diff preview and custom commit messages
37
+ - Commits restricted to requirement files; unrelated work is left untouched
38
+ - Unreadable requirement files are preserved, never silently deleted
39
+ - Requirement IDs are immutable: they are never renamed or removed
40
+ - CSV import/export and a PDF export with a contents page, links and outline
41
+
42
+ ## Installation
43
+
44
+ Python 3.9+ and git are required.
45
+
46
+ ### Prebuilt bundles (easiest for end users)
47
+
48
+ Download the archive for your platform from the repository's **Releases** page,
49
+ extract it, and run `babyreqs`. The bundles include Python, wxPython and
50
+ matplotlib, so no Python installation is needed. `git` is still required at
51
+ runtime because repositories are git-backed.
52
+
53
+ ### Install with pip
54
+
55
+ The desktop editor is an optional extra because wxPython is large and may need
56
+ to compile on some Linux configurations:
57
+
58
+ ```bash
59
+ pip install "babyreqs[gui]" # desktop editor + CLI
60
+ # or, in an isolated environment:
61
+ pipx install "babyreqs[gui]"
62
+ ```
63
+
64
+ For the headless CLI only (no wxPython download):
65
+
66
+ ```bash
67
+ pip install babyreqs
68
+ babyreqs-cli --help
69
+ ```
70
+
71
+ From a checkout, install everything for development:
72
+
73
+ ```bash
74
+ pip install -e ".[gui,math,dev]"
75
+ ```
76
+
77
+ Optional extras:
78
+
79
+ ```bash
80
+ pip install "babyreqs[math]" # rendered math images (matplotlib)
81
+ pip install "babyreqs[all]" # gui + math
82
+ ```
83
+
84
+ ### PlantUML (local rendering only)
85
+
86
+ babyreqs never sends diagram text to a remote server. Use one of:
87
+
88
+ ```bash
89
+ # Option 1: plantuml on PATH
90
+ # Debian/Ubuntu: sudo apt install plantuml
91
+ # macOS: brew install plantuml
92
+
93
+ # Option 2: a plantuml.jar with Java
94
+ export BABYREQS_PLANTUML_JAR=/path/to/plantuml.jar
95
+ ```
96
+
97
+ Check the setup with `python babyreqs.py` → **Help > PlantUML Renderer Status**,
98
+ or `babyreqs-cli plantuml-status`.
99
+
100
+ ## Usage
101
+
102
+ ### GUI
103
+
104
+ ```bash
105
+ python babyreqs.py [path/to/repository]
106
+ # after pip install -e .:
107
+ babyreqs [path/to/repository]
108
+ ```
109
+
110
+ ### CLI
111
+
112
+ ```bash
113
+ babyreqs-cli validate path/to/repository [--strict]
114
+ babyreqs-cli list path/to/repository [--status Active] [--json]
115
+ babyreqs-cli export path/to/repository --csv out.csv --pdf out.pdf --json out.json
116
+ babyreqs-cli init path/to/new-repository
117
+ babyreqs-cli plantuml-status
118
+ ```
119
+
120
+ The CLI does not import wxPython and is suitable for CI.
121
+
122
+ ## File format
123
+
124
+ ```yaml
125
+ id: REQ-0001
126
+ title: Bridge shall support VLAN-aware forwarding
127
+ reference: IEEE 802.1Q-2022, Clause 6
128
+ status: Active
129
+ rationale: ''
130
+ parents:
131
+ - REQ-0002
132
+ notes: |
133
+ Notes may contain Markdown.
134
+ owner: Systems
135
+ ```
136
+
137
+ Only files named `REQ-*.yaml` (legacy `REQ_*.yaml` is also accepted) with an
138
+ `id` are editable. Files that match the name but cannot be parsed are reported as
139
+ warnings and preserved unchanged.
140
+
141
+ New repositories include an example `title.yaml` in the repository root. It
142
+ supplies title-page fields for PDF exports. `title` and `subtitle` are used as
143
+ the heading; other keys (or a nested `fields:` mapping) are printed as labelled
144
+ values. Use **File > Edit Title Page...** in the GUI to edit these fields;
145
+ saving writes and commits `title.yaml`.
146
+
147
+ ## Development
148
+
149
+ ```bash
150
+ pip install -e ".[gui,math,dev]"
151
+ python -m unittest discover -s tests -v
152
+ ```
153
+
154
+ Build a wheel/sdist:
155
+
156
+ ```bash
157
+ python -m build
158
+ ```
159
+
160
+ Build a standalone desktop bundle (run on the target OS):
161
+
162
+ ```bash
163
+ pyinstaller --noconfirm babyreqs.spec
164
+ ```
165
+
166
+ The `Release` GitHub Actions workflow runs the tests, publishes wheels to PyPI
167
+ on a `v*` tag, and attaches Windows/macOS/Linux bundles to the GitHub Release.
168
+
169
+ Code layout:
170
+
171
+ - `babyreqs.py` — entry point, dependency check and GUI/CLI dispatch
172
+ - `babyreqs_gui/` — wxPython GUI split into dialogs, renderers and editor mixins
173
+ - `babyreqs_cli.py` — headless command line interface
174
+ - `babyreqs_core/` — repository/YAML, Markdown, PDF and shared data structures
175
+ - `pdf.py` / `pdf_document.py` / `pdf_image.py` / `pdf_text.py` / `pdf_title.py` — PDF writer split into focused modules
@@ -0,0 +1,36 @@
1
+ babyreqs.py,sha256=eTixwnAy3mwciGkeWms_B8UUjCiek2D0hifdhJuZSKw,2349
2
+ babyreqs_cli.py,sha256=FotZ5AMuen9VocRGx71tns6CBbO5r8dMJ0H9DB8MXwA,5944
3
+ babyreqs_core/__init__.py,sha256=jO4nULupPXKojp38WJLT75C9BXQLTR5mz47yCiIPduY,4281
4
+ babyreqs_core/common.py,sha256=CP22NrtqivfwI87qL0KECJl2fULMXgX2IEVEXtKR1GE,38231
5
+ babyreqs_core/documentation.py,sha256=e2hHc45TeJwl2HJ3k9lNOJO-ULJcKJG73a5b0skESE8,5739
6
+ babyreqs_core/errors.py,sha256=EG_uD7uBpZDfbh0_qZUfFky8nRte87e6XBExaVG3S1s,738
7
+ babyreqs_core/git.py,sha256=Z12XaqIlMPjeBGuTrXCr08Hd4YvXhVIbeqZkMdOfTdc,4771
8
+ babyreqs_core/markdown.py,sha256=lX1eGpMjMp0COo2A0HhhhySBvCdVeUvS-i822yC4sCo,19420
9
+ babyreqs_core/markdown_model.py,sha256=AaGZcoRSNnwDCs93utAzBniaO5raEvn_AbEEIkRA7NM,4163
10
+ babyreqs_core/markdown_renderers.py,sha256=QX5dYq43HZGwSv9tcLK76E89jLfP_N4ZxUQvrJ0Zw7o,8663
11
+ babyreqs_core/model.py,sha256=l7t_xdZJwvzzLCKLhkBNG35liH_ZYM2Os_NjVLGvFRU,10816
12
+ babyreqs_core/pdf.py,sha256=2oHLGVZ4R_5h5pEwwVPP_9ADol4WfGE6eeylur4PGMU,4311
13
+ babyreqs_core/pdf_document.py,sha256=dOLdLBInnxCSkP6bCqFbJPjYyEC6Ux5zEXljgFOsNwY,25218
14
+ babyreqs_core/pdf_image.py,sha256=0A3vNqa0PeUK5Wpolr_MqAEWOmFWvzt0LqYEsHCrtpA,10830
15
+ babyreqs_core/pdf_text.py,sha256=f5H-h--laAdyKkryBHRyHzXea1PTBBTpUsKkjzJJPVc,4565
16
+ babyreqs_core/pdf_title.py,sha256=_Hwmz9WC_gzLPmOpAsqKGTPVKXDBTE75PkFJPexv1yg,10423
17
+ babyreqs_core/repository.py,sha256=PbMuGIL-09Oi4P94XOAchiLpcZqmdodTBD7xsbgjt-8,24210
18
+ babyreqs_core/version.py,sha256=o4nKEIsB8vqjSiF-48DZyJhHauhHs388KU5jNC4tMO8,989
19
+ babyreqs_gui/__init__.py,sha256=WLciw1d7jcq-NwUDLpSJA3ufw0mUUqmB9Nfat2nUjPg,731
20
+ babyreqs_gui/constants.py,sha256=pEmdnkGvRaXNeXOZx8R_A7wWe6erGsDqJWfojHHfFNk,103
21
+ babyreqs_gui/dialogs.py,sha256=8UMxKsQACc6GtcYeLY7iC3aeDVNIuOM_QpqJcki1rXM,14850
22
+ babyreqs_gui/editor.py,sha256=qv6ssZfTpRIFszhiT0F_5RffidfUIkEVAfkha42nLvU,676
23
+ babyreqs_gui/editor_base.py,sha256=nP-PYYeu-HAOwKWXlQXgg8-fZZTpQRv1v9D-k4uXZ6c,22593
24
+ babyreqs_gui/editor_edit.py,sha256=u5GvWbpTN4f8LaGoctzwHdHAL1VvCSHxYUJlyodxR44,8236
25
+ babyreqs_gui/editor_grid.py,sha256=ZNGxF5HCJJFzdWtA-HPy3V0TpX546ieacyFXiWilPyM,13011
26
+ babyreqs_gui/editor_repo.py,sha256=hjGr-dIv1VUQE0bWl5cecwuhvmIYbfrgPA5qqiNQVMU,21174
27
+ babyreqs_gui/editor_tree.py,sha256=36PCq9mvabihsQoopig8jDzcb1slZgbfxP63ojOso6I,8733
28
+ babyreqs_gui/grid_view.py,sha256=T_wIQNuUOdzm2MTD_pwp167C3nqjmSXi7yQlIkXobPY,5900
29
+ babyreqs_gui/models.py,sha256=NOJawXXR_w8k-9-4XalOON8ls4IgcvSZg5DeO8QQ_XM,8461
30
+ babyreqs_gui/renderers.py,sha256=I5l9p2TwjfOuUNvR9Ib4T6gnAo2T5ERHYPzKCaJWo3w,6301
31
+ babyreqs_gui/tree_view.py,sha256=zndUVEvAXzOlA9OQx6Bo2ADFiu_J52y8NDCN-ABTTaw,2382
32
+ babyreqs-0.2.1.dist-info/METADATA,sha256=TsmqFKpaXbbTaXUkyUSkzoyIRqePS0CU3k53mUi6kCk,5030
33
+ babyreqs-0.2.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
34
+ babyreqs-0.2.1.dist-info/entry_points.txt,sha256=F_lFnLTHGdAxDxo-y03ViOLOk-nxNuolbM2BgUIm-KY,76
35
+ babyreqs-0.2.1.dist-info/top_level.txt,sha256=LPtoA9sU1S6I5-uFCi8SwB6O9PM7vp-ss82qylUt72M,49
36
+ babyreqs-0.2.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ babyreqs = babyreqs:main
3
+ babyreqs-cli = babyreqs_cli:main
@@ -0,0 +1,4 @@
1
+ babyreqs
2
+ babyreqs_cli
3
+ babyreqs_core
4
+ babyreqs_gui
babyreqs.py ADDED
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env python3
2
+ """babyreqs graphical requirements editor.
3
+
4
+ The GUI depends on wxPython; headless commands should use ``babyreqs_cli`` and
5
+ the ``babyreqs_core`` package instead.
6
+
7
+ The window implementation lives in the :mod:`babyreqs_gui` package. This module
8
+ keeps the dependency check and the command-line entry point.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ import sys
14
+
15
+ MIN_PYTHON = (3, 9)
16
+ REQUIRED_PYTHON_PACKAGES = {
17
+ "wx": "wxPython",
18
+ "yaml": "PyYAML",
19
+ }
20
+
21
+
22
+ def _runtime_check() -> None:
23
+ """Fail fast with clear messages for unsupported runtime environments."""
24
+ if sys.version_info < MIN_PYTHON:
25
+ current = ".".join(str(part) for part in sys.version_info[:3])
26
+ required = ".".join(str(part) for part in MIN_PYTHON)
27
+ sys.stderr.write(f"babyreqs requires Python {required}+ (found {current}).\n")
28
+ raise SystemExit(1)
29
+
30
+ missing = []
31
+ for module_name, package_name in REQUIRED_PYTHON_PACKAGES.items():
32
+ try:
33
+ __import__(module_name)
34
+ except Exception as exc:
35
+ missing.append(f" - {package_name} (import {module_name!r} failed: {exc})")
36
+
37
+ if missing:
38
+ sys.stderr.write(
39
+ "babyreqs is missing required Python dependencies:\n"
40
+ + "\n".join(missing)
41
+ + "\n\nThe graphical editor is an optional extra. Install it with:\n"
42
+ + " pip install \"babyreqs[gui]\"\n"
43
+ + "\nFor the headless CLI alone:\n"
44
+ + " pip install babyreqs\n"
45
+ )
46
+ raise SystemExit(1)
47
+
48
+ import shutil
49
+
50
+ if shutil.which("git") is None:
51
+ sys.stderr.write("babyreqs requires git to be installed and available on PATH.\n")
52
+ raise SystemExit(1)
53
+
54
+
55
+ _runtime_check()
56
+
57
+ import wx
58
+
59
+ from babyreqs_gui import RequirementsEditor
60
+
61
+
62
+ def main(argv: list[str] | None = None) -> int:
63
+ args = list(sys.argv[1:] if argv is None else argv)
64
+ app = wx.App(False)
65
+ # wxGTK occasionally emits a harmless debug message when the menu bar gets
66
+ # a spurious focus-out event (e.g. on the first click into the grid). Keep
67
+ # warnings and errors, but hide debug-level noise.
68
+ wx.Log.SetLogLevel(wx.LOG_Warning)
69
+ frame = RequirementsEditor(initial_repo_path=args[0] if args else None)
70
+ frame.Show()
71
+ app.MainLoop()
72
+ return 0
73
+
74
+
75
+ if __name__ == "__main__":
76
+ raise SystemExit(main())
babyreqs_cli.py ADDED
@@ -0,0 +1,181 @@
1
+ #!/usr/bin/env python3
2
+ """Headless commands for babyreqs.
3
+
4
+ Unlike the GUI, this module never imports wxPython, so it works on servers and
5
+ in CI environments.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ import argparse
11
+ import csv
12
+ import json
13
+ import os
14
+ import sys
15
+
16
+ from babyreqs_core import (
17
+ BASE_COLUMNS,
18
+ VIRTUAL_COLUMNS,
19
+ RequirementSet,
20
+ RequirementsRepository,
21
+ _PdfDocument,
22
+ build_requirements_pdf,
23
+ is_git_repository,
24
+ plantuml_available,
25
+ plantuml_status,
26
+ )
27
+
28
+
29
+ def _repo_path(value: str) -> str:
30
+ return os.path.abspath(os.path.expanduser(value))
31
+
32
+
33
+ def _load(repo: str) -> RequirementSet:
34
+ return RequirementsRepository(repo).load()
35
+
36
+
37
+ def cmd_validate(args: argparse.Namespace) -> int:
38
+ repo = _repo_path(args.repository)
39
+ if not is_git_repository(repo):
40
+ print(f"error: not a git repository: {repo}", file=sys.stderr)
41
+ return 2
42
+
43
+ document = _load(repo)
44
+ issues = document.validate()
45
+ for issue in issues:
46
+ print(f"{issue.level}: {issue}")
47
+
48
+ print(
49
+ f"Validated {len(document.requirements)} requirement(s), "
50
+ f"{len(document.parent_links)} parent link(s), "
51
+ f"{len(issues)} issue(s)."
52
+ )
53
+ blocking = [issue for issue in issues if issue.level == "error"]
54
+ if blocking or (args.strict and issues):
55
+ return 1
56
+ return 0
57
+
58
+
59
+ def _all_rows(document: RequirementSet):
60
+ rows = []
61
+ for requirement in document.requirements:
62
+ values = dict(requirement.values)
63
+ req_id = requirement.id
64
+ values["parents"] = ", ".join(document.parents_of(req_id))
65
+ values["children"] = ", ".join(document.children_of(req_id))
66
+ rows.append(values)
67
+ return rows
68
+
69
+
70
+ def cmd_list(args: argparse.Namespace) -> int:
71
+ repo = _repo_path(args.repository)
72
+ if not is_git_repository(repo):
73
+ print(f"error: not a git repository: {repo}", file=sys.stderr)
74
+ return 2
75
+ document = _load(repo)
76
+ rows = _all_rows(document)
77
+ if args.status:
78
+ wanted = args.status.lower()
79
+ rows = [row for row in rows if row.get("status", "").lower() == wanted]
80
+ for row in rows:
81
+ if args.json:
82
+ continue
83
+ print(f"{row.get('id', '')}\t{row.get('status', '')}\t{row.get('title', '')}")
84
+ if args.json:
85
+ print(json.dumps(rows, indent=2, ensure_ascii=False))
86
+ return 0
87
+
88
+
89
+ def cmd_export(args: argparse.Namespace) -> int:
90
+ repo = _repo_path(args.repository)
91
+ if not args.csv and not args.pdf and not args.json:
92
+ print("error: specify at least one of --csv, --pdf or --json", file=sys.stderr)
93
+ return 2
94
+ if not is_git_repository(repo):
95
+ print(f"error: not a git repository: {repo}", file=sys.stderr)
96
+ return 2
97
+
98
+ document = _load(repo)
99
+ rows = _all_rows(document)
100
+
101
+ if args.csv:
102
+ columns = BASE_COLUMNS + [col for col in document.custom_columns if col not in BASE_COLUMNS] + VIRTUAL_COLUMNS
103
+ with open(os.path.abspath(args.csv), "w", encoding="utf-8", newline="") as handle:
104
+ writer = csv.DictWriter(handle, fieldnames=columns, extrasaction="ignore")
105
+ writer.writeheader()
106
+ writer.writerows(rows)
107
+ print(f"Wrote {len(rows)} row(s) to {args.csv}")
108
+ if args.json:
109
+ with open(os.path.abspath(args.json), "w", encoding="utf-8") as handle:
110
+ json.dump(rows, handle, indent=2, ensure_ascii=False)
111
+ handle.write("\n")
112
+ print(f"Wrote {len(rows)} row(s) to {args.json}")
113
+ if args.pdf:
114
+ document_pdf = _PdfDocument()
115
+ build_requirements_pdf(
116
+ document_pdf, document.requirements, document.parent_links, repo
117
+ )
118
+ document_pdf.save(os.path.abspath(args.pdf))
119
+ print(f"Wrote PDF to {args.pdf}")
120
+ return 0
121
+
122
+
123
+ def cmd_init(args: argparse.Namespace) -> int:
124
+ path = _repo_path(args.path)
125
+ try:
126
+ result = RequirementsRepository(path).initialize()
127
+ except OSError as exc:
128
+ print(f"error: {exc}", file=sys.stderr)
129
+ return 1
130
+ if not result.ok:
131
+ print(f"error: {result.message}", file=sys.stderr)
132
+ return 1
133
+ print(f"Initialized {path}" + (f" ({result.commit_hash})" if result.commit_hash else ""))
134
+ return 0
135
+
136
+
137
+ def cmd_plantuml_status(args: argparse.Namespace) -> int:
138
+ print(plantuml_status())
139
+ return 0 if plantuml_available() else 1
140
+
141
+
142
+ def build_parser() -> argparse.ArgumentParser:
143
+ parser = argparse.ArgumentParser(prog="babyreqs-cli", description="Headless babyreqs commands")
144
+ subparsers = parser.add_subparsers(dest="command", required=True)
145
+
146
+ validate = subparsers.add_parser("validate", help="Check YAML files for errors")
147
+ validate.add_argument("repository")
148
+ validate.add_argument("--strict", action="store_true", help="fail on warnings too")
149
+ validate.set_defaults(func=cmd_validate)
150
+
151
+ listing = subparsers.add_parser("list", help="List requirements")
152
+ listing.add_argument("repository")
153
+ listing.add_argument("--status", help="only show this status")
154
+ listing.add_argument("--json", action="store_true", help="print JSON instead of a table")
155
+ listing.set_defaults(func=cmd_list)
156
+
157
+ export = subparsers.add_parser("export", help="Export requirements")
158
+ export.add_argument("repository")
159
+ export.add_argument("--csv", metavar="PATH")
160
+ export.add_argument("--json", metavar="PATH")
161
+ export.add_argument("--pdf", metavar="PATH")
162
+ export.set_defaults(func=cmd_export)
163
+
164
+ init = subparsers.add_parser("init", help="Create a new requirements repository")
165
+ init.add_argument("path")
166
+ init.set_defaults(func=cmd_init)
167
+
168
+ status = subparsers.add_parser("plantuml-status", help="Show the local PlantUML renderer")
169
+ status.set_defaults(func=cmd_plantuml_status)
170
+
171
+ return parser
172
+
173
+
174
+ def main(argv: list[str] | None = None) -> int:
175
+ parser = build_parser()
176
+ args = parser.parse_args(argv)
177
+ return int(args.func(args))
178
+
179
+
180
+ if __name__ == "__main__":
181
+ raise SystemExit(main())
@@ -0,0 +1,157 @@
1
+ """Dependency-light core for babyreqs (GUI-independent)."""
2
+
3
+ import warnings
4
+
5
+ from .common import (
6
+ BASE_COLUMNS,
7
+ DEFAULT_TITLE_METADATA,
8
+ DEMO_SAMPLE_PARENT_LINKS,
9
+ DEMO_SAMPLE_REQUIREMENTS,
10
+ DEMO_SAMPLE_TITLE,
11
+ KNOWN_META_KEYS,
12
+ REQUIREMENT_FILE_PREFIX,
13
+ REQUIREMENT_FILE_SUFFIX,
14
+ REQUIREMENT_ID_PREFIX,
15
+ STATUS_CHOICES,
16
+ STATUS_COLOURS,
17
+ VIRTUAL_COLUMNS,
18
+ ColumnKind,
19
+ ColumnSpec,
20
+ CommitResult,
21
+ RequirementLoadResult,
22
+ Status,
23
+ ValidationIssue,
24
+ WritePlan,
25
+ column_spec,
26
+ column_specs,
27
+ status_colour_spec,
28
+ stringify,
29
+ )
30
+ from .documentation import DOCUMENTATION
31
+ from .errors import CommitError, BabyreqsError, RepositoryError, ValidationError
32
+ from .version import APP_NAME, DESCRIPTION, VERSION, __version__
33
+ from .git import GitClient
34
+ from .markdown import (
35
+ Block,
36
+ DEFAULT_CONTEXT,
37
+ InlineToken,
38
+ ListItem,
39
+ RenderContext,
40
+ configured_plantuml_command,
41
+ markdown_cache_dir,
42
+ markdown_to_plain,
43
+ parse_inline,
44
+ parse_markdown,
45
+ plantuml_available,
46
+ plantuml_status,
47
+ render_math_image,
48
+ render_markdown_html,
49
+ render_plantuml_image,
50
+ tokens_to_html,
51
+ tokens_to_plain,
52
+ )
53
+ from .markdown_model import (
54
+ CodeBlock,
55
+ CodeToken,
56
+ EmphasisToken,
57
+ HeadingBlock,
58
+ HorizontalRuleBlock,
59
+ ImageToken,
60
+ LinkToken,
61
+ ListBlock,
62
+ MathBlock,
63
+ MathToken,
64
+ ParagraphBlock,
65
+ PlantUmlBlock,
66
+ QuoteBlock,
67
+ TableBlock,
68
+ TextToken,
69
+ )
70
+ from .model import Requirement, RequirementSet, as_requirement
71
+ from .pdf import (
72
+ PDF_MARGIN,
73
+ PDF_PAGE_HEIGHT,
74
+ PDF_PAGE_WIDTH,
75
+ StyledRun,
76
+ build_requirements_pdf,
77
+ load_png,
78
+ load_title_metadata,
79
+ merge_title_metadata,
80
+ _PdfDocument,
81
+ _load_title_metadata,
82
+ _pdf_colour,
83
+ _pdf_escape,
84
+ _pdf_estimate_width,
85
+ _pdf_safe_text,
86
+ _pdf_wrap_text,
87
+ _title_page_content,
88
+ )
89
+ from .repository import (
90
+ RequirementWriteTransaction,
91
+ RequirementsRepository,
92
+ build_write_plan,
93
+ commit_paths,
94
+ commit_paths_from_staged,
95
+ git_error,
96
+ initialize_repository,
97
+ is_git_repository,
98
+ is_requirement_file,
99
+ is_requirement_filename,
100
+ load_requirement_rows,
101
+ read_requirement_yaml,
102
+ requirement_filename,
103
+ requirements_diff,
104
+ run_git,
105
+ save_title_metadata,
106
+ validate_rows,
107
+ write_text_atomic,
108
+ )
109
+
110
+
111
+ # Older code used underscored aliases for the public functions above. They
112
+ # keep working, but emit a DeprecationWarning so the migration is visible.
113
+ _DEPRECATED_ALIASES = {
114
+ "_build_requirement_rows": "build_write_plan",
115
+ "_build_requirements_pdf": "build_requirements_pdf",
116
+ "_build_write_plan": "build_write_plan",
117
+ "_commit_requirement_changes": "commit_paths",
118
+ "_git_error": "git_error",
119
+ "_initialize_repository": "initialize_repository",
120
+ "_is_git_repository": "is_git_repository",
121
+ "_is_requirement_file": "is_requirement_file",
122
+ "_is_requirement_filename": "is_requirement_filename",
123
+ "_load_requirement_rows": "load_requirement_rows",
124
+ "_load_title_metadata": "load_title_metadata",
125
+ "_markdown_cache_dir": "markdown_cache_dir",
126
+ "_markdown_to_plain": "markdown_to_plain",
127
+ "_parse_markdown": "parse_markdown",
128
+ "_plantuml_available": "plantuml_available",
129
+ "_plantuml_command": "configured_plantuml_command",
130
+ "_read_requirement_yaml": "read_requirement_yaml",
131
+ "_render_markdown_html": "render_markdown_html",
132
+ "_render_math_image": "render_math_image",
133
+ "_render_plantuml_image": "render_plantuml_image",
134
+ "_requirement_filename": "requirement_filename",
135
+ "_run_git": "run_git",
136
+ "_save_title_metadata": "save_title_metadata",
137
+ "_status_colour_spec": "status_colour_spec",
138
+ "_stringify": "stringify",
139
+ "_validate_rows": "validate_rows",
140
+ }
141
+
142
+
143
+ def __getattr__(name: str):
144
+ target = _DEPRECATED_ALIASES.get(name)
145
+ if target is None:
146
+ raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
147
+ warnings.warn(
148
+ f"babyreqs_core.{name} is deprecated; use babyreqs_core.{target} instead",
149
+ DeprecationWarning,
150
+ stacklevel=2,
151
+ )
152
+ return globals()[target]
153
+
154
+
155
+ __all__ = [name for name in globals() if not name.startswith("__")] + list(
156
+ _DEPRECATED_ALIASES
157
+ ) + ["__version__"]