/*! * @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 {h} from 'preact'; import {EntryType, isDocEntryWithSourceInfo, PipeEntry} from '../entities.mjs'; import {DocEntryRenderable, PipeEntryRenderable} from '../entities/renderables.mjs'; import { HEADER_CLASS_NAME, HEADER_ENTRY_CATEGORY, HEADER_ENTRY_LABEL, HEADER_ENTRY_TITLE, } from '../styling/css-classes.mjs'; import {DocsPillRow} from './docs-pill-row'; /** Component to render a header of the API page. */ export function HeaderApi(props: { entry: DocEntryRenderable | PipeEntryRenderable; showFullDescription?: boolean; }) { const entry = props.entry; // TODO: This link point to the main branch. // When ADEV is not deployed on the main branch branch anymore, // We should update it to point to the tag of the released version which ADEV runs on. const sourceUrl = sourceUrlForEntry(entry); return (
{entry.moduleName}

{entry.name}

{getEntryTypeDisplayName(entry.entryType)}
{entry.isDeprecated && (
Deprecated
)} {entry.isDeveloperPreview && (
Developer preview
)} {entry.isExperimental && (
Experimental
)} {entry.entryType === EntryType.Pipe && !(entry as PipeEntry).isPure && (
Impure
)}
{sourceUrl && ( )}
); } function getEntryTypeDisplayName(entryType: EntryType | string): string { switch (entryType) { case EntryType.NgModule: return 'NgModule'; case EntryType.TypeAlias: return 'Type Alias'; case EntryType.UndecoratedClass: return 'Class'; case EntryType.InitializerApiFunction: return 'Initializer API'; } return entryType; } function sourceUrlForEntry(entry: DocEntryRenderable): string | null { if (!isDocEntryWithSourceInfo(entry)) { return null; } if (entry.source.filePath.includes('node_modules')) { // We don't know the source path in external repos link the CLI return null; } else { const filePath = entry.source.filePath.replace(/^\//, ''); return `https://github.com/${entry.repo}/blob/main/${filePath}#L${entry.source.startLine}-L${entry.source.endLine}`; } }