Repository navigation
feat: build reference docs from latest release - #10418
Conversation
| "serve": "docusaurus serve", | ||
| "write-translations": "docusaurus write-translations", | ||
| "write-heading-ids": "docusaurus write-heading-ids", | ||
| "reference:refresh": "typedoc --options ./typedoc.json --entryPointStrategy resolve --entryPoints ../blockly/core/blockly.ts --includeVersion --json ./blockly_api.json", |
There was a problem hiding this comment.
| "reference:refresh": "typedoc --options ./typedoc.json --entryPointStrategy resolve --entryPoints ../blockly/core/blockly.ts --includeVersion --json ./blockly_api.json", | |
| "reference-refresh": "typedoc --options ./typedoc.json --entryPointStrategy resolve --entryPoints ../blockly/core/blockly.ts --includeVersion --json ./blockly_api.json", |
We've changed from using colons in script names to using dashes, as nx doesn't play well with the colon syntax. You would also want to update all the references to this command. You might also need to merge in main as the lint:fix script below has been updated to lint-fix as well.
There was a problem hiding this comment.
Fixed & merged in main!
| fi | ||
| else | ||
| VERSION_COMMAND="${VERSION_COMMAND} --conventional-prerelease --preid beta" | ||
| export npm_config_ignore_scripts=true |
There was a problem hiding this comment.
Sorry, forgot to mention this in my earlier review. I'm not sure why this was added, but this is unrelated to the changes you're making and doesn't need to be added.
There was a problem hiding this comment.
Since I'm using the version script (a lerna lifecycle hook) to handle creating/committing the docs JSON, I needed a way to disable lifecycle hooks when we're doing a beta release. That way, the docs JSON is only generated for full releases.
That said, double checking this made me realize that I can just set --ignore-scripts on the VERSION_COMMAND that's above this line, which feels a little less weird than setting an environment variable. I can also add a comment explaining why the flag is there.
The basics
The details
Resolves
Fixes #10298
Proposed Changes
blockly_api.json) that's generated and committed only during each release.Added 2 npm scripts, one to docs package.json and one to the root package.json:
npm run reference:refreshin docs now re-generatesblockly_api.json, this is used during the release process but also can be used locally to see API or TSDoc changes reflected when building locally.versionscript is a lifecycle hook with lerna. It wasn't sufficient to add docs generation as a task in the release process, because theblockly_api.jsonneeds to be generated after the version number is incremented (so that it doesn't pull/display the wrong version) but before the release is fully committed.To block
blockly_api.jsonfrom being rebuilt during beta releases, this PR turns off lerna lifecycle hooks during beta releases, so that the newversionscript never runs. I'm happy to adjust this if it seems like a bad idea to disable the lifecycle hooks. I did it this way because it's one of the simpler options for changing the behavior based on whether it's a beta release or not. We also don't currently use any lerna lifecycle hooks.mergemode. Previously, we were generating the docs straight from source (rather than from the generated JSON) so this didn't come up. It looks like there's already been work on the issue I filed, but the plugin version with the fixes hasn't been released yet. There's some workaround code intypedoc-member-index.mjsthat allows our docs to work for now, and it can be deleted once the plugin fix is released.Reason for Changes
Since docs deployment used to generate the reference docs fresh from
mainevery time, unreleased APIs would leak into the reference docs. Now, since docs are generated fromblockly_api.jsonwhich is only created/committed on a release, the reference docs always display latest released version of Blockly. This also gives us a way to track API changes.Test Coverage
Tested the workflows manually as best I could and everything seems to be working, the real test will be whenever we next release Blockly and deploy docs
Documentation
Updated docs readme, and AGENTS.md
Additional Information
blockly_api.jsonbecause then it couldn't be committed during the release. We could add another PR action that checks to see if this file was edited. I elected not to do that, because I'm hopeful that it's a rare enough scenario that someone will a) regenerate, or manually edit the reference docs and b) commit that generated file that it probably isn't worth adding an action that needs to run on every PR.blockly_api.json. This would otherwise be generated and committed on the next release, which is fine, but without committing it now the docs would be in a state where a deploy would break entirely.