-
Notifications
You must be signed in to change notification settings - Fork 604
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
API Extractor: Add support for custom TSDoc tags #1628
Conversation
I wonder if there's a way to make this configuration discoverable by other tools... For example @bafolts recently created a package eslint-plugin-tsdoc that enabels ESLint to validate TSDoc comments. Since it also invokes the TSDoc parser, it also needs to know about custom tags. We could write this config into the tsdoc-metadata.json file, but that's an output, so it wouldn't be available until after you've built the project. We could invent a special We could also define the custom tags in the @packageDocumentation code comment. I don't know the right answer. Your approach here is pretty good, but it might be good to brainstorm some other options. |
Thinking about this some more, I feel like we made a mistake by designing @ecraig12345 if you don't mind waiting, I'd like to pursue moving your configuration down into the Rather than breaking the tsdocMetadataFilePath feature of API Extractor, maybe we can use a different filename |
That sounds like the right thing to do long-term. From working on this, I actually figured out a (rather hackish) workaround for adding extra tags when invoking API Extractor programmatically: directly calling |
Cool. I posted my proposed design here and will start work on a PR as soon as I get some time. |
This PR implements an initial sketch of the tsdoc-config.json feature: microsoft/tsdoc#196 |
We published The basic idea is that the custom tag definitions go in a new config file With this design, I feel like we can also move the AEDoc-specific definitions out of [AedocDefinitions.ts](https://github.com/microsoft/rushstack/blob/master/apps/api-extractor- my-project/tsdoc.json
@ecraig12345 It sounds like you already found a workaround to unblock yourself, but if you want to keep going, let us know. Otherwise maybe I can find some time to push this feature along. |
Add support for custom TSDoc tags in the API Extractor config file and when deserializing via
ApiModel
. Fixes #519.Implementing this involved a couple significant design decisions which I've called out below. I'm open to suggestions on whether these (and really any element of the change) should be handled differently.
Configuration placement and naming
Right now, the new section in the JSON is at the top level and would look like this:
The placement (top-level or not) and naming are negotiable. The idea of putting
tagDefinitions
under a parenttsdoc
tag was to facilitate possibly adding more TSDoc-related options later. The tag definition items are based onITSDocTagDefinitionParameters
.How to update and share the TSDoc configuration
Another significant design decision is whether the new tags should be added to the global
AedocDefinitions.tsdocConfiguration
, or whether a new TSDoc configuration should be generated when adding tags. The advantage of updating the global usingAedocDefinitions.tsdocConfiguration.addTagDefinitions(...)
is simplicity. The disadvantage is that it's polluting a global object, which makes behavior harder to trace and could cause problems if anyone wants to use different configurations within the same program.To avoid polluting a global, I went with creating a new TSDoc configuration which incorporates existing defaults, and passing it as a parameter to the various places that need it. Currently the configuration for API Extractor is created in
ExtractorConfig
, and the one for deserialization is created inApiModel
(though I wonder if that ought to be done inApiPackage
instead).