Skip to content

fix: preserve deprecation codes in table of contents#919

Open
MFA-G wants to merge 1 commit into
nodejs:mainfrom
MFA-G:fix/deprecation-code-toc
Open

fix: preserve deprecation codes in table of contents#919
MFA-G wants to merge 1 commit into
nodejs:mainfrom
MFA-G:fix/deprecation-code-toc

Conversation

@MFA-G

@MFA-G MFA-G commented Jul 18, 2026

Copy link
Copy Markdown

Description

On the deprecations page, sidebar/ToC labels are built by headingLabel in src/generators/jsx-ast/utils/buildBarProps.mjs, which strips any leading <something>: prefix (meant for prefixes like Class:). That rule also strips deprecation codes, so DEP0001: http.OutgoingMessage.prototype.flush renders in the ToC as just http.OutgoingMessage.prototype.flush, making it hard to locate a deprecation by its ID.

This PR adds a narrow exception: headings matching DEP\d+: keep their full text (backticks removed) as the label, so the deprecation code shows up in the ToC — matching the behavior of the legacy nodejs.org deprecations page.

Validation

  • New unit test in src/generators/jsx-ast/utils/__tests__/buildBarProps.test.mjs: DEP0001: \http.OutgoingMessage.prototype.flush`now yields the labelDEP0001: http.OutgoingMessage.prototype.flush`.
  • node --run test — 523 tests pass, 0 fail.
  • node --run lint — no errors (2 pre-existing warnings in src/generators/web/ui/hooks/useOrama.mjs, untouched by this PR).
  • node --run format:check — clean.

Related Issues

Fixes #917

Check List

  • I have read the Contributing Guidelines and made commit messages that follow the guideline.
  • I have run node --run test and all tests passed.
  • I have check code formatting with node --run format & node --run lint.
  • I've covered new added functionality with unit tests if necessary.

Signed-off-by: Fadhlan <fadhlanzap@gmail.com>
@MFA-G
MFA-G requested a review from a team as a code owner July 18, 2026 07:49
@vercel

vercel Bot commented Jul 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
api-docs-tooling Ready Ready Preview Jul 18, 2026 7:50am

Request Review

@cursor

cursor Bot commented Jul 18, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Small, targeted change to ToC label formatting with a dedicated regex branch and unit test; no auth, data, or API surface impact.

Overview
Fixes ToC/sidebar labels on the deprecations page so entries like DEP0001: http.OutgoingMessage.prototype.flush keep the deprecation ID instead of showing only the message after the colon.

headingLabel in buildBarProps.mjs previously stripped any leading prefix: (intended for labels such as Class:), which also removed DEP####: codes. The change adds an early branch for headings matching ^DEP\d+: that uses the full heading text with backticks removed, before the generic prefix strip runs.

A unit test covers the new label behavior; the changeset records a patch for @node-core/doc-kit.

Reviewed by Cursor Bugbot for commit e35d78c. Bugbot is set up for automated code reviews on this repo. Configure here.

// Remove any containing code blocks
.replace(/`/g, '')
// Remove any prefixes (i.e. 'Class:')
.replace(/^[^:]+:/, '')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can't we just modify this RegEx to exclude DEPXXXX?

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.

Show Dep Code in ToC

3 participants