📖 (docs): Fix duplicate content and collapse markers in writing tests tutorial #5269
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.
📖 (docs): Fix duplicate content and collapse markers in writing tests tutorial
Fixes #5239
Problem
Duplicate Content: The page is being rendered twice, showing identical sections
Collapse Markers: Test code explanations and final instructions were hidden behind collapse markers
Root Cause
Duplicate Content
The markdown template file
docs/book/src/cronjob-tutorial/writing-tests.mdcontained duplicate sections (lines 1-25) that were identical to the rest of the page causing the{{#literatego}}directives to be processed twice.Collapse Markers
Two generation scripts were inserting collapse markers that hide content from the test page:
Changes Made
File 1:
docs/book/src/cronjob-tutorial/writing-tests.mdLines deleted: 0-25 (pre build)
Why: Lines 1-25 were an older duplicate of page content that must be removed.
File 2:
hack/docs/internal/cronjob-tutorial/writing_tests_env.goConstant:
suiteTestCleanupLine deleted: 123
Code removed:
// +kubebuilder:docs-gen:collapse=Remaining code from suite_test.goWhy: This collapse marker hides the transition comment .
File 3:
hack/docs/internal/cronjob-tutorial/writing_tests_controller.goConstant:
controllerTestLine deleted: 229
Code removed:
// +kubebuilder:docs-gen:collapse=Remaining code from cronjob_controller_test.goWhy: This collapse marker hides the final instructions about how to run tests with
go test ./....Shared Generation Code
Multiversion tutorial uses the same generation constants from
writing_tests_controller.go:Line 19 in
hack/docs/internal/cronjob-tutorial/writing_tests_controller.go:Both tutorials generate their controller test files independently using the same source constant. This means changes to the generation scripts affect both tutorials identically.
Result
No duplicate content in the writing tests
First Marker
was hiding section (
Kubebuilder also generates ...)Second Marker
was hiding section (
Adding this Job to our test CronJob ...)