mirror of
https://github.com/zoriya/v10.git
synced 2026-08-08 07:07:10 +00:00
feat(site): generated multipart component api reference (#468)
This commit is contained in:
@@ -2,14 +2,20 @@ import * as ts from 'typescript';
|
||||
import type { HtmlExtraction } from './types.js';
|
||||
|
||||
/** Extract tagName from a Lit element file. */
|
||||
export function extractHtml(filePath: string, program: ts.Program, componentName: string): HtmlExtraction | null {
|
||||
export function extractHtml(
|
||||
filePath: string,
|
||||
program: ts.Program,
|
||||
componentName: string,
|
||||
elementName?: string
|
||||
): HtmlExtraction | null {
|
||||
const sourceFile = program.getSourceFile(filePath);
|
||||
if (!sourceFile) return null;
|
||||
|
||||
const className = elementName ?? `${componentName}Element`;
|
||||
let tagName = '';
|
||||
|
||||
function visit(node: ts.Node) {
|
||||
if (ts.isClassDeclaration(node) && node.name?.text === `${componentName}Element`) {
|
||||
if (ts.isClassDeclaration(node) && node.name?.text === className) {
|
||||
for (const member of node.members) {
|
||||
if (
|
||||
ts.isPropertyDeclaration(member) &&
|
||||
|
||||
Reference in New Issue
Block a user