2024-08-02 16:42:23 +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
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import {render} from 'preact-render-to-string';
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
isClassEntry,
|
|
|
|
|
isCliEntry,
|
|
|
|
|
isConstantEntry,
|
2024-08-20 23:46:30 +00:00
|
|
|
isDecoratorEntry,
|
2024-08-02 16:42:23 +00:00
|
|
|
isEnumEntry,
|
|
|
|
|
isFunctionEntry,
|
|
|
|
|
isInitializerApiFunctionEntry,
|
|
|
|
|
isInterfaceEntry,
|
|
|
|
|
isTypeAliasEntry,
|
2025-12-10 18:03:54 +00:00
|
|
|
isBlockEntry,
|
2025-05-06 20:59:30 +00:00
|
|
|
} from './entities/categorization.mjs';
|
2025-10-20 12:40:23 +00:00
|
|
|
import {CliCommandRenderable, DocEntryRenderable} from './entities/renderables.mjs';
|
2024-08-02 16:42:23 +00:00
|
|
|
import {ClassReference} from './templates/class-reference';
|
|
|
|
|
import {CliCommandReference} from './templates/cli-reference';
|
|
|
|
|
import {ConstantReference} from './templates/constant-reference';
|
|
|
|
|
import {DocsReference} from './templates/docs-reference';
|
|
|
|
|
import {EnumReference} from './templates/enum-reference';
|
|
|
|
|
import {FunctionReference} from './templates/function-reference';
|
|
|
|
|
import {InitializerApiFunction} from './templates/initializer-api-function';
|
|
|
|
|
import {TypeAliasReference} from './templates/type-alias-reference';
|
2025-06-24 15:45:49 +00:00
|
|
|
import {DecoratorReference} from './templates/decorator-reference';
|
2025-05-06 20:59:30 +00:00
|
|
|
import {setCurrentSymbol} from './symbol-context.mjs';
|
2025-12-10 18:03:54 +00:00
|
|
|
import {BlockReference} from './templates/block-reference';
|
2024-08-02 16:42:23 +00:00
|
|
|
|
|
|
|
|
/** Given a doc entry, get the transformed version of the entry for rendering. */
|
|
|
|
|
export function renderEntry(renderable: DocEntryRenderable | CliCommandRenderable): string {
|
2024-08-31 02:31:27 +00:00
|
|
|
setCurrentSymbol(renderable.name);
|
2024-08-02 16:42:23 +00:00
|
|
|
if (isCliEntry(renderable)) {
|
|
|
|
|
return render(CliCommandReference(renderable));
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-24 15:45:49 +00:00
|
|
|
if (isClassEntry(renderable) || isInterfaceEntry(renderable)) {
|
2025-10-20 12:40:23 +00:00
|
|
|
return render(ClassReference(renderable));
|
2025-06-24 15:45:49 +00:00
|
|
|
}
|
|
|
|
|
if (isDecoratorEntry(renderable)) {
|
|
|
|
|
return render(DecoratorReference(renderable));
|
2024-08-02 16:42:23 +00:00
|
|
|
}
|
|
|
|
|
if (isConstantEntry(renderable)) {
|
|
|
|
|
return render(ConstantReference(renderable));
|
|
|
|
|
}
|
|
|
|
|
if (isEnumEntry(renderable)) {
|
|
|
|
|
return render(EnumReference(renderable));
|
|
|
|
|
}
|
|
|
|
|
if (isFunctionEntry(renderable)) {
|
|
|
|
|
return render(FunctionReference(renderable));
|
|
|
|
|
}
|
|
|
|
|
if (isTypeAliasEntry(renderable)) {
|
|
|
|
|
return render(TypeAliasReference(renderable));
|
|
|
|
|
}
|
|
|
|
|
if (isInitializerApiFunctionEntry(renderable)) {
|
|
|
|
|
return render(InitializerApiFunction(renderable));
|
|
|
|
|
}
|
2025-12-10 18:03:54 +00:00
|
|
|
if (isBlockEntry(renderable)) {
|
|
|
|
|
return render(BlockReference(renderable));
|
|
|
|
|
}
|
2024-08-02 16:42:23 +00:00
|
|
|
|
|
|
|
|
// Fall back rendering nothing while in development.
|
|
|
|
|
return render(DocsReference(renderable));
|
|
|
|
|
}
|