Skip to content

Docs: let the docs generator import the badges that generated pages render - #131704

Merged
Blargian merged 11 commits into
ClickHouse:masterfrom
groeneai:docs/generator-badge-imports
Nov 17, 2026
Merged

Blargian merged 11 commits into
ClickHouse:masterfrom
groeneai:docs/generator-badge-imports

Conversation

@groeneai

@groeneai groeneai commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #131679
Related: #130905

Changelog category (leave one):

  • Documentation (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

The docs generator adds the imports of the status badges (<ExperimentalBadge/>, <CloudNotSupportedBadge/>, ...) that a generated reference page renders, so the documentation in the source registrations no longer carries MDX import lines.

Description

As asked in #131679 (comment).

Stacked on #130905 (itself based on #130608), which converts the remaining @theme/badges imports into the lines deleted here: merge both first; until then this diff also shows their commits.

Change:

  • replace_between_markers in autogenerate_docs.py, which places every generated region, now prepends import { XBadge } from "/snippets/components/XBadge/XBadge.jsx"; at the start of the region for each *Badge tag the new content renders and the resulting page does not import yet. Pages that import a badge above the region (function category pages) and doc strings that still carry an import get no duplicate. The split settings pages keep their own import logic.
  • The 57 badge imports are deleted from 44 doc strings in 36 src/ files, so system.documentation no longer shows them. The terminal help and the /docs page already dropped them; their output is unchanged.
  • Tests 04415 and 05023 asserted those imports and are retargeted; the two dictionary page self-tests now compare through replace_between_markers.

Validation: full --write runs of the old generator with the old binary and of the new one with the new binary leave 26,348 of 26,358 docs files byte-identical. Differences: 6 pages drop 12 imports of badges they never render (MergeTree; s3, azureBlobStorage, hdfs, url, file), 3 pages order their imports by first use (YTsaurus engine, CODEC, CREATE DICTIONARY), and beta-and-experimental-features.mdx reorders rows, which also happens between two runs of the old generator. Every generated page imports each badge it renders exactly once.


Workflow [PR]
Sync PR [sync-upstream/pr/131704]

Version info

  • Merged into: 26.11.1.2511-master (included in 26.11 and later)

groeneai and others added 10 commits November 10, 2026 19:57
The format page generator (`format_generators` in
`ci/jobs/scripts/docs/autogenerate/autogenerate_docs.py`) discovers pages
only through the matched rows of `docs/_migration/slug-map.csv`. Neither
`reference/formats/Vortex.mdx` nor `reference/formats/SQLite.mdx` had a
row, so the nightly docs job never regenerated them and `Vortex.mdx` still
described the `String` mapping from before ClickHouse#130234 (written as `Binary`,
no `output_format_vortex_string_as_string` row).

Add the two rows in the shape of the Puffin rows and regenerate both pages
with the generator (`--write --only format:Vortex` / `format:SQLite`).
The SQLite page change is the generator's link rewrite of the database
engine link to its current path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The reference docs generator found its destination pages and resolved
legacy links through `docs/_migration/slug-map.csv`, a snapshot of the
Docusaurus to Mintlify migration. Pages added or moved since then were
silently skipped (`Vortex`, `SQLite`) or linked through stale routes.

- Every generator names its Mintlify page (`dest`) and the page's former
  Docusaurus path (`source_docu`, which relative links in the source
  registrations are written against).
- The eight page families discover their pages by walking their
  `reference/` directory, as database engines already did.
- The Markdown to MDX transforms move next to the generator as
  `mintlify_transform.py`. Only the transforms that some registration can
  trigger are kept; the migration driver, its per-page overrides and the
  slug map reader are dropped.
- Legacy links resolve through the docs tree plus the site redirect table
  `docs/_site/redirects.json`.

A full regeneration with the old and the new generator writes the same
page set and the same content, except one link in `ODBCDriver2.mdx`: the
ODBC page moved to `concepts/features/interfaces/odbc/index.mdx`, which
the stale slug-map row hid. The regenerated page is included.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Nothing reads it any more: the reference docs generator discovers its
pages from the `reference/` directories and resolves legacy links through
`docs/_site/redirects.json`. Drop the folder (slug map, alias table,
one-shot migration scripts) and the exclusions that only existed for it
in `navigation_check.py`, `lychee.toml` and the docs README.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The source registrations are about to carry Mintlify `<Accordion title="...">`
sections instead of `<details><summary>`. The `/docs` page sanitizer drops any
unknown element together with its subtree, so `uniq`'s "Implementation
details" would disappear there: map an own-line `<Accordion>` onto the
allowlisted `<details>`/`<summary>` pair (with blank lines so the Markdown
inside is still parsed). The terminal `help` renderer treats `<Accordion>`
like `<Card>` (the title is kept as a bold line) and drops `<Frame>` wrappers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The docs generator still ran every generated body through the
Docusaurus-to-Mintlify transform, which rewrote 85 of 516 pages on every run
(`@theme/` imports, `:::` admonitions, `<details>`, `<TabItem>`, `<iframe>`,
`highlight-*` comments, HTML comments and pre-Mintlify links). Write the
transform's output directly in the doc strings and in the generator's
settings SQL, so the generated pages no longer depend on the transform and
`system.documentation` carries the same syntax as the website.

The conversion is the transform's own output for each string (measured per
page with the generator in check mode; nothing is left for it to change except
the leading `# Title` of full-page bodies and the blank-line collapse, which
the generator keeps), with four deliberate differences:
- the titled note of `arrayCount` uses `<Note title="...">`, the convention of
  the already converted sources (the transform gave an `<Info>` with a bold line);
- the six `<!-- -->` lines that only separated a list or a code block from the
  next code block are deleted (CommonMark already ends the list at the blank
  line, and `{/* */}` would show literally in `system.documentation`);
- the two `...WithWWW` descriptions of `cutToFirstSignificantSubdomainCustom*`
  get their missing closing fence (it swallowed the next section on the page);
- the inline code `<!-- -->` in `extractTextFromHTML` stays as is (the
  transform corrupted it to `{/* */}`).
Also converted: the untyped `:::` of `geohashEncode`, the `:::note` of the
`Freeform` format and the relative `.md` link of `Nested`, which no generated
page reaches yet.

A new test checks that no description in `system.documentation` uses `:::`
admonitions, `@theme/` imports, `highlight-*` comments or `.md` links. The
corpus checks of `04415` and `04417` follow the converted descriptions: the
`TimeSeries` badge is a named import now, and `uniq` no longer carries a raw
`<details>` block (`MergeTree` still does).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The source registrations and the generator's SQL templates are written in
Mintlify MDX now, so the Docusaurus-to-Mintlify body transform no longer
changes any generated page. Remove it, together with the link lookups and
the former Docusaurus paths (`source_docu`, `legacy_page`) that only fed it.

Two steps of page assembly stay in the generator, in `page_body`: the leading
`# Title` of a full-page description is dropped (Mintlify renders the page
title, and `system.documentation` needs the H1 to recognize the description
as a full page), and blank-line runs of the SQL output are collapsed. The
generator key `full_transform` becomes `full_page`; the dictionary page
self-tests compare against `page_body` instead of the transform.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts:
- docs/_migration/migrate.py, docs/_migration/slug-map.csv: master
  modified them; this branch deletes docs/_migration (moved to the
  generator in ClickHouse#130608, removed here), so they stay deleted.
- ci/jobs/scripts/docs/autogenerate/test_session_settings_split.py:
  master added a `migrate.rewrite_links` fenced-link check next to the
  `migrate.transform_imports` checks this branch already removed with
  the transform; kept this branch's side.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A Mintlify page must import every badge it renders. `replace_between_markers`
wrote the generated content verbatim, so the only place such an import could
come from was the documentation string itself: 57 `import { XBadge } ...`
lines in 44 descriptions, 12 of them for badges the page never renders, all
visible in `system.documentation`.

`replace_between_markers`, the placement point of every marker family and
of the statement pages, now prepends at the start of the region one
`import { XBadge } from "/snippets/components/XBadge/XBadge.jsx";` per
`*Badge` tag the new content renders that the resulting page does not import
yet. The old region is not consulted (it holds the previous generation's
imports); the text outside the region and the new content are, so function
category pages that import their badges above the region, and doc strings
that still carry an import, get no duplicate. Imports follow first use. The
split settings pages keep their own derivation.

Remove the badge imports (and the blank line after each group) from the doc
strings. Retarget 04415 (TimeSeries renders `<PrivatePreviewBadge/>` without
importing it) and 05023 (full-page detection past an MDX import: the polygon
layout's snippet import). The two dictionary page self-tests now compare
through `replace_between_markers`, so they model the inserted imports.

Full `--write` A/B (old script + old binary vs new script + new binary):
26,348 of 26,358 docs files byte-identical; 6 pages drop the 12 unused
imports, 3 pages reorder imports by first use, and
`beta-and-experimental-features.mdx` reorders rows, which also happens
between two runs of the old generator.

Related: ClickHouse#131679

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mintlify

mintlify Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit d7f00f1.

Approve preview

@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 2 findings), plus my own review (3 nits). The review covered this commit together with the stacked #130905 and #130608, with only the docs/_migration deletions left out to fit the size limit.

# Sev Finding Verdict Evidence / action
1 ⚠️ No test fails if a doc string imports a badge again, or if a page imports one twice DISAGREE A leftover doc-string import is harmless (new generator on the old sources: all 26,358 files byte-identical); dropping the "already imported" filter double-binds badges on other-functions.mdx and iceberg.mdx in the full A/B. No tests for docs tooling (#119766).
2 💡 test_statement_generators.py passes the removed lk argument DISAGREE From #130905, not this PR.
3 💡 04415's corpus check now only requires the badge tag AGREE Noted, not blocking: no doc string imports a badge any more; the test still pins the import-handling code.
4 💡 A second import regex next to IMPORT_RE / NAMED_IMPORT_RE NOTED The existing ones match single-symbol imports only, too narrow for the "already imported" check.
5 💡 Generator-owned settings SQL keeps its badge imports NOTED Not source registrations; the split settings path is unchanged, as the description says.

Severity: ❌ blocker / ⚠️ major / 💡 nit. DISAGREE verdicts carry recorded evidence and are terminal per finding.

Session id: cron:clickhouse-review-slot-10:20261114-225202

@groeneai

Copy link
Copy Markdown
Collaborator Author
Pre-PR validation gate (click to expand)
# Question Answer
a Deterministic repro? Not a failure but a deterministic property: with the old binary, 44 descriptions in system.documentation carry 57 badge import lines and the generated pages take their imports from there; with the new binary there are 0 and the generator inserts them.
b Root cause explained? replace_between_markers wrote the generated content verbatim and never derived an import, so a page could only import a badge if the doc string itself declared it.
c Fix matches root cause? Yes: the import is derived at the single placement point that every marker family and statement page goes through, instead of being authored in each registration.
d Test intent preserved / new tests added? No test of the generator itself (docs/CI tooling); validated locally. 04415 still checks a corpus entity that renders <PrivatePreviewBadge/>; 05023 still checks full-page detection past an MDX import (now the polygon layout's snippet import). The two dictionary page self-tests now model the insertion.
e Both directions demonstrated? Old 04415/05023 fail on the new binary exactly at the import assertions and pass on the old one; the edited ones pass on both, 100/100 randomized runs. Generator mutations (consult the old region, drop the already-imported filter, no insertion) each break the page invariant below.
f Fix is general across code paths? All callers of replace_between_markers (functions, aggregate/window functions, engines, data types, formats, table functions, dictionary sources/layouts, statements). Split settings pages derive their imports separately and are byte-identical before/after.
g Fix generalizes across inputs (params/datatypes/wrappers)? All 8 badges in use; badges imported above the region (no duplicate); content that still carries an import (new generator with the old binary: pages byte-identical to the old generator); pages without badges unchanged; several badges ordered by first use.
h Backward compatible? (maintainer-approved exception only) Docs tooling and doc strings only, no setting. A doc string that still imports a badge stays valid.
i Invariants and contracts preserved? Every generated page imports each badge it renders exactly once: checked over all 1317 English pages with generated regions, before and after.

Session id: cron:clickhouse-impl-slot-6:20261114-221700

@clickhouse-gh

clickhouse-gh Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [d7f00f1]

Summary: ✅


AI Review

Summary

The PR moves badge imports from embedded documentation into the docs generator; its stacked changes also remove the migration tooling and convert source documentation to Mintlify syntax. No actionable findings at d7f00f1aff17802a67fbe65ad6fb851a070dc3d3.

Consumers reviewed:

  • Reference and statement page generators insert missing badge imports through replace_between_markers.
  • Split settings pages retain their separate component-import handling.
  • system.documentation still recognizes full-page descriptions after imports are removed.
  • Terminal help and browser /docs render badges directly from their tags and handle the converted disclosure components.

Local validation passed for 14 dictionary-source pages, 12 dictionary-layout pages, settings splitting and routing, and focused badge-import checks across 1,313 marked reference pages. Page discovery retains all previously generated marked pages. The fetched CI reports contain no failed tests.

Final Verdict

Status: ✅ Approve

@clickhouse-gh clickhouse-gh Bot added pr-documentation Documentation PRs for the specific code PR can be tested Allows running workflows for external contributors manual approve Manual approve required to run CI comp-documentation Documentation (docs, examples, READMEs). labels Nov 14, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

CI finish ledger - 1ee1b48

Every failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
whose fixing-PR link will be posted here when it opens. Only CH Inc sync is exempt.

Check / test Reason Owner / fixing PR
Docs check (Mintlify) / No direct edits to generated or read-only docs inherited from the stacked #130608: it intentionally regenerates the AUTOGENERATED regions of ODBCDriver2.mdx, SQLite.mdx and Vortex.mdx, which stay in this branch's diff until it merges; the guard accepts that only with the pr-autogenerated-docs label, which #130608 carries. This PR's own commit does not touch those files #130608 (mine, open)
Mergeable Check, PR praktika rollups of the row above #130608 (the owner above)
Sync - CH Inc sync (private, not actionable by me)

CIDB has no other FAIL or ERROR row on this head.

Session id: cron:our-pr-ci-monitor:20261115-043013

@Blargian Blargian added the pr-autogenerated-docs PR that regenerates docs artifacts from source; exempt from the autogenerated-region edit guard label Nov 16, 2026
Resolve the `ParserSystemQuery.cpp` conflict while preserving generator-managed badge imports.

ClickHouse#131704

@clickhouse-gh clickhouse-gh 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.

AI review approves this commit, see the AI Review comment.

@clickhouse-gh

clickhouse-gh Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing d7f00f1af with master 7074838a9 (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Compile time of recompiled translation units

100 translation units recompiled, 815 s compile time in total, 100 of them have a recent master baseline.

Job report

@Blargian Blargian self-assigned this Nov 16, 2026
@Blargian
Blargian enabled auto-merge November 16, 2026 16:04
@Blargian
Blargian added this pull request to the merge queue Nov 16, 2026
Merged via the queue into ClickHouse:master with commit 5327cf5 Nov 17, 2026
193 checks passed
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 17, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Nov 18, 2026
The new reference pages were empty AUTOGENERATED stubs that the nightly
docs regeneration fills, so deploying this PR before that run would
publish blank pages (asked in
ClickHouse#131672 (comment)).

Fill the generated regions of `backup.mdx`, `restore.mdx` and
`alter/unlock-snapshot.mdx`, plus the new `UNLOCK SNAPSHOT` row of the
`ALTER` overview table, with the output of master's generator
(`autogenerate_docs.py --only 'statement:'`) run against a binary built
from this branch. The PR carries the `pr-autogenerated-docs` label.

Drop the explicit badge imports from the `BACKUP` and
`ALTER TABLE ... UNLOCK SNAPSHOT` descriptions: since ClickHouse#131704 the
generator adds the imports of the badges a page renders, which is where
the committed pages get them from.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-documentation Documentation (docs, examples, READMEs). manual approve Manual approve required to run CI pr-autogenerated-docs PR that regenerates docs artifacts from source; exempt from the autogenerated-region edit guard pr-documentation Documentation PRs for the specific code PR pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants