File tree Expand file tree Collapse file tree
src/generators/legacy-html Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ 'use strict' ;
2+
3+ // Matches deprecation headings (e.g., "DEP0001: some title") and captures
4+ // the deprecation code (e.g., "DEP0001") as the first group
5+ export const DEPRECATION_HEADING_REGEX = / ^ ( D E P \d + ) : / ;
Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ describe('createLegacySlugger', () => {
3838 } ) ;
3939
4040 describe ( 'deprecation headings' , ( ) => {
41- it ( 'returns the DEP code for deprecation headings in the deprecations doc ' , ( ) => {
41+ it ( 'returns the DEP code for a deprecation heading ' , ( ) => {
4242 const getLegacySlug = createLegacySlugger ( ) ;
4343 assert . strictEqual (
4444 getLegacySlug (
@@ -59,13 +59,5 @@ describe('createLegacySlugger', () => {
5959 'DEP0190'
6060 ) ;
6161 } ) ;
62-
63- it ( 'does not apply deprecation special-casing outside the deprecations doc' , ( ) => {
64- const getLegacySlug = createLegacySlugger ( ) ;
65- assert . notStrictEqual (
66- getLegacySlug ( 'DEP0190: some heading' , 'child_process' ) ,
67- 'DEP0190'
68- ) ;
69- } ) ;
7062 } ) ;
7163} ) ;
Original file line number Diff line number Diff line change 11'use strict' ;
22
3- // Matches headings in the deprecations API doc (e.g., "DEP0001: some title")
4- // and captures the deprecation code (e.g., "DEP0001") as the first group
5- const DEPRECATION_HEADING_REGEX = / ^ ( D E P \d + ) : / ;
3+ import { DEPRECATION_HEADING_REGEX } from '../constants.mjs' ;
64
75/**
86 * Creates a stateful slugger for legacy anchor links.
97 *
108 * Generates underscore-separated slugs in the form `{apiStem}_{text}`,
119 * appending `_{n}` for duplicates to preserve historical anchor compatibility.
1210 *
13- * For the deprecations API doc, headings matching the `DEP####:` pattern use
14- * just the deprecation code (e.g., `DEP0001`) as the anchor, matching the
15- * behavior of the old tooling and preserving existing external links.
11+ * Headings matching the `DEP####:` pattern return just the deprecation code
12+ * (e.g., `DEP0001`) as the anchor, matching the behavior of the old tooling
13+ * and preserving existing external links.
1614 *
1715 * @returns {(text: string, apiStem: string) => string }
1816 */
1917export const createLegacySlugger =
2018 ( counters = { } ) =>
2119 ( text , apiStem ) => {
22- const depMatch =
23- apiStem === 'deprecations' && DEPRECATION_HEADING_REGEX . exec ( text ) ;
20+ const depMatch = DEPRECATION_HEADING_REGEX . exec ( text ) ;
2421
2522 if ( depMatch ) {
2623 return depMatch [ 1 ] ;
You can’t perform that action at this time.
0 commit comments