-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: Refine api reference docs generation process #8229
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
Conversation
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 change moves the config without updating it. We're moving it so that other repo's can be extracted into a reasonable structure.
src/references/raw-references.json
Outdated
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.
The raw file is an intermediate transformation artifact that isn't directly used. This change removes it as it serves no purpose.
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.
Thanks for doing that! Imagine the CO2 produced when cloning and copying this file. Should it be added to the gitignore?
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.
I'll add it, however this dir location isn't used in the new process since the file is read from the neighboring package, then the complete product is written directly into the directories, skipping over all the interstitial steps the original process had.
@@ -135,13 +155,84 @@ function recursivelyPopulateNodes(node) { | |||
} | |||
} | |||
|
|||
function processReferences(references, rootPackage) { |
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 logic is taken directly from the working branch that was used to generate the original references process https://github.com/aws-amplify/amplify-js/blob/feat/inline-api-docs/scripts/process-typedoc.mjs#L31-L108
This change proposes having a single transformation from the generated references.json file to the transformed / optimized apiReferences/*.json file where all of the transform logic is here in this file.
name: Receive repository dispatch event | ||
|
||
on: | ||
# Listen to a repository dispatch event by the name of `dispatch-event` | ||
repository_dispatch: | ||
types: [update-references] | ||
workflow_dispatch: | ||
permissions: | ||
contents: write # Used to commit updated references PR | ||
pull-requests: write # Used to create updated references PR | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
jobs: | ||
create-pull-request: |
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.
I am removing this workflow. Instead of having a trigger-able process to on the docs repo, I propose each repo have a workflow to push a PR against the docs repo as can be seen in the draft js change
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.
The approach makes sense to me. Thank you for doing it!
I think clean-references
script needs a lot of work to make the API reference in docs look better. It seems like the node walker logic misses a lot of doc nodes, and make the page misses a lot examples we wrote in source code.
But I think we can make it a follow-up task.
src/references/raw-references.json
Outdated
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.
Thanks for doing that! Imagine the CO2 produced when cloning and copying this file. Should it be added to the gitignore?
@@ -1,4 +1,4 @@ | |||
import { API_CATEGORIES, API_SUB_CATEGORIES } from '@/data/api-categories'; | |||
import { API_CATEGORIES, API_SUB_CATEGORIES } from '@/data/api-categories.mjs'; |
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.
Is this necessary?
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.
Interesting. If I remove the file type, then I get an error
There wasn't a *.d.ts
file there before so I'm not sure why the prior version worked :-/
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.
I would agree that the clean-references
could use a good refactor. Looking at the result, I think a lot of content is being skipped over in the display logic, so there are some quick wins to add comments into the doc without retooling the transformation.
From what I grox of this transformation logic, its there to:
-
- Prune a bunch of exports that aren't referenced to make the file smaller.
-
- Reindex the references so that access is constant time vs linear when looking up related code/type references
Love seeing so much red here! With the size of the diff here being so large, how are we validating there is no impact to the existing documentation |
@@ -1,8 +1,8 @@ | |||
import references from '../src/references/raw-references.json' assert { type: 'json' }; |
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.
@calebpollman The original process proposed have the JS repo generate and check in this raw file, which the docs repo would then transform into the apiReferences.json
file, which I have moved to scop by package name.
My update process proposes that the JS repo (and other repos) should generate their api docs json files, then use the docs repo transformation logic proposed here to transform the file directly into the finished product instead of having multiple interstitial json files checked in along the way.
I had originally included updating the amplify-js file with this change, but it seems better to do this using the automated process and leave this change a no-op for the docs.
Description of changes:
This change is process/automation only and contains no docs site changes.
Changes:
yarn clean-references -- -p amplify-js
in the docs repo.This command will:
../amplify-js/docs/references.json
references.json
file to optimize it for docs use and write the result to./src/directory/apiReferences/amplify-js.json
This process will allow library package owners to add a workflow that:
Checks out their repo
Checks out the docs repo
Build an updated docs
references.json
fileTransform it into the docs repo version
Open a PR to update the docs repo
See the workflow process in the draft amplify-js PR: chore: Setup typedoc to build references.json and configure release workflow to update docs site amplify-js#14255
Which product(s) are affected by this PR (if applicable)?
Which platform(s) are affected by this PR (if applicable)?
Please add the product(s)/platform(s) affected to the PR title
Checks
Does this PR conform to the styleguide?
Does this PR include filetypes other than markdown or images? Please add or update unit tests accordingly.
Are any files being deleted with this PR? If so, have the needed redirects been created?
Are all links in MDX files using the MDX link syntax rather than HTML link syntax?
ref: MDX:
[link](https://docs.amplify.aws/)
HTML:
<a href="https://docs.amplify.aws/">link</a>
When this PR is ready to merge, please check the box below
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.