-
Notifications
You must be signed in to change notification settings - Fork 174
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
feat: ui primitive api autodocs #464
base: main
Are you sure you want to change the base?
Conversation
Wanted you all's opinion on this. So I think I got a semi-decent executor to autodoc the UI primitives API. Output is a JSON file with an object where each property is the class name for a given component/directive with the following structure
it would require us to start self document each input output like so (it's currently not doing so well without explicit type on signal and assuming any in that case)
my hope is we won't have to maintain the UI api docs as it's own task and we can just make sure it's well doc'ed in the code. Curious to hear your thoughts. My plan was place the static JSON in the site app's public assets folder and just read it in based on the className to feed them into a table on the page |
Personally, I have been using this approach in projects for many years and it has worked well. The benefit of this approach is users also get docs in their editor, for example if I highlight over a property or ctrl click to definition I can see docs right inline in my editor as well as them being available in a docs site. And it also means the docs are derived from the code so less likely to be out of date. So I'm all for this approach! I haven't looked into your code much yet (as I'm on my phone), and it may do everything we need, but if not, just so you're aware, there are some solutions out there that are available if you don't want to write your own from scratch. One is compodoc (https://compodoc.app/) which actually comes built in with the Nx storybook executor, you can just enable it and get it to emit JSON. It's not perfect, but not bad. Another option which could be used within our own executor like you have been doing but may help extract information is Angular's own API extraction tooling - although it's not really documented but it's pretty good: https://github.com/angular/angular/tree/main/packages/compiler-cli/src/ngtsc/docs/src I really like the idea, just wanted to share these in case they are of any use to you! |
Yea I was thinking to myself afterwards I was like there's probably already solutions for this 😅, but i'm all for either. We can leverage compodoc if we prefer or I can work to probably make this more robust by leveraging the angular one you mentioned. I wasn't aware of it so thanks for mentioning them! |
You may not need either if you have it working fine already 😊 it may be easier not to rely on an additional tool at all. I guess we could also extract some additional things like the selector and exportAs values, which could also be useful in the docs. |
I am a big fan of keeping things together. I have nothing to add to Ashleys comments, because I have pretty much the same opinion. |
Awesome sounds good, I guess since i'm this far let me see if I can also add grabbing the selector and exportAs if available, great suggestion @ashley-hunter. Thanks all for the input, just wanted to make sure we were good with starting to self document this in the code. I know the trade off is slightly "busier" looking code with the extra comments but I think it's better than risking having out of date api docs |
Updated the structure to be like below so we can easily pull all the "accordion" api's for example and easily loop and create brain and helm sections on the page docs and dynamically create tables for each respective component/directive
|
122b8aa
to
455c973
Compare
Just wanted to give an update I think I mainly have the few things below left for this:
For this last one should I just go ahead and add the sections to all the primitive pages as part of this and fix any issues we find or should we go one by one after merging this to make sure the docs for each primitive are complete and correct first |
466552f
to
1c3c30d
Compare
1c3c30d
to
58ea570
Compare
f847689
to
22d3380
Compare
- adds api page sections - page navigation links
22d3380
to
b129441
Compare
PR Checklist
Please check if your PR fulfills the following requirements:
guidelines: https://github.com/goetzrobin/spartan/blob/main/CONTRIBUTING.md#-commit-message-guidelines
PR Type
What kind of change does this PR introduce?
Which package are you modifying?
What is the current behavior?
Closes #247
What is the new behavior?
Does this PR introduce a breaking change?
Other information