fix(api-docs): preserve manual content during generation#1663
Draft
fix(api-docs): preserve manual content during generation#1663
Conversation
✅ Deploy Preview for vcluster-docs-site ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Contributor
|
Claude finished @Piotr1215's task in 35s —— View job No issues found. The file existence check using |
Contributor
Main page files (e.g., resources/clusterroletemplate.mdx) are now manually maintained following the vcluster pattern where partials are auto-generated but main pages are always manual. This allows adding custom documentation sections like platform-specific RBAC verbs that won't be overwritten by loft-bot regeneration. Partials (reference.mdx, create.mdx, etc.) continue to be regenerated on each run. Closes DOC-1196
8a7ce12 to
fe2fb7e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stop generating main API resource pages (
platform/api/resources/*.mdx). Only generate partials (platform/api/_partials/resources/*/).Problem
Automated API docs generation (loft-bot PRs) overwrites manually-added documentation sections in platform API resource files:
clusterroletemplate.mdx- Policy rules sectionclusters.mdx- Platform-specific verbs sectionteam.mdx- Platform-specific verbs sectionuser.mdx- Platform-specific verbs sectionSolution
Follow the vcluster pattern: partials are auto-generated, main pages are manually maintained.
Technical Details
What the generator does NOW (after this PR)
When
go run ./hack/platform/partials/main.goruns:platform/api/_partials/resources/directory (line 30 in main.go)_partials/resources/<resource>/reference.mdx- schema reference docs_partials/resources/<resource>/create.mdx- create examples (if enabled)_partials/resources/<resource>/retrieve.mdx- retrieve examples (if enabled)_partials/resources/<resource>/update.mdx- update examples (if enabled)_partials/resources/<resource>/delete.mdx- delete examples (if enabled)platform/api/resources/What the generator did BEFORE (the problem)
Same as above, but also:
resources/<resource>.mdx) usingTemplateObjectOverviewtemplateCode changes
hack/platform/util/schema.go:
writeTemplate(TemplateObjectOverview, ...)call at the end ofGenerateObjectOverview()relPathcalculation that was only used for main page generationhack/platform/util/template_overview.go:
TemplateObjectOverviewandObjectOverviewValueswhich are no longer usedHow main pages work
Main pages import and render the auto-generated partials:
When schema changes:
Impact on existing workflow
What happens for NEW resources?
When adding a new resource to
main.go:_partials/resources/<new-resource>/resources/<new-resource>.mdxVerified behavior
Ran generator and confirmed:
_partials/resources/clusterroletemplates/reference.mdx- regenerated (timestamp updated)_partials/resources/clusterroletemplates/create.mdx- regenerated (timestamp updated)resources/clusterroletemplate.mdx- untouched (timestamp unchanged, git diff empty)Note on unused
FilefieldThe
ObjectInformation.Filefield is still passed frommain.gobut is now ignored. This could be cleaned up in a follow-up PR but is harmless.Testing
go build ./hack/platform/...passesCloses DOC-1196