@jsdocs-io/extractor
Version:
The API extractor for npm packages powering jsdocs.io
19 lines (18 loc) • 865 B
JavaScript
import { Node } from "ts-morph";
import { isHidden } from "./is-hidden.js";
import { sourceFilePath } from "./source-file-path.js";
export function ambientModulesDeclarations(containerName, project, pkgName) {
const ambientModulesDeclarations = [];
for (const symbol of project.getAmbientModules()) {
for (const declaration of symbol.getDeclarations()) {
if (!Node.isModuleDeclaration(declaration) || isHidden(declaration))
continue;
// Ignore ambient modules that are not from the analyzed package.
if (pkgName && !sourceFilePath(declaration).startsWith(`/${pkgName}`))
continue;
const exportName = declaration.getName();
ambientModulesDeclarations.push({ containerName, exportName, declaration });
}
}
return ambientModulesDeclarations;
}