Skip to content

Regenerate class diagrams from source and fix contribution guides - #812

Open
daniel-locatelli wants to merge 10 commits into
mainfrom
class-diagrams-2.2.0
Open

Regenerate class diagrams from source and fix contribution guides#812
daniel-locatelli wants to merge 10 commits into
mainfrom
class-diagrams-2.2.0

Conversation

@daniel-locatelli

@daniel-locatelli daniel-locatelli commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes the four pre-existing class diagrams (Elements, Connections, Fabrication, Errors) so they match the actual v2.2.0 code, and makes them reproducible:

  • The diagrams are generated with a pipeline maintained outside this repo at https://github.com/daniel-locatelli/compas_timber-class-diagrams: class bodies, inheritance and attributes are extracted from src/ with Python's ast (ground truth), while subsystem partitioning, prose and cross-class edges are curated in diagram_spec.py. Curated composition edges are asserted against the extracted attributes so they fail loudly when the code changes; see that repo's README for usage.
  • Regenerates docs/contribution/class_diagrams.md from that pipeline; the page header now states it is generated and must not be edited by hand.
  • Drops the Data base-class nodes (they carried no discriminating information — the prose states the convention and its exceptions instead).
  • Draws the constants classes (OrientationType, StepShapeType, TenonShapeType, AlignmentType, EdgePositionType, LimitationTopType) and MachiningLimits as explicit blocks with source-verified usage edges — previously the constants classes appeared in the diagrams only as attribute types, and MachiningLimits not at all. BTLxFromGeometryDefinition gains an instantiates edge to BTLxProcessing in place of the dropped Data link.
  • Per review: CutPlaneSpec / MiterPlaneSpec are left out of the Connections diagram while that mechanism is reworked in Add BTLx UserReferencePlane support, remove CutPlaneSpec/MiterPlaneSpec #803, and the Fabrication intro links the BTLx standard specification.
  • Fixes broken mermaid rendering on the published site via mkdocs.yml: the superfence formatter is switched from mermaid2's non-escaping fence_mermaid_custom to pymdownx.superfences.fence_code_format, because the non-escaping variant let the browser parse class-diagram stereotypes like <<abstract>> as HTML tags and render them as empty <>. (The panzoom enablement originally bundled here landed separately via Make mermaid class diagrams zoomable in docs #788; this branch has been rebased onto main accordingly.)
  • Rewrites the joints contribution guide to match the v2.2.0 Joint base-class API: corrects the JointTopology values (the old page misdescribed TOPO-X/TOPO-I and was missing TOPO_Y, TOPO_K and the plate topologies), replaces the outdated elements / restore_beams_from_keys() requirements with the automatic GUID restoration and the _set_unset_attributes() hook, documents check_elements_compatibility() as a classmethod, and makes the add_features example idempotent on re-run. This API is unchanged on current main, so the guide stays correct after the merge; the one thing to revisit for the next release is the example's manual remove-features-first step, which post-2.2.0 code supersedes with the new Joint.clear_features().

Docs-only change, no CHANGELOG entry ("no changelog" label).

Heads-up: post-2.2.0 hand-edits to the diagrams are superseded

main received hand-edits to class_diagrams.md documenting post-2.2.0 additions (e.g. CompositeJoint from the composite-joint work). This PR replaces the page with the generated 2.2.0 snapshot, so those entries are intentionally not included — the diagrams document the released version, and new classes will re-enter the diagrams when they are regenerated for the next release (the compare script in the pipeline repo reports any unplaced classes). Going forward the page should not be edited by hand; the header now says so.

Note for maintainers: updating the published 2.2.0 docs

The docs workflow only deploys the mkdocs site on version tags, so merging this PR does not update the live site by itself — the fixes would first appear with the next release tag. If we want the published "2.2.0 (latest)" docs to show the corrected diagrams before then, someone with push rights needs to run, from the merged main:

mike deploy 2.2.0 latest --push

This rewrites only the 2.2.0 folder on gh-pages (no git tag is created or moved).

🤖 Generated with Claude Code

@daniel-locatelli daniel-locatelli added the no changelog No changes to CHANGELOG.md required in this PR label Jul 27, 2026
daniel-locatelli and others added 8 commits July 27, 2026 14:36
Switch the mermaid superfence formatter from mermaid2's non-escaping
fence_mermaid_custom to pymdownx.superfences.fence_code_format. The
non-escaping variant let the browser parse class-diagram stereotypes
like <<abstract>> as HTML tags, rendering them as empty <> on the
published site. mermaid.js reads the element's text content, so
escaped entities arrive intact.

Also enable the panzoom plugin for zoomable diagrams (mirrors the
pending fix/zoomable-mermaid-diagrams PR; the plugin dependency is
installed in the build environment).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Deterministic extract -> curate -> render -> validate pipeline behind
docs/contribution/class_diagrams.md: extract_classes.py parses the
package with ast into graph.json; diagram_spec.py holds the curated
partitioning, prose and edges (composition edges are asserted against
the extracted attributes); gen_diagrams.py renders the doc;
validate_mermaid.py lints the mermaid blocks; compare_doc_to_graph.py
diffs any diagrams doc against the extracted graph to catch
hallucinated classes, edges or members.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Replace the hand-maintained diagrams with output generated by
scripts/docs_class_diagrams: an ast-based extractor produces a class
graph (bases, attributes with @Property getters folded in, method
signatures), and a generator renders it into subsystem-partitioned
mermaid blocks, so inheritance and members can no longer be invented
or drift.

Changes to the diagrams doc:
- Split the Connections subsystem into three diagrams (topology
  solving, beam joints, plate/panel joints) and add the previously
  undocumented solver machinery (JointTopology, ConnectionSolver,
  PlateConnectionSolver, solver results, Cluster).
- Split Fabrication into infrastructure and processings diagrams and
  add the parameter enums (OrientationType, StepShapeType, etc.),
  MachiningLimits, and a note on the *Proxy companion classes.
- Add Planning (nesting + assembly sequencing) and Structural
  subsystem sections, which were entirely undocumented.
- Correct members that didn't exist as public API (butt_plane_spec /
  back_plane_spec are constructor params stored privately; BTLxWriter
  private _create_* methods; PanelFeature.name/transformation) and
  suppress members redeclared from in-package bases.

Changes to the joints guide:
- Document all nine JointTopology values (TOPO_Y, TOPO_K,
  TOPO_EDGE_EDGE, TOPO_EDGE_FACE, TOPO_UNKNOWN were missing).
- Fix the check_elements_compatibility example: it is a classmethod
  receiving (elements, raise_error), not an instance method.
- Cross-link the class diagrams page.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The example omitted the remove-first step every shipped joint performs
(ButtJoint, LMiterJoint): process_joinery() may run repeatedly on the
same model (e.g. Grasshopper recompute), and without removing the
joint's previously registered features first, each run applies them
again. Also reassign self.features instead of extending, and expand the
note: element registration applies the feature, joint registration is
the undo record; blank extensions need no equivalent because they are
keyed by joint guid on the element.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The retroactive fix for 2.2.0 only corrects the diagrams that already
existed (Timber Element, Connections, Fabrication, Errors), restoring
the original one-diagram-per-subsystem layout. The Model Overview,
Planning and Structural diagrams and the Connections/Fabrication
sub-diagram splits move to docs/class-diagrams-additions for the next
release.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The title was accurate when the diagrams were authored (v1.0.x, where
every element inherited from TimberElement) but became misleading in
the 2.0 refactor, when Fastener and Panel were rebased directly onto
compas_model Element. The section documents the whole
compas_timber.elements package, so name it accordingly.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Drop the Data anchor and the legacy Feature classes (CutFeature,
DrillFeature, MillVolume, BrepSubtraction) from the Elements diagram:
they are neither Element subclasses nor connected to one, and the
legacy features are unused internally. They remain exported and are
now mentioned in prose only.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Data carried no information in the Connections diagram (every class
derives from it) and little in Fabrication; the prose now states the
convention and its exceptions instead. Orphan blocks (MachiningLimits,
the constants classes, BTLxFromGeometryDefinition) got usage edges
verified against the source, and the Connections/Fabrication intros
are split into short paragraphs. The page header now links to the
regeneration pipeline in scripts/docs_class_diagrams/.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Jul 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.64%. Comparing base (85bc4b6) to head (86cbd8d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #812      +/-   ##
==========================================
- Coverage   82.67%   82.64%   -0.04%     
==========================================
  Files          83       83              
  Lines       12005    12005              
==========================================
- Hits         9925     9921       -4     
- Misses       2080     2084       +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread docs/contribution/class_diagrams.md Outdated
Comment thread docs/contribution/class_diagrams.md Outdated
Comment thread scripts/docs_class_diagrams/README.md Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmh dunno if this suite of scripts should end up as part of compas timber. if it can be generalized, perhaps it's worth packaging this as some kind of a developer tool. otherwise, I would just remove it from here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, I removed the scripts and have them here. I've been thinking about how to keep the diagrams from drifting long-term. Ideally they would be generated as part of the docs CI. If you think that makes sense I can write it as an issue.

daniel-locatelli and others added 2 commits August 4, 2026 12:03
…BTLx standard, remove diagram pipeline from repo

- CutPlaneSpec/MiterPlaneSpec removed from the Connections diagram and prose
  (mechanism contested in #803); LMiterJoint's miter_plane attribute keeps its
  extracted type.
- Fabrication intro links the BTLx standard specification.
- The generation pipeline moves out of the repo to
  https://github.com/daniel-locatelli/compas_timber-class-diagrams; the page
  header no longer points at in-repo scripts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…its, union mkdocs.yml changes

# Conflicts:
#	docs/contribution/class_diagrams.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changelog No changes to CHANGELOG.md required in this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants