sourcebound 1.2.1rc1__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.
- clean_docs/__init__.py +26 -0
- clean_docs/__main__.py +3 -0
- clean_docs/accessibility.py +182 -0
- clean_docs/adapters/__init__.py +1 -0
- clean_docs/adapters/event_capture.py +56 -0
- clean_docs/adapters/mdx_dependencies.json +714 -0
- clean_docs/adapters/mdx_parser.mjs +29992 -0
- clean_docs/applicability.py +330 -0
- clean_docs/audit.py +1120 -0
- clean_docs/bootstrap.py +507 -0
- clean_docs/capabilities.py +200 -0
- clean_docs/changed.py +452 -0
- clean_docs/claims.py +840 -0
- clean_docs/cli.py +1612 -0
- clean_docs/context.py +307 -0
- clean_docs/corpus.py +377 -0
- clean_docs/demo.py +369 -0
- clean_docs/doctor.py +184 -0
- clean_docs/emit/__init__.py +4 -0
- clean_docs/emit/llms_txt.py +102 -0
- clean_docs/emit/stepwise.py +168 -0
- clean_docs/engine.py +324 -0
- clean_docs/errors.py +20 -0
- clean_docs/evaluation.py +867 -0
- clean_docs/execution.py +138 -0
- clean_docs/explain.py +123 -0
- clean_docs/extractors/__init__.py +19 -0
- clean_docs/extractors/command.py +51 -0
- clean_docs/extractors/inventory.py +176 -0
- clean_docs/extractors/json_pointer.py +84 -0
- clean_docs/extractors/python_literal.py +104 -0
- clean_docs/extractors/static.py +111 -0
- clean_docs/feedback.py +1390 -0
- clean_docs/impact.py +1624 -0
- clean_docs/improvements.py +1178 -0
- clean_docs/inventory.py +474 -0
- clean_docs/isolation.py +157 -0
- clean_docs/manifest.py +898 -0
- clean_docs/mdx.py +272 -0
- clean_docs/migration.py +121 -0
- clean_docs/models.py +194 -0
- clean_docs/outcomes.py +296 -0
- clean_docs/performance.py +123 -0
- clean_docs/phrasing.py +448 -0
- clean_docs/plugins.py +249 -0
- clean_docs/policy.py +536 -0
- clean_docs/projections.py +255 -0
- clean_docs/regions.py +75 -0
- clean_docs/release.py +232 -0
- clean_docs/renderers.py +57 -0
- clean_docs/residue.py +311 -0
- clean_docs/review_contracts.py +862 -0
- clean_docs/review_ledger.py +297 -0
- clean_docs/review_limits.py +9 -0
- clean_docs/sensitivity.py +602 -0
- clean_docs/snapshot.py +212 -0
- clean_docs/standard.py +281 -0
- clean_docs/standards/default.json +309 -0
- clean_docs/standards/exemplars.md +87 -0
- clean_docs/standards/v0-migrations.json +26 -0
- clean_docs/symbols.py +47 -0
- clean_docs/templates.py +96 -0
- clean_docs/verdict.py +1397 -0
- clean_docs/visuals.py +346 -0
- clean_docs/write_gate.py +170 -0
- sourcebound-1.2.1rc1.dist-info/LICENSE +21 -0
- sourcebound-1.2.1rc1.dist-info/METADATA +109 -0
- sourcebound-1.2.1rc1.dist-info/RECORD +71 -0
- sourcebound-1.2.1rc1.dist-info/WHEEL +5 -0
- sourcebound-1.2.1rc1.dist-info/entry_points.txt +2 -0
- sourcebound-1.2.1rc1.dist-info/top_level.txt +1 -0
clean_docs/templates.py
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""Render documentation around a complete task contract."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
|
|
7
|
+
from clean_docs.errors import ConfigurationError
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
TASK_SECTIONS = (
|
|
11
|
+
"Intended reader",
|
|
12
|
+
"Value",
|
|
13
|
+
"Prerequisites",
|
|
14
|
+
"Procedure",
|
|
15
|
+
"Limits",
|
|
16
|
+
"Next step",
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@dataclass(frozen=True)
|
|
21
|
+
class TaskPage:
|
|
22
|
+
title: str
|
|
23
|
+
intended_reader: str
|
|
24
|
+
value: str
|
|
25
|
+
prerequisites: tuple[str, ...]
|
|
26
|
+
procedure: tuple[str, ...]
|
|
27
|
+
limits: tuple[str, ...]
|
|
28
|
+
next_step: str
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _text(value: str, field: str) -> str:
|
|
32
|
+
if not value.strip():
|
|
33
|
+
raise ConfigurationError(f"task page {field} must be non-empty")
|
|
34
|
+
return value.strip()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _items(values: tuple[str, ...], field: str) -> tuple[str, ...]:
|
|
38
|
+
if not values or any(not value.strip() for value in values):
|
|
39
|
+
raise ConfigurationError(f"task page {field} must contain non-empty items")
|
|
40
|
+
return tuple(value.strip() for value in values)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def render_task_markdown(page: TaskPage) -> str:
|
|
44
|
+
"""Render a task page only when every required reader slot is populated."""
|
|
45
|
+
title = _text(page.title, "title")
|
|
46
|
+
intended_reader = _text(page.intended_reader, "intended reader")
|
|
47
|
+
value = _text(page.value, "value")
|
|
48
|
+
prerequisites = _items(page.prerequisites, "prerequisites")
|
|
49
|
+
procedure = _items(page.procedure, "procedure")
|
|
50
|
+
limits = _items(page.limits, "limits")
|
|
51
|
+
next_step = _text(page.next_step, "next step")
|
|
52
|
+
lines = [
|
|
53
|
+
f"# {title}",
|
|
54
|
+
"",
|
|
55
|
+
"## Intended reader",
|
|
56
|
+
"",
|
|
57
|
+
intended_reader,
|
|
58
|
+
"",
|
|
59
|
+
"## Value",
|
|
60
|
+
"",
|
|
61
|
+
value,
|
|
62
|
+
"",
|
|
63
|
+
"## Prerequisites",
|
|
64
|
+
"",
|
|
65
|
+
*(f"- {item}" for item in prerequisites),
|
|
66
|
+
"",
|
|
67
|
+
"## Procedure",
|
|
68
|
+
"",
|
|
69
|
+
*(f"{index}. {item}" for index, item in enumerate(procedure, start=1)),
|
|
70
|
+
"",
|
|
71
|
+
"## Limits",
|
|
72
|
+
"",
|
|
73
|
+
*(f"- {item}" for item in limits),
|
|
74
|
+
"",
|
|
75
|
+
"## Next step",
|
|
76
|
+
"",
|
|
77
|
+
next_step,
|
|
78
|
+
]
|
|
79
|
+
return "\n".join(lines) + "\n"
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def validate_task_markdown(content: str) -> None:
|
|
83
|
+
"""Reject task documentation that omits or reorders a required slot."""
|
|
84
|
+
observed = tuple(
|
|
85
|
+
line.removeprefix("## ").strip()
|
|
86
|
+
for line in content.splitlines()
|
|
87
|
+
if line.startswith("## ")
|
|
88
|
+
)
|
|
89
|
+
positions = []
|
|
90
|
+
for section in TASK_SECTIONS:
|
|
91
|
+
try:
|
|
92
|
+
positions.append(observed.index(section))
|
|
93
|
+
except ValueError as exc:
|
|
94
|
+
raise ConfigurationError(f"task page is missing section: {section}") from exc
|
|
95
|
+
if positions != sorted(positions):
|
|
96
|
+
raise ConfigurationError("task page sections are out of order")
|