Skip to content

ApiExtractor now creates ApiDocumentation after all members have been created - #81

Merged
Dan Gaeta (dgaeta) merged 8 commits into
dagaeta/ApiItemKindfrom
dagaeta/api-extractor-resolve-references
Feb 2, 2017
Merged

Dan Gaeta (dgaeta) merged 8 commits into
dagaeta/ApiItemKindfrom
dagaeta/api-extractor-resolve-references

Conversation

@dgaeta

Copy link
Copy Markdown
Contributor

Refactored the creation of documention for ApiItems to occur after the abstract syntax tree has been created. This will be useful for implementing local API reference inheritdocs.

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

Overall looks good, assuming you fix the various issues


this.package = new ApiPackage(this, rootFile);
this.package = new ApiPackage(this, rootFile); // construct members
this.package.resolveReferences(); // creates ApiDocumentation

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.

Do you need to update the Gulp task? This is a breaking API change

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.

We don't this change is contained within the Extractor.analyze() function so it is hidden to the Gulp task.


/**
* We need the extractor to access the package that this ApiItem
* belongs to in order to resolve references.

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.

Can we obtain that via ApiItem.package.extractor?

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.

ApiItem doesn't have a package property.

TypeLiteral = 9
}

/**

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.

Maybe reference the resolveReferences() stage

*/
Unresolved = 0,
/**
* The refernces of this ApiItem are in the process of being resolved.

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.

Maybe clarify "inside a recursive call to ApiItem.resolveReferences()"

@virtual
protected onResolveReferences(): void {
this.documentation = new ApiDocumentation(this, this.extractor.docItemLoader, this.extractor, this.reportError);
// this.collectTypeReferences(this);

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.

?

protected onResolveReferences(): void {
super.onResolveReferences();
this.memberItems.forEach(apiItem => {
apiItem.resolveReferences(); // <==== crawling tree

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.

crawling tree?

this.params = [];
for (const param of methodDeclaration.parameters) {
const declarationSymbol: ts.Symbol = TypeScriptHelpers.tryGetSymbolForDeclaration(param);
const docComment: string = declarationSymbol && this.documentation && this.documentation.paramDocs ?

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.

Could you run this on sp-core-library and make sure the output JSON doesn't have any diff from the last release? That would help confirm that we don't need this code.

*
* @param memberName - the name of the member ApiItem
*/
protected getMemberItem(memberName: string): ApiItem {

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.

Is this used in this PR?

*
* @param memberName - the name of the member we want to ensure has documentation created.
*/
public resolveReferencesOnItem(memberName: string): ApiItem {

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 looks weird. Maybe we should bump it to the next PR if nothing is using it.

/* tslint:disable:no-constant-condition */

import * as ts from 'typescript';
import { virtual } from '@microsoft/decorators/lib/virtual';

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.

Don't use path-based imports

@dgaeta Dan Gaeta (dgaeta) left a comment

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.

Response to comments


/**
* We need the extractor to access the package that this ApiItem
* belongs to in order to resolve references.

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.

ApiItem doesn't have a package property.

@dgaeta
Dan Gaeta (dgaeta) merged commit 6eb2ba2 into dagaeta/ApiItemKind Feb 2, 2017
Pete Gonzalez (octogonz) pushed a commit that referenced this pull request Feb 13, 2017
…eferences

ApiExtractor now creates ApiDocumentation after all members have been created
Christian Gonzalez (christiango) pushed a commit to christiango/web-build-tools that referenced this pull request Aug 22, 2017
…resolve-references

ApiExtractor now creates ApiDocumentation after all members have been created
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.

3 participants