-
Notifications
You must be signed in to change notification settings - Fork 626
[api-extractor] Improve namespace support #773
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] Improve namespace support #773
Conversation
Thanks @adventure-yunfei for submitting this PR! I will take a look soon. #Resolved |
…ference for namespace content, and render namespace item
2f669bd
to
568db17
Compare
@AlexJerabek your group is the primary user of namespaces with API Extractor. Before we merge this PR, could you test it against the Office Add-ins project to make sure it doesn't break anything? My specific concern are the changes in AstNamespace.ts and DocItemSet.ts which affect the YAML pipeline. Thanks! #Resolved |
@pgonzal Just tested the changes against office-js. Nothing appears to be different in the yaml or json files. #Resolved |
Thanks @AlexJerabek for taking the time to test this! I will merge it. #Resolved |
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.
@adventure-yunfei thanks again for contributing this fix! |
@pgonzal I'm just using api-documenter for typescript project right now. Searched around the world and almost tried every ts doc generator, you guys wrote the cleanest codes. While some features are not supported yet, it's not quite hard for me to figure out the logic and implement them. Nice Work! But at I said this fix is just a quick fix. With namespace, "package" -> "export name" -> "member name" hierarchy is not enough. A re-implementation of api reference may be needed~ |
Is your project open source? If so I'd be interested to see your API and documentation scenario. We're going to be improving the analysis in our next sprint, by adapting the new .d.ts generator code to handle the .api.ts and .api.json features as well. |
It's an internal project, but I can describe a little bit. The required missing feature is the export statement support. The directory hierarchy is:
And the exported api file combines all of them. // api.math.ts
import * as Vector3 from './math/Vector3';
import * as mathUtils from './math/mathUtils';
export { Vector3, mathUtils };
// - api.ts
import * as events from './events';
import * as math from './api.math';
import * as utils from './utils';
export { events, math, utils }; In this case the api reference for class Vector3 would be "" -> "math" -> "Vector3" -> "default" (and it could be deeper with nested namespace/es6-export-statement). Some other missing features are:
If you need, I may re-create an example project. |
Thanks, this is helpful! If you find the time and are able to create a small repro branch on GitHub that illustrates these issues, when I am working on the analysis engine I can try to make sure these cases are handled correctly. If not, I can try to infer it from these notes. |
I've made an example project that demonstrates what I've met before. Hopefully it'll help you. |
Fix Cases:
Currently this case won't work:
First,
api-extractor
cannot build correct api.json for case 1 (invalid name).Second, while configure
api-extractor.json
to"namespaceSupport": "permissive"
,api-extractor
successfully builds api.json, butapi-documenter
won't generate document for namespace.What this PR does:
api-extractor
for sub module exportsapi-documenter
for api reference search (for namespace case, api reference will be more than limited "package" -> "export name" -> "member name" hierarchy, and right now it's a quick fix which only affectsapi-documenter
package )namespace
document support forapi-documenter