Skip to content

Commit c615bdc

Browse files
committed
docs(docs-infra): Improve support for @link within the jsdoc. (#60201)
PR Close #60201
1 parent 79c3374 commit c615bdc

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

adev/shared-docs/pipeline/api-gen/rendering/test/transforms/jsdoc-transforms.spec.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ describe('jsdoc transforms', () => {
6666
name: 'see',
6767
comment: '{@link https://angular.dev}',
6868
},
69+
{
70+
name: 'see',
71+
comment: '{@link /cli/build ng build}',
72+
},
73+
{
74+
name: 'see',
75+
comment: '{@link cli/build ng build}',
76+
},
77+
{
78+
name: 'see',
79+
comment: '{@link /ecosystem/rxjs-interop/output-interop Output Interop}',
80+
},
6981
],
7082
moduleName: 'test',
7183
});
@@ -117,5 +129,22 @@ describe('jsdoc transforms', () => {
117129
label: 'angular.dev',
118130
url: 'https://angular.dev',
119131
});
132+
133+
expect(entry.additionalLinks[10]).toEqual({
134+
label: 'ng build',
135+
url: '/cli/build',
136+
});
137+
138+
// TODO: in the future when all links are valid we would throw an error instead when not starting with a slash
139+
// Links should be absolute within adev (to support both next & stable site)
140+
expect(entry.additionalLinks[11]).toEqual({
141+
label: 'ng build',
142+
url: 'cli/build',
143+
});
144+
145+
expect(entry.additionalLinks[12]).toEqual({
146+
label: 'Output Interop',
147+
url: '/ecosystem/rxjs-interop/output-interop',
148+
});
120149
});
121150
});

adev/shared-docs/pipeline/api-gen/rendering/transforms/jsdoc-transforms.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,10 @@ function parseAtLink(link: string): {label: string; url: string} {
195195
let [rawSymbol, description] = link.split(/\s(.+)/);
196196
if (rawSymbol.startsWith('#')) {
197197
rawSymbol = rawSymbol.substring(1);
198-
} else if (rawSymbol.startsWith('http://') || rawSymbol.startsWith('https://')) {
198+
} else if (rawSymbol.includes('/')) {
199199
return {
200200
url: rawSymbol,
201-
label: rawSymbol.split('/').pop()!,
201+
label: description ?? rawSymbol.split('/').pop()!,
202202
};
203203
}
204204

packages/core/src/util/is_dev_mode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {global} from './global';
1313
*
1414
* By default, this is true, unless `enableProdMode` is invoked prior to calling this method or the
1515
* application is built using the Angular CLI with the `optimization` option.
16-
* @see {@link cli/build ng build}
16+
* @see {@link /cli/build ng build}
1717
*
1818
* @publicApi
1919
*/
@@ -31,7 +31,7 @@ export function isDevMode(): boolean {
3131
*
3232
* Using this method is discouraged as the Angular CLI will set production mode when using the
3333
* `optimization` option.
34-
* @see {@link cli/build ng build}
34+
* @see {@link /cli/build ng build}
3535
*
3636
* @publicApi
3737
*/

0 commit comments

Comments
 (0)