Skip to content

Conversation

@BadisLaffet1
Copy link
Contributor

📖 (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.md contained 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.md

Lines 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.go

Constant: suiteTestCleanup
Line deleted: 123

Code removed:

// +kubebuilder:docs-gen:collapse=Remaining code from suite_test.go

Why: This collapse marker hides the transition comment .


File 3: hack/docs/internal/cronjob-tutorial/writing_tests_controller.go

Constant: controllerTest
Line deleted: 229

Code removed:

// +kubebuilder:docs-gen:collapse=Remaining code from cronjob_controller_test.go

Why: 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:

const controllerTest = `/*

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 ... )

Test execution instructions visible

Second Marker
was hiding section ( Adding this Job to our test CronJob ... )

Cleanup code explanation visible

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Dec 12, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @BadisLaffet1. Thanks for your PR.

I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Dec 12, 2025
Copy link
Member

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approved

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 13, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: BadisLaffet1, camilamacedo86

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 13, 2025
@camilamacedo86
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 13, 2025
@k8s-ci-robot k8s-ci-robot merged commit 02b1d3f into kubernetes-sigs:master Dec 13, 2025
28 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docs: We should not have the collapse with Remaining code from in the writing tests

3 participants