Repository navigation
Adding support for external json doc loading, Changed name of Analyzer to Extractor - #69
Conversation
Pete Gonzalez (octogonz)
left a comment
There was a problem hiding this comment.
See notes
| return; | ||
| } | ||
|
|
||
| const files: string[] = fsx.readdirSync(externalJsonCollectionPath); |
There was a problem hiding this comment.
What if the filename does not end with "*.api.json"? For example "thumbs.db" or "es6-promise.api.json.bak"?
There was a problem hiding this comment.
if JsonFile.loadJsonFile() can't parse it to a string and error will be thrown. Then if it gets past that stage, if it must conform to our schema check, otherwise an error will be thrown. So it really doesn't matter what the file is called as long as we can parse it. Do you suggest we enforce the name end in 'api.json'?
There was a problem hiding this comment.
Changed to only read files with extname === 'json'
| */ | ||
| public loadPackageIntoCache(packageJsonFilePath: string): IDocPackage { | ||
| if (!fsx.existsSync(path.join(packageJsonFilePath))) { | ||
| return undefined; |
There was a problem hiding this comment.
Shouldn't this be an error?
|
|
||
| // JSON schema has been found and validated | ||
| this.cache[cachePackageName] = apiPackage; | ||
| const packageName: string = path.basename(packageJsonFilePath).split('.').shift(); |
There was a problem hiding this comment.
What if the filename has no extension? Better to use path.parse() than write your own path parsing logic
There was a problem hiding this comment.
I would have to do: path.parse(packageJsonFilePath).name.split('.').shift(), since if the filename is es6-collections.api.json then path.parse().name gives 'es6-collections.api'. So this is essentially the same thing.
| /** | ||
| * Analyzes the specified project. | ||
| */ | ||
| public analyze(options: IApiAnalyzerOptions): void { |
There was a problem hiding this comment.
If you're keeping the name analyze(), then the interface should be something like IExtractorAnalyzeOptions
|
|
||
| import * as ts from 'typescript'; | ||
| import Analyzer from '../Analyzer'; | ||
| import Extractor from '../Extractor'; |
There was a problem hiding this comment.
This is a ton of diff churn. In the future, renaming Analyzer should probably be a separate PR from new work
Adding support for external json doc loading, Changed name of Analyzer to Extractor
…ge-loading Adding support for external json doc loading, Changed name of Analyzer to Extractor
Import Methods added:
The test for making sure this support works is in example2/MyDocumentedClass. We can see it is working because the summary for ' es6-collections:ForEachable' is added. (The summary for ForEachable was added manually in the API-Extractor copy of external-api-json, we have not written JSDoc comments for the externals yet)
If no external package is found for an '@inheritdoc (@inheritdoc)' tag, then a textDocElement will be attached to the json entry that says "See documentation for 'xxx'" (this does not appear for our test case because it is being found).