Skip to content

Implement @webonly tag to exclude items from Node docs #1679

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Apr 11, 2019
Merged

Conversation

hsubox76
Copy link
Contributor

@hsubox76 hsubox76 commented Apr 9, 2019

Added a @webonly tag. When included in leading comments in packages/firebase/index.d.ts, it will exclude that symbol from Node docs. This happens by the generate-docs.js script creating a temporary copy of index.d.ts that excludes any item with that tag. It uses the native Typescript parser to find these sections.

@webonly must be added after the description text of the comment, or Typedoc will think that text is part of the tag and exclude it. I'll add instructions on usage into `CONTRIBUTING.md`` in a separate PR.

Also changed the order of signatures/descriptions for overloaded methods. Typedoc does S-S-S-D-D-D, users prefer S-D-S-D-S-D. May look into a future change to make descriptions collapsible.

if (item.tags) {
item.tags.forEach(tag => {
if (tag.tagName.escapedText === 'webonly') {
webOnlyBlocks.push({ start: node.pos, end: node.end });
Copy link
Member

@Feiyang1 Feiyang1 Apr 9, 2019

Choose a reason for hiding this comment

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

Is it possible to create a new AST by deleting "webonly" nodes? Then you can use AST.writefile or something similar to create a file instead of scanning the file and deleting lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The native Typescript parser is pretty basic. It doesn't have a delete method and doesn't give direct access to children. There is a wrapper library that provides that functionality (https://github.com/dsherret/ts-morph) but I think it also does it by just removing text? I would use that library but it says prominently in several places it's WIP and I don't know how stable it is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the help, updated the code to use the transformer as you suggested.

// }
// typescript.forEachChild(node, findWebOnlyBlocks);
// }
// findWebOnlyBlocks(typescriptSourceFile);
Copy link
Member

Choose a reason for hiding this comment

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

remove comments?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should be removed, I think this snippet is from one commit behind?

@hsubox76 hsubox76 merged commit e0aba76 into master Apr 11, 2019
@hsubox76 hsubox76 deleted the ch-docs branch April 11, 2019 18:57
@firebase firebase locked and limited conversation to collaborators Oct 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants