@jsdocs-io/extractor
Version:
The API extractor for npm packages powering jsdocs.io
21 lines (20 loc) • 837 B
JavaScript
import { docs } from "./docs.js";
import { formatSignature } from "./format-signature.js";
import { id } from "./id.js";
import { sourceFilePath } from "./source-file-path.js";
import { typeCheckerType } from "./type-checker-type.js";
export async function extractFunctionExpression(containerName, exportName, declaration) {
return {
kind: "function",
id: id(containerName, "+function", exportName),
name: exportName,
docs: docs(declaration),
file: sourceFilePath(declaration),
line: declaration.getStartLineNumber(),
signature: await functionExpressionSignature(exportName, declaration),
};
}
async function functionExpressionSignature(name, declaration) {
const type = typeCheckerType(declaration);
return await formatSignature("function", `${name}: ${type}`);
}