Skip to content

✨ section generate predefined anchor link#2733

Merged
edno merged 16 commits intomainfrom
feat/2713-fields-generate-predefined-anchor-link
Mar 3, 2026
Merged

✨ section generate predefined anchor link#2733
edno merged 16 commits intomainfrom
feat/2713-fields-generate-predefined-anchor-link

Conversation

@edno
Copy link
Copy Markdown
Member

@edno edno commented Mar 2, 2026

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 docOptions config flag has been created sectionHeaderId and set to true by default (custom ID generated by default). When set to false, it disable the generation of custom id, and it can also be disabled using CLI flag --noSectionId.

Checklist

  • My changes follow the contributing guidelines of this project.
  • I have performed a self-review of my code.
  • I have made corresponding changes to the documentation.
  • I have added tests that prove my fix is effective or that my changes work.
  • New and existing unit tests pass locally with my changes.

@edno edno linked an issue Mar 2, 2026 that may be closed by this pull request
@edno edno changed the title Feat/2713 fields generate predefined anchor link ✨ section generate predefined anchor link Mar 2, 2026
@edno edno marked this pull request as ready for review March 2, 2026 15:58
Copilot AI review requested due to automatic review settings March 2, 2026 15:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 in printer-legacy.
  • Add sectionHeaderId option to types/config plumbing and propagate it from docOptions into 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.

edno and others added 2 commits March 2, 2026 17:04
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Grégory Heitz <324670+edno@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 21 out of 23 changed files in this pull request and generated 2 comments.

edno and others added 4 commits March 2, 2026 17:16
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>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 21 out of 23 changed files in this pull request and generated 2 comments.

edno and others added 2 commits March 3, 2026 11:19
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Grégory Heitz <324670+edno@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 21 out of 23 changed files in this pull request and generated 3 comments.

edno and others added 2 commits March 3, 2026 11:52
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Grégory Heitz <324670+edno@users.noreply.github.com>
@edno edno requested a review from Copilot March 3, 2026 11:13
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 3, 2026

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 3, 2026

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 3, 2026

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 3, 2026

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 3, 2026

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 3, 2026

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 3, 2026

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 3, 2026

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 21 out of 23 changed files in this pull request and generated no new comments.

@edno edno enabled auto-merge (squash) March 3, 2026 11:26
@edno edno disabled auto-merge March 3, 2026 11:26
@edno edno merged commit 413226a into main Mar 3, 2026
37 checks passed
@edno edno deleted the feat/2713-fields-generate-predefined-anchor-link branch March 3, 2026 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Fields all generate a broken anchor link

2 participants