Skip to content

Conversation

@camilamacedo86
Copy link
Member

@camilamacedo86 camilamacedo86 commented Nov 2, 2025

The following changes impact mainly the tutorials.
To review see:

Documentation Improvements Summary

Changes

New Features:

  • Added copy-to-clipboard buttons on code blocks
  • Added "(click to expand/collapse)" hints
  • Soft collapse styling (no icons, italic text)

Layout:

  • Content width: 95% (wider)
  • Code padding: 0.5em (reduced)
  • Tab-size: 2 (compact)

Content Cleanup:

  • Hidden Apache License blocks (23 instances)
  • Hidden closing braces in tests
  • Removed 3 duplicate collapse markers
  • Fixed extra } appearing outside code blocks

Label Updates:

  • "Clock" → "Clock Code Implementation"
  • "Go imports" → "Imports"
  • "Validate object name" → "validateCronJobName() Code Implementation"
  • "old stuff" → "Remaining code from "
  • "The rest of Spec" → "CronJobSpec Full Code"

Closes: #4862

@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 2, 2025
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Nov 2, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: camilamacedo86

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

The pull request process is described here

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 approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Nov 2, 2025
@camilamacedo86 camilamacedo86 force-pushed the docs-css-improvements branch 3 times, most recently from b0f9039 to b1949ee Compare November 2, 2025 23:57
@camilamacedo86 camilamacedo86 changed the title WIP: Docs css improvements 📖 Documentation Improvements Nov 3, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 3, 2025
@camilamacedo86 camilamacedo86 changed the title 📖 Documentation Improvements 📖 Improve collapsible code sections and formatting of tutorials Nov 3, 2025
@camilamacedo86 camilamacedo86 force-pushed the docs-css-improvements branch 2 times, most recently from 7c8ceca to 691368a Compare November 3, 2025 09:28
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 3, 2025
Copy link
Contributor

@vitorfloriano vitorfloriano left a comment

Choose a reason for hiding this comment

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

The copy button seems to not be working correctly when we insert the code using the directive {{#literatego}}.

As a suggestion, what would happen if we wrapped the directives in a codeblock, like this:

```go
{{#literatego ./getting-started/testdata/project/api/v1alpha1/memcached_types.go}}
```

Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @camilamacedo86 I was taking a look at the preview and noticed that the copy button is duplicated in some blocks, like in here:

Image

But in other codeblocks, it isn't, like in here:

Image

It led me to think that mdBook adds the copy button by default. If you take a look at the current state of the docs, that same codeblock that has duplicated buttons already features the button, as seen in here:

Image

The codeblock that does not have a duplicated button does not feature the button in the current docs, as seen in here:

Image

So, IMO, we could investigate what's causing the button to not be rendered in some codeblocks, instead of adding a custom script for that.

# Enable copy button on code blocks
copy-fonts = true
# Improve code block rendering
code-block-copy-button = true
Copy link
Contributor

Choose a reason for hiding this comment

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

If it's set by default, should we still add this? Also, I can't see the option code-block-copy-button in the mdBook docs, which only mention copyable.

@vitorfloriano
Copy link
Contributor

@camilamacedo86 I suggested ealier that we tried wrapping the {{#literatego}} directives in a codeblock, but that could create another problem: In some parts of the docs, we insert the whole file into a markdown file, and add the rest of the page in the tutorial as comments in that file. If we wrap everything in a codeblock, the docs inserted as comments in those files may not work properly.

And that raises the question: why do we start some parts in a markdown file, then continue the page by inserting comments in the file that was inserted?

As an example, let's consider this page: https://book.kubebuilder.io/cronjob-tutorial/empty-main

We start it here: https://github.com/kubernetes-sigs/kubebuilder/blob/master/docs/book/src/cronjob-tutorial/empty-main.md

Then we insert this file: https://github.com/kubernetes-sigs/kubebuilder/blob/master/docs/book/src/cronjob-tutorial/testdata/emptymain.go

And then we add comments to that file to continue the instructions in the page.

So, couldn't we keep all the instruction in markdown files, and add only the sections of code that we need? That way, we could wrap each section in a codeblock, to be rendered properly, with the copy button.

See: https://rust-lang.github.io/mdBook/format/mdbook.html?highlight=hide#including-portions-of-a-file

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. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants