Skip to content

Adding support for external json doc loading, Changed name of Analyzer to Extractor - #69

Merged
Dan Gaeta (dgaeta) merged 11 commits into
masterfrom
dagaeta/external-package-loading
Jan 27, 2017
Merged

Dan Gaeta (dgaeta) merged 11 commits into
masterfrom
dagaeta/external-package-loading

Conversation

@dgaeta

@dgaeta Dan Gaeta (dgaeta) commented Jan 26, 2017 •

Copy link
Copy Markdown
Contributor

Import Methods added:

  • Extractor.loadExternalPackages()
  • DocItemLoader.loadPackageIntoCache() (This method took some of the logic from DocItemloader.loadPackage() to eliminate duplication.)

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).

@octogonz Pete Gonzalez (octogonz) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See notes

return;
}

const files: string[] = fsx.readdirSync(externalJsonCollectionPath);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the filename does not end with "*.api.json"? For example "thumbs.db" or "es6-promise.api.json.bak"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to only read files with extname === 'json'

Comment thread api-extractor/src/DocItemLoader.ts Outdated
*/
public loadPackageIntoCache(packageJsonFilePath: string): IDocPackage {
if (!fsx.existsSync(path.join(packageJsonFilePath))) {
return undefined;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the filename has no extension? Better to use path.parse() than write your own path parsing logic

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread api-extractor/src/Extractor.ts Outdated
/**
* Analyzes the specified project.
*/
public analyze(options: IApiAnalyzerOptions): void {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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';

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a ton of diff churn. In the future, renaming Analyzer should probably be a separate PR from new work

@dgaeta
Dan Gaeta (dgaeta) merged commit e739da3 into master Jan 27, 2017
Pete Gonzalez (octogonz) pushed a commit that referenced this pull request Feb 13, 2017
Adding support for external json doc loading, Changed name of Analyzer to Extractor
Christian Gonzalez (christiango) pushed a commit to christiango/web-build-tools that referenced this pull request Aug 22, 2017
…ge-loading

Adding support for external json doc loading, Changed name of Analyzer to Extractor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants