-
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] Adds package-defined TSDoc tag support #1950
[api-extractor] Adds package-defined TSDoc tag support #1950
Conversation
@@ -47,7 +46,21 @@ export class ApiDocumentedItem extends ApiItem { | |||
const documentedJson: IApiDocumentedItemJson = jsonObject as IApiDocumentedItemJson; | |||
|
|||
if (documentedJson.docComment) { | |||
const tsdocParser: tsdoc.TSDocParser = new tsdoc.TSDocParser(AedocDefinitions.tsdocConfiguration); | |||
const tsdocConfiguration: tsdoc.TSDocConfiguration = new tsdoc.TSDocConfiguration(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a performance concern, since it will initialize a new TSDocConfiguration
for every single doc comment.
Instead, we should construct it once and share it. The DeserializerContext
could be used to store it:
rushstack/apps/api-extractor-model/src/model/ApiPackage.ts
Lines 160 to 168 in a30cdf5
const context: DeserializerContext = new DeserializerContext({ | |
apiJsonFilename, | |
toolPackage: jsonObject.metadata.toolPackage, | |
toolVersion: jsonObject.metadata.toolVersion, | |
versionToDeserialize: versionToDeserialize | |
}); | |
return ApiItem.deserialize(jsonObject, context) as ApiPackage; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call - DeserializerContext
now stores the TSDocConfiguration
and non-standard tags now configured in ApiPackage.loadFromJsonFile()
545836f
to
4e8dd5c
Compare
4e8dd5c
to
0546564
Compare
@octogonz any chance you have some time to take another look at this? We're really looking forward to using this feature. Thanks in advance! |
I apologize -- I recently got sandbagged by a bunch of high priority work for the Heft and Rush projects, and have not been able to give much time to API Extractor. The pressure should hopefully be off by end of next week at the latest. This is a cool PR and I feel bad for delaying it! |
No worries - I totally understand ;) Thanks @octogonz! |
0546564
to
a1f3c2e
Compare
Is there any update? |
Pinging @octogonz Not having this is really causing an issue for our open source efforts. Is there anything we need to do to help get this PR merged? I have engineering resources I can commit to seeing this PR through. |
@EisenbergEffect I'll take a look at this today and follow up. |
Okay @EisenbergEffect I've merged Some thoughts:
I think we can implement all these things pretty quickly. Lemme see if I can make some PRs over the weekend. |
Here's an upstream PR that adds the missing features: microsoft/tsdoc#277 |
Thanks @octogonz ! |
Here's a second PR that sorts out a problem where the serialized TSDoc config includes the predefined standard tags, which would then conflict with the tags that are predefined when Once that's published, I think we'll have all the pieces necessary to finally complete this PR. 😊🤞 |
Thanks @octogonz! This is awesome to see; we're really looking forward to this feature. |
…ags implementation
Hey @octogonz! I'm in the process of working in the To build up the |
0bb6a89
to
52829d8
Compare
@@ -14,6 +14,18 @@ import { ApiDocumentedItem, IApiDocumentedItemOptions } from '../items/ApiDocume | |||
import { ApiEntryPoint } from './ApiEntryPoint'; | |||
import { IApiNameMixinOptions, ApiNameMixin } from '../mixins/ApiNameMixin'; | |||
import { DeserializerContext, ApiJsonSchemaVersion } from './DeserializerContext'; | |||
import { TSDocConfiguration, TSDocTagDefinition, TSDocTagSyntaxKind } from '@microsoft/tsdoc'; | |||
|
|||
interface ITagConfigJson { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@octogonz defining these here is odd to me because they're essentially a copy of the interfaces defined in tsdoc-config
and are the product of saveToObject()
, but saveToObject()
returns unknown
. Should I do something to address this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was easy, so I went ahead and implemented the missing loadFromObject()
operation in microsoft/tsdoc#288
tsdocConfiguration.addTagDefinitions( | ||
tagDefinitions.map((definition) => { | ||
const { syntaxKind } = definition; | ||
const formattedSyntaxKind: TSDocTagSyntaxKind = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the re-mapping I am referring to in my previous comment. Should there be a mechanism from tsdoc-config
to build up a TSDocConfigFile
from the product of TSDocConfigFile.saveToObject()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicholasrice The right solution would be to implement a corresponding TSDocConfigFile.loadFromObject()
to handle loading of the object. Ideally it would be integrated with the TSDocConfigFile.loadFile()
implementation, although there is an interesting nuance that loadFile()
considers file paths and "extends"
resolution which assume that the objects have meaningful file paths. So a bit of abstraction might be needed to handle that. (Perhaps that is why I procrastinated it?)
If you want to make a PR for TSDoc that would be great. However your PR has been open for a very long time, so if it helps speed things along, I would also be okay with merging a less ideal solution to get you unblocked. And then we could come back later and improve the tsdoc-config
API.
I am away on vacation right now, but I will review this PR as soon as I get back. Sorry about the delays.
For future reference if you need help getting PRs merged @iclanton's team at Microsoft is a good point of contact, and also we now have a #contributor-helpline chatroom for getting attention of the maintainers. Thanks!
Hey @octogonz 😄 Thanks for working with us on this. I think we're ready for another round of review from you. Nick had a few questions that he dropped above. Would be great to get these last few things wrapped, merged, and released. We're pretty excited for this work as we'll be able to make some huge improvements to our documentation and it will also enable some other teams we're working with as well. 🎊 |
@EisenbergEffect I apologize for the delay. I'm on vacation -- will be back next week. |
…e/custom-tags # Conflicts: # common/config/rush/nonbrowser-approved-packages.json # common/config/rush/pnpm-lock.yaml # common/config/rush/repo-state.json
…doc.json to the "api-documenter-test" project
Okay @nicholasrice sorry again about the delays in getting this PR reviewed. I've updated your branch to use After merging this PR we'll do a little more testing and then we should finally be ready to release this. After using it a bit, it is a pretty cool feature. I'm very excited about it! Thanks for all your work to make it happen. |
Awesome @octogonz ! Thank you so much for helping to move this through 😄 |
Thank you @octogonz! It's awesome to see this go through, thanks for working with me on it :) |
This was released with API Extractor 7.14.0. Docs here: https://api-extractor.com/pages/configs/tsdoc_json/ |
I took a shot at implementing #519 based on the feedback of #1628. I'm new to this code-base so very open to feedback on any of this. I also tried to implement this without causing any breaking changes but please call out any issues I may have missed.
This change involves removing
AedocDefinitions
references fromapi-extractor
andapi-extractor-model
. TheExtractorConfig
has been updated to construct thetsdocConfiguration
for theExtractor
process. ThetsdocConfiguration
is configured from one of two sourcetsdoc.json
files:tsdoc.json
file in the project folder, if it existsapi-extractor
'stsdoc.json
Once configured, the configuration is provided to parts of the process requiring a
tsdocConfiguration
.api-extractor-model
was also changed to remove it's dependency onAedocDefintions
- instead expecting any non-standard TSDoc tags for a given package to be enumerated in the metadata field of the model.I made a few decisions that I'm unsure about and also had a few questions:
{package}.api.json
. This is so that tags can be ingested by theApiPackage
implementation and so that any non-standard tags can exist per package. This deviates from API Extractor: Add support for custom TSDoc tags #1628, where tags are provided to as part of the options config to theApiModel
implementation. If API Extractor: Add support for custom TSDoc tags #1628 is the preferred implementation (or if there is any other preferred implementation) please let me know and I'll adjust.AedocDefinitions
implementation as@deprecated
. I believe it is technically internal though, so should it be removed entirely?build-tests
that contains custom TSDoc tags?api-documenter
- should it to fully address [api-extractor] Support extensible AEDoc tags #519?As always, open to any and all feedback.
closes #519