2024-11-28 23:22:31 +00:00
|
|
|
/**
|
|
|
|
|
* @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
|
|
|
|
|
*/
|
|
|
|
|
|
2025-08-25 01:59:16 +00:00
|
|
|
import {getSymbolUrl as sharedGetSymbolUrl} from '../../shared/linking.mjs';
|
|
|
|
|
|
2024-08-20 23:52:41 +00:00
|
|
|
/**
|
|
|
|
|
* API pages are generated each package at a time.
|
2025-08-25 01:59:16 +00:00
|
|
|
* This allows us to use a global context to store the symbols and their corresponding module names.
|
2024-08-20 23:52:41 +00:00
|
|
|
*/
|
|
|
|
|
|
2025-08-25 01:59:16 +00:00
|
|
|
let symbols: Record<string, string> = {};
|
2024-08-20 23:52:41 +00:00
|
|
|
|
2024-08-31 02:31:27 +00:00
|
|
|
// This is used to store the currently processed symbol (usually a class or an interface)
|
|
|
|
|
let currentSymbol: string | undefined;
|
|
|
|
|
export function setCurrentSymbol(symbol: string): void {
|
|
|
|
|
currentSymbol = symbol;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-25 21:04:26 +00:00
|
|
|
/** Convert Record<string, string> to ApiEntries format */
|
|
|
|
|
export function getSymbolsAsApiEntries(): Record<string, {moduleName: string}> {
|
|
|
|
|
const result: Record<string, {moduleName: string}> = {};
|
|
|
|
|
|
|
|
|
|
for (const symbol in symbols) {
|
|
|
|
|
result[symbol] = {moduleName: symbols[symbol]};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
2025-09-01 21:21:21 +00:00
|
|
|
}
|
|
|
|
|
|
2024-08-31 02:31:27 +00:00
|
|
|
export function getCurrentSymbol(): string | undefined {
|
|
|
|
|
return currentSymbol;
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-25 01:59:16 +00:00
|
|
|
export function setSymbols(newSymbols: Record<string, string>): void {
|
|
|
|
|
symbols = newSymbols;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function getSymbolUrl(symbol: string): string | undefined {
|
2025-11-25 21:04:26 +00:00
|
|
|
return sharedGetSymbolUrl(symbol, getSymbolsAsApiEntries());
|
2025-08-25 01:59:16 +00:00
|
|
|
}
|
|
|
|
|
|
2025-03-04 18:14:08 +00:00
|
|
|
export function unknownSymbolMessage(link: string, symbol: string): string {
|
|
|
|
|
return `WARNING: {@link ${link}} is invalid, ${symbol} or ${currentSymbol}.${symbol} is unknown in this context`;
|
2024-08-20 23:52:41 +00:00
|
|
|
}
|