Skip to content

refactor: Strip site-specific framing from docgen templates#210

Merged
khvn26 merged 1 commit intomainfrom
feat/docgen-templates-header-partial
Apr 20, 2026
Merged

refactor: Strip site-specific framing from docgen templates#210
khvn26 merged 1 commit intomainfrom
feat/docgen-templates-header-partial

Conversation

@khvn26
Copy link
Copy Markdown
Member

@khvn26 khvn26 commented Apr 20, 2026

Contributes to #201

Strip both docgen-events.md and docgen-metrics.md down to pure catalogue data. Consumers of flagsmith docgen {events,metrics} previously got a full page with hard-coded framing — frontmatter, intro prose, and a section heading. The OpenTelemetry link in the events header turned out to be a relative URL that only resolved correctly when the events page happened to live where the library author had put it; any move in the consumer's docs tree silently broke it.

The templates now emit only the per-event / per-metric ### ... entries. Consumers supply their own frontmatter and intro — either by writing an MDX page that imports the generated fragment as a partial, or by concatenating a hand-maintained header before the docgen output in their build.

BREAKING CHANGE

Consumers of docgen events / docgen metrics must now supply their own page header. The generated file alone is no longer a publishable docs page.

For the MDX partial pattern, rename the output to an underscore-prefixed file (Docusaurus treats _foo.md as a non-routed partial) and import it from a hand-authored .mdx:

---
title: Events
sidebar_label: Events
sidebar_position: 30
---

import EventCatalogue from './_events-catalogue.md';

Your intro prose here, linking to your OTel docs at the right path for your site.

## Event catalogue

<EventCatalogue />

Then in your Makefile:

poetry run flagsmith docgen events > path/to/_events-catalogue.md

How did you test this code?

Regenerated the two snapshot fixtures (test_docgen__events__runs_expected.txt, test_docgen__metrics__runs_expected.txt) via pytest --snapshot-update, then ran the tests normally to confirm they pass.

Consumers of `flagsmith docgen {events,metrics}` previously got a page
with a hard-coded Flagsmith-shaped header — frontmatter, intro prose,
and a section heading. The opentelemetry link in the events header
turned out to be a relative URL that only resolved correctly when the
events page happened to live where the library author put it; moves in
the consumer's docs tree silently broke it.

Strip both templates to pure data (just the event / metric entries),
letting consumers own the page header via their own MDX or a concat
step. Regenerate snapshots.

BREAKING CHANGE: consumers of `docgen events` / `docgen metrics` must
now supply their own page header (frontmatter + intro) when wiring the
output into their docs site.

beep boop
@khvn26 khvn26 requested a review from a team as a code owner April 20, 2026 16:23
@khvn26 khvn26 requested review from gagantrivedi and removed request for a team April 20, 2026 16:23
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.26%. Comparing base (ae79cc7) to head (4cee526).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #210   +/-   ##
=======================================
  Coverage   97.26%   97.26%           
=======================================
  Files         104      104           
  Lines        4459     4459           
=======================================
  Hits         4337     4337           
  Misses        122      122           

☔ View full report in Codecov by Sentry.
📢 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.

khvn26 added a commit to Flagsmith/flagsmith that referenced this pull request Apr 20, 2026
…artial

The flagsmith-common docgen templates used to emit a full Docusaurus
page — frontmatter, intro prose, a section heading, and the catalogue
entries. The intro links and framing were necessarily site-specific,
which meant upstream owned URLs that only made sense for one consumer
and silently broke on docs-tree moves (see Flagsmith/flagsmith-common#210).

Switch to an MDX + partial pattern. The `docgen events` and
`docgen metrics` commands now write only the catalogue entries to
underscore-prefixed partial files (`_events-catalogue.md`,
`_metrics-catalogue.md`) — Docusaurus ignores these from routing. The
page shell moves to hand-authored `events.mdx` and `metrics.mdx` that
import the partials, owning the frontmatter, intro prose, and internal
links.

Pins flagsmith-common to the PR branch temporarily; swap for a version
pin once that lands and releases.

beep boop
Copy link
Copy Markdown
Contributor

@emyller emyller left a comment

Choose a reason for hiding this comment

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

🚀

@khvn26 khvn26 merged commit d45af91 into main Apr 20, 2026
4 checks passed
khvn26 added a commit to Flagsmith/flagsmith that referenced this pull request Apr 20, 2026
Switch back from the PR branch pin now that Flagsmith/flagsmith-common#210
(pure-data docgen templates) has been released.

beep boop
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.

3 participants