@ng-doc/builder
Version:
<!-- PROJECT LOGO --> <br /> <div align="center"> <a href="https://github.com/ng-doc/ng-doc"> <img src="https://ng-doc.com/assets/images/ng-doc.svg?raw=true" alt="Logo" height="150px"> </a>
31 lines • 1.3 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCategorySourceFile = getCategorySourceFile;
const ts_morph_1 = require("ts-morph");
const helpers_1 = require("../../../helpers");
/**
* Retrieves the source file for a given category.
* @param {SourceFile} sourceFile - The source file to retrieve the category from.
* @returns {SourceFile | undefined} The source file for the category, or undefined if it could not be found.
*/
function getCategorySourceFile(sourceFile) {
const objectExpression = (0, helpers_1.getObjectExpressionFromDefault)(sourceFile);
if (objectExpression) {
const categoryProperty = objectExpression.getProperty('category');
if (ts_morph_1.Node.isPropertyAssignment(categoryProperty)) {
const initializer = categoryProperty.getInitializer();
if (initializer) {
const categorySourceFile = initializer
.getSymbol()
?.getAliasedSymbol()
?.getValueDeclaration()
?.getSourceFile();
if (categorySourceFile) {
return categorySourceFile;
}
}
}
}
return undefined;
}
//# sourceMappingURL=get-category-source-file.js.map
;