Skip to content

docs: S23.12 generate relationship diagrams on API pages#619

Merged
DavidCozens merged 3 commits into
mainfrom
docs/relationship-diagrams
Jul 14, 2026
Merged

docs: S23.12 generate relationship diagrams on API pages#619
DavidCozens merged 3 commits into
mainfrom
docs/relationship-diagrams

Conversation

@DavidCozens

@DavidCozens DavidCozens commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

Renders a post-it "realised by" class diagram at the top of every vtable role's API page, generated from code at docs-build time and injected via a MkDocs hook. Addresses the "show relationships" item from the doc-site first-impression backlog.

How it works

  • Extract (hooks/relationship_data.py) — the role → implementers graph comes straight from the headers: every implementer is a public factory returning struct SolidSyslog<Role>*. Package and the Null object are derived from the file path / name. Runs standalone (python hooks/relationship_data.py) to dump the graph.
  • Render (hooks/relationship_render.py) — a self-contained inline SVG in the post-it kit's hand-drawn style. Simple, followable rules for the general case:
    • interface top-centre; a CASE-tool generalisation tree with the hand-drawn hollow realises triangle;
    • ≤4 backends → one row; ≥5 → two staggered rows (bottom offset half a pitch so its droppers thread the top row's gaps);
    • font scales to fit the longest backend name (worst case is MbedTlsHmacSha256Policy, 23 chars);
    • Null → grey; a small override marks decorator backends that wrap an inner instance of their own role (Stream's TLS pair) with the pink "wraps" tab.
  • Inject (hooks/relationship_diagrams.py) — an on_page_markdown hook prepends the diagram onto each role's base page (the consumer dispatch header where there is one, else the vtable Definition — e.g. SecurityPolicy). Styles are id-scoped so nothing leaks into the page; every sticky links to its own API page.

Covers all 13 vtable roles (2–7 backends each) with no per-role hand-authoring. The kit's realises marker (postit-defs.svg) is upgraded from an open chevron to the hand-drawn hollow triangle.

Verified

mkdocs build --strict passes. Rendered and reviewed all 13 roles on the local server — big/small, one-/two-row, the no-Null role (Address), and the Definition-page fallback (SecurityPolicy).

Follow-up (not in scope)

The already-committed post-it diagrams (architecture, storage, sl1/2/3) still inline the old chevron marker and want re-inlining now the kit uses the triangle.

Closes #618

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added automatically generated “realised by” relationship diagrams to selected API documentation pages.
    • Diagrams include interface implementations, links to backends, and markers for null implementations, with support for wrapping callouts.
    • Diagram layout adapts based on the number of implementations for improved readability.
  • Documentation
    • Relationship diagrams are now embedded directly into the generated API documentation during the build process.

Render a post-it "realised by" class diagram at the top of each vtable role's
API page, generated from code at docs-build time.

- relationship_data.py: extract the role -> implementers graph from the headers
  (every implementer is a public factory returning struct SolidSyslog<Role>*);
  derive each backend's package and the Null object. Runs standalone to dump the
  graph.
- relationship_render.py: render a self-contained inline SVG in the post-it kit
  style — interface top-centre, a generalisation tree with the hand-drawn hollow
  realises triangle, backends beneath (one row for <=4, two staggered rows for
  >=5), font scaled to fit the longest name, Null grey, a small override for the
  decorator backends that wrap their own role (Stream's TLS pair).
- relationship_diagrams.py: MkDocs on_page_markdown hook that injects the diagram
  onto each role's base page (dispatch header, else the vtable Definition). Every
  sticky links to its API page.
- postit-defs.svg: the kit's realises marker is now a hand-drawn hollow triangle
  (closed, slightly bowed) rather than an open chevron.
- mkdocs.yml: register the hook.

Covers all 13 vtable roles, generated from code — no per-role hand-authoring.

Closes #618
@github-actions

Copy link
Copy Markdown
Contributor

☀️   Quality Summary

   🚦   build-linux-gcc: 100% successful (✔️ 1522 passed)
   🚦   build-freertos-host-tdd-plustcp: 100% successful (✔️ 1873 passed)
   🚦   build-linux-clang: 100% successful (✔️ 1453 passed)
   🚦   sanitize-linux-gcc: 100% successful (✔️ 1453 passed)
   🚦   integration-linux-openssl: 100% successful (✔️ 16 passed)
   🚦   integration-linux-mbedtls: 100% successful (✔️ 14 passed)
   🚦   integration-windows-openssl: 100% successful (✔️ 16 passed)
   🚦   bdd-linux-syslog-ng: 94% successful (✔️ 49 passed, 🙈 3 skipped)
   🚦   bdd-windows-otel: 88% successful (✔️ 46 passed, 🙈 6 skipped)
   🚦   bdd-freertos-qemu-plustcp: 87% successful (✔️ 45 passed, 🙈 7 skipped)
   🚦   bdd-freertos-qemu-lwip: 87% successful (✔️ 45 passed, 🙈 7 skipped)
   🚦   build-windows-msvc: 100% successful (✔️ 1298 passed)
   🚦   build-linux-tunable-override: 100% successful (✔️ 1453 passed)
   ⚠️   Clang-Tidy: No warnings
   ⚠️   CPPCheck: No warnings


Created by Quality Monitor v1.14.0 (#f3859fd). More details are shown in the GitHub Checks Result.

@DavidCozens

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 67c2c3ad-509e-4574-8da9-13133cebb9de

📥 Commits

Reviewing files that changed from the base of the PR and between 127a3cd and 8ed4857.

📒 Files selected for processing (2)
  • hooks/relationship_render.py
  • mkdocs.yml

Walkthrough

Changes

The change adds build-time extraction of vtable role relationships, inline SVG rendering for interface and backend links, and a MkDocs hook that prepends diagrams to matching API pages.

Relationship diagrams

Layer / File(s) Summary
Vtable relationship graph extraction
hooks/relationship_data.py
Scans interface headers, extracts factory relationships, derives package and page metadata, marks Null implementations, and sorts the resulting graph deterministically.
Inline SVG relationship rendering
hooks/relationship_render.py
Generates one- or two-row linked SVG diagrams with scaled typography, Null styling, connector paths, and wrapper annotations.
MkDocs hook integration
hooks/relationship_diagrams.py, mkdocs.yml
Registers the build hook, caches extracted mappings by repository root, and prepends diagrams to matching api/*_8h.md pages.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant MkDocs
  participant relationship_diagrams
  participant relationship_data
  participant relationship_render
  participant APIPage

  MkDocs->>relationship_diagrams: process page Markdown
  relationship_diagrams->>relationship_data: build_graph(repository root)
  relationship_data-->>relationship_diagrams: return role relationship graph
  relationship_diagrams->>relationship_render: render_svg(role, info)
  relationship_render-->>relationship_diagrams: return inline SVG
  relationship_diagrams->>APIPage: prepend diagram for matching API page
  relationship_diagrams-->>MkDocs: return updated Markdown
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed Conventional-commit title is concise and matches the docs-only diagram generation change.
Description check ✅ Passed The body covers purpose, implementation, verification, and affected areas, matching the template intent.
Linked Issues check ✅ Passed The change meets #618: data extraction, SVG rendering, MkDocs injection, layout rules, links, and 13-role coverage are all present.
Out of Scope Changes check ✅ Passed No clear unrelated code paths are introduced; the link-prefix fix and hook wiring support the documented diagram feature.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch docs/relationship-diagrams

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@hooks/relationship_render.py`:
- Line 14: Replace the hard-coded BASE_URL used by the relationship SVG link
generation with MkDocs’ configured site URL or a page-relative URL helper,
ensuring links remain valid under mkdocs serve and alternate deployment
prefixes. Update the URL construction in the relationship rendering logic that
uses BASE_URL, including the node links near the referenced locations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9bb41e6f-fe47-4a01-a320-a140cfe474d0

📥 Commits

Reviewing files that changed from the base of the PR and between ed5ffeb and 127a3cd.

⛔ Files ignored due to path filters (1)
  • docs/assets/postit/postit-defs.svg is excluded by !**/*.svg, !**/*.svg, !docs/assets/**
📒 Files selected for processing (4)
  • hooks/relationship_data.py
  • hooks/relationship_diagrams.py
  • hooks/relationship_render.py
  • mkdocs.yml

Comment thread hooks/relationship_render.py Outdated
CodeRabbit: BASE_URL hard-coded the /solid-syslog/ prefix, so the diagram's
node links would break under `mkdocs serve` or any other deployment prefix.
Diagrams are always injected on an api/<name>_8h/ page, so a sibling API page
is one level up — use "../<page>/". Verified the built Stream page now emits
href="../SolidSyslogPosixTcpStream_8h/" and strict build stays green.
@github-actions

Copy link
Copy Markdown
Contributor

☀️   Quality Summary

   🚦   build-linux-gcc: 100% successful (✔️ 1522 passed)
   🚦   build-freertos-host-tdd-plustcp: 100% successful (✔️ 1873 passed)
   🚦   build-linux-clang: 100% successful (✔️ 1453 passed)
   🚦   sanitize-linux-gcc: 100% successful (✔️ 1453 passed)
   🚦   integration-linux-openssl: 100% successful (✔️ 16 passed)
   🚦   integration-linux-mbedtls: 100% successful (✔️ 14 passed)
   🚦   integration-windows-openssl: 100% successful (✔️ 16 passed)
   🚦   bdd-linux-syslog-ng: 94% successful (✔️ 49 passed, 🙈 3 skipped)
   🚦   bdd-windows-otel: 88% successful (✔️ 46 passed, 🙈 6 skipped)
   🚦   bdd-freertos-qemu-plustcp: 87% successful (✔️ 45 passed, 🙈 7 skipped)
   🚦   bdd-freertos-qemu-lwip: 87% successful (✔️ 45 passed, 🙈 7 skipped)
   🚦   build-windows-msvc: 100% successful (✔️ 1298 passed)
   🚦   build-linux-tunable-override: 100% successful (✔️ 1453 passed)
   ⚠️   Clang-Tidy: No warnings
   ⚠️   CPPCheck: No warnings


Created by Quality Monitor v1.14.0 (#f3859fd). More details are shown in the GitHub Checks Result.

@DavidCozens
DavidCozens merged commit 399e25d into main Jul 14, 2026
30 checks passed
@DavidCozens
DavidCozens deleted the docs/relationship-diagrams branch July 14, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

S23.12: Generate relationship diagrams on API pages

1 participant