runem / web-component-analyzer

CLI that analyzes web components and emits documentation
https://runem.github.io/web-component-analyzer
MIT License
501 stars 63 forks source link

Feature request: analyzeProject() #134

Open justinfagnani opened 4 years ago

justinfagnani commented 4 years ago

For programmatic use, one of the simplest APIs I can think of would be to analyze a TypeScript project either by folder, or by reference to tsconfig.json file. The entrypoint, rather than the caller, would create the TypeScript program and checker.

runem commented 4 years ago

Thanks for the suggestion! I already have functionality in the CLI to analyze a glob/directory called analyzeGlob. This function creates a program and checker.

https://github.com/runem/web-component-analyzer/blob/4f3b5ad4a9c26cb4270519d4153089914da3c1d1/src/cli/util/analyze-globs.ts#L33-L37

It's not aware any tsconfig.json files, so I'm thinking about supporting giving a path to the tsconfig through the config AnalyzerCliConfig. This would add/exclude root files in the program by adding include, exclude and files from the tsconfig.json to the array of globs. It might also be relevant to auto-discover the tsconfig.json :-)