Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for generating stable, in-page anchor permalinks for legacy printer section headers by emitting custom header IDs (e.g. ### Title {#title}), and wires a new docOptions.sectionHeaderId / --noSectionId toggle through core, CLI, and integrations.
Changes:
- Generate section header custom IDs and use them to build non-broken
#<id>links inprinter-legacy. - Add
sectionHeaderIdoption to types/config plumbing and propagate it fromdocOptionsinto printer options. - Add/adjust unit tests and update documentation for the new option and CLI flag.
Reviewed changes
Copilot reviewed 21 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/types/src/printer.d.ts | Adds sectionHeaderId to printer/type options and optional id on TypeLink. |
| packages/types/src/core.d.ts | Adds docOptions.sectionHeaderId and CLI noSectionId typings. |
| packages/printer-legacy/src/section.ts | Appends {#id} to section headers (when enabled) and uses generated link IDs. |
| packages/printer-legacy/src/printer.ts | Introduces sectionHeaderId init/config propagation into Printer.options. |
| packages/printer-legacy/src/link.ts | Adds fallback id generation and prints #<id> hash links when enabled. |
| packages/printer-legacy/src/const/options.ts | Enables sectionHeaderId: true by default in legacy printer defaults. |
| packages/core/src/generator.ts | Passes docOptions.sectionHeaderId into printer init options. |
| packages/core/src/config.ts | Adds sectionHeaderId resolution from config/CLI/defaults (but currently mis-handles noSectionId). |
| packages/cli/src/index.ts | Adds --noSectionId CLI option. |
| docs/settings.md | Documents docOptions.sectionHeaderId and the --noSectionId flag. |
| packages/printer-legacy/tests/unit/section.test.ts | Updates snapshots to include generated hash links and {#id} markers. |
| packages/printer-legacy/tests/unit/printer.test.ts | Updates expected default options to include sectionHeaderId: true. |
| packages/printer-legacy/tests/unit/link.test.ts | Adds coverage for disabling section IDs and updates link expectations to use #<id>. |
| packages/printer-legacy/tests/unit/graphql/operation.test.ts | Updates snapshots for argument links and {#id} markers. |
| packages/printer-legacy/tests/unit/graphql/object.test.ts | Updates snapshots for field links and {#id} markers. |
| packages/printer-legacy/tests/unit/graphql/interface.test.ts | Updates snapshots for field links and {#id} markers. |
| packages/printer-legacy/tests/unit/graphql/input.test.ts | Updates snapshots for field links and {#id} markers. |
| packages/printer-legacy/tests/unit/graphql/enum.test.ts | Updates snapshots for enum value links and {#id} markers. |
| packages/printer-legacy/tests/unit/graphql/directive.test.ts | Updates snapshots for directive argument links and {#id} markers. |
| packages/docusaurus/tests/unit/index.test.ts | Ensures docOptions.sectionHeaderId is forwarded through the Docusaurus plugin. |
| packages/core/tests/unit/generator.test.ts | Ensures docOptions.sectionHeaderId reaches printer options in generator flow. |
| packages/core/tests/unit/config.test.ts | Updates config expectations to include sectionHeaderId. |
| packages/cli/tests/unit/index.test.ts | Adds CLI option expectations for --noSectionId and forwarding coverage. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Grégory Heitz <324670+edno@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Grégory Heitz <324670+edno@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Grégory Heitz <324670+edno@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Grégory Heitz <324670+edno@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Grégory Heitz <324670+edno@users.noreply.github.com>
|
|
|
|
|
|
|
|
|



Description
This PR add supporrt for custom section header IDs, eg
### InputParam \{#input-param\}to support #2713.The notation is supported by default by Docusaurus (not documented), and it should be compatible with any Remark based Markdown parser using https://github.com/playfulprogramming/rehype-slug-custom-id.
To allow backward compatiblity, a new
docOptionsconfig flag has been createdsectionHeaderIdand set totrueby default (custom ID generated by default). When set tofalse, it disable the generation of custom id, and it can also be disabled using CLI flag--noSectionId.Checklist