mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
docs: api sub-entries should have / in urls. (#57593)
`@angular/animations/browser` => `api/animations/browser/xyz` PR Close #57593
This commit is contained in:
parent
2ad9609a8d
commit
466e21399f
2 changed files with 40 additions and 1 deletions
|
|
@ -0,0 +1,35 @@
|
|||
/*!
|
||||
* @license
|
||||
* Copyright Google LLC All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by an MIT-style license that can be
|
||||
* found in the LICENSE file at https://angular.dev/license
|
||||
*/
|
||||
|
||||
import {ApiManifestPackage} from '../interfaces/api-manifest';
|
||||
import {getApiUrl} from './manifest.helper';
|
||||
|
||||
describe('ManiferHelper', () => {
|
||||
describe('getApiUrl', () => {
|
||||
it('should return the correct URL for a given package and API name', () => {
|
||||
const packageEntry: ApiManifestPackage = {
|
||||
moduleName: '@angular/common',
|
||||
moduleLabel: 'common',
|
||||
normalizedModuleName: 'angular_common',
|
||||
entries: [],
|
||||
};
|
||||
const apiName = 'DatePipe';
|
||||
const result = getApiUrl(packageEntry, apiName);
|
||||
expect(result).toBe('api/common/DatePipe');
|
||||
|
||||
const packageEntry2: ApiManifestPackage = {
|
||||
moduleName: '@angular/animations/browser',
|
||||
moduleLabel: 'animations/browser',
|
||||
normalizedModuleName: 'angular_animations_browser',
|
||||
entries: [],
|
||||
};
|
||||
const result2 = getApiUrl(packageEntry2, apiName);
|
||||
expect(result2).toBe('api/animations/browser/DatePipe');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -58,7 +58,11 @@ export function getApiNavigationItems(): NavigationItem[] {
|
|||
}
|
||||
|
||||
export function getApiUrl(packageEntry: ApiManifestPackage, apiName: string): string {
|
||||
const packageName = packageEntry.normalizedModuleName.replace('angular_', '');
|
||||
const packageName = packageEntry.normalizedModuleName
|
||||
// packages like `angular_core` should be `core`
|
||||
// packages like `angular_animation_browser` should be `animation/browser`
|
||||
.replace('angular_', '')
|
||||
.replace('_', '/');
|
||||
return `${PagePrefix.API}/${packageName}/${apiName}`;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue