FE-1414: Support Python packages in the architecture docs - #9230
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
0404a2d to
0dde89b
Compare
0dde89b to
e9619cf
Compare
PR SummaryLow Risk Overview
The TypeScript-only extractor rejection is gone; the graph builder still cruises TypeScript packages only. Reviewed by Cursor Bugbot for commit c8e70a5. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Pull request overview
Adds Python package support to Petrinaut’s architecture documentation generator.
Changes:
- Extracts layers and roles from Python module docstrings.
- Registers the Python bindings and optimizer packages.
- Adds Python-aware diagrams and subprocess-boundary documentation.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
apps/petrinaut-opt/src/optimization_api.py |
Declares the optimizer layer. |
libs/@local/petrinaut-python/src/petrinaut/__init__.py |
Declares the bindings layer. |
libs/@local/petrinaut-arch-docs/architecture.config.ts |
Registers Python packages and ignored directories. |
libs/@local/petrinaut-arch-docs/src/scope.ts |
Selects source extensions by language. |
libs/@local/petrinaut-arch-docs/src/extract.ts |
Extracts architecture data from Python sources. |
libs/@local/petrinaut-arch-docs/src/tags.ts |
Adds Python docstring tag scanning. |
libs/@local/petrinaut-arch-docs/src/tags.test.ts |
Tests Python tag scanning. |
libs/@local/petrinaut-arch-docs/src/emit/d2.ts |
Adds colors for Python layers. |
libs/@local/petrinaut-arch-docs/src/emit/mdx.ts |
Clarifies Python import-edge limitations. |
libs/@local/petrinaut-arch-docs/content/optimizer/subprocess-boundary.mdx |
Documents the optimizer–CLI process boundary. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
e9619cf to
fa79bff
Compare
fa79bff to
d756009
Compare
d756009 to
8aa7b93
Compare
20a8f84 to
89f7cd1
Compare
89f7cd1 to
49329d4
Compare
49329d4 to
5c0751d
Compare
5c0751d to
0de26eb
Compare
The generator only accepted TypeScript packages; apps/petrinaut-opt and the new Python bindings could not be documented. The layer pipeline was already language-agnostic, so this teaches the two gates Python: source extensions are resolved per package language, and the tag scanner reads @layerRoot/@ROLE from triple-quoted docstrings (module docstrings are the Python analog of a file's doc comment; # comments are deliberately not scanned). The import graph still receives only TypeScript packages - Python layers render with no edges, and the generated edge-table caption says so. Registers @apps/petrinaut-opt (layer: optimizer) and @local/petrinaut-python (layer: bindings) with docstring declarations, gives both roots diagram colours, and adds an authored page on the optimizer-CLI subprocess boundary, which a static import graph cannot represent. Python import edges are FE-1415.
🌟 What is the purpose of this PR?
The architecture docs generator accepted only TypeScript packages, so
apps/petrinaut-optand the new@local/petrinaut-pythonbindings could not be documented. This PR adds Python support: layer pages, roles, and diagrams for Python packages, with@layerRoot/@roleread from module docstrings. Import edges for Python arrive in FE-1415 (#9265), further up this stack.In stack #9280, FE-1470 (#9278) sits below and FE-1443 (#9263) above.
🔗 Related links
🔍 What does this change?
Generator (
@local/petrinaut-arch-docs).pyfor Python, and the TypeScript-only check in the extractor is gone. The graph builder still receives only TypeScript packages, exactly as before.@layerRoot/@rolefrom the module docstring only, in both quote styles; a triple-quoted string elsewhere in the file is a value. The tag grammar, duplicate detection, and miscasing hints are shared across languages.__pycache__and.venvjoin the ignored directories. The overview page now states that the Python packages contribute no import edges yet.Registrations
@apps/petrinaut-optdeclares the root layeroptimizerinoptimization_api.py's docstring.@local/petrinaut-pythondeclares the root layerpython-bindingsin the package docstring.Authored content
content/optimizer/subprocess-boundary.mdx, attached tooptimizer, documents the optimizer-to-CLI process contract: the spawn handshake, the ownership split, isolation, and the bounded limits. It links thecli,python-bindings, andcli.runtimelayers and the CLI usage manual.Review fixes
r"""), with a test, so a raw docstring cannot silently drop a package's@layerRoot.Recordkeyed by the config's language enum, so adding an enum member fails to compile until it names its extensions. The single-usepythonSourceExtensionsexport was inlined.Pre-Merge Checklist 🚀
🚢 Has this modified a publishable library?
This PR:
📜 Does this require a change to the docs?
The changes in this PR:
🕸️ Does this require a change to the Turbo Graph?
The changes in this PR:
🛡 What tests cover this?
tags.test.tsgrows from 9 to 16 cases: module docstrings, single-quoted and prefixed docstrings, non-matches for#comments and JSDoc text inside strings, and duplicate and miscasing diagnostics in Python.lint:arch-docsvalidates the real registrations end to end, including full file coverage of both Python packages andattachToresolution.❓ How to test this?
yarn workspace @local/petrinaut-arch-docs lint:arch-docsturbo run dev --filter @apps/petrinaut-docsand open Architecture → optimizer / python-bindings; the boundary guide sits under the optimizer page.🤖 Generated with Claude Code