Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: quotes are displayed as " in description of kubebuilder markers on CRD Validation page #3534

Closed
tenstad opened this issue Aug 14, 2023 · 5 comments
Assignees
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. kind/documentation Categorizes issue or PR as related to documentation.

Comments

@tenstad
Copy link

tenstad commented Aug 14, 2023

What broke? What's expected?

See expanded description of +kubebuilder:default on CRD Validation, which appears to come from controller-tools/pkg/crd/markers/validation.go

The struct should be {policy: "delete"}, not {policy: "delete"}.

@tenstad tenstad added the kind/bug Categorizes issue or PR as related to a bug. label Aug 14, 2023
@camilamacedo86
Copy link
Member

Hi @tenstad,

Thank you for raising it. Yes, the descriptions came from controller-tools project. Therefore, the content:

Screenshot 2023-08-14 at 15 02 51

IN: https://github.com/kubernetes-sigs/kubebuilder/blob/master/docs/book/src/reference/markers/crd-validation.md?plain=1

Then, the implementation which is responsible for generate this documentation can be found in: https://github.com/kubernetes-sigs/kubebuilder/tree/master/docs/book/utils/markerdocs

Also, see: https://github.com/kubernetes-sigs/kubebuilder/blob/master/docs/book/markerdocs.sh

So, in order to address the issue described here is required to change its implementation in order to properly handle ".

I will mark as help wanted and it might also be a good first issue. However, is required be able to analyse the code to know how properly change it out. Either is possible to verify the change in the doc preview which is available for each PR done against master, see;

Screenshot 2023-08-14 at 15 10 22

@camilamacedo86 camilamacedo86 added help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. kind/documentation Categorizes issue or PR as related to documentation. labels Aug 14, 2023
@typeid
Copy link
Contributor

typeid commented Aug 15, 2023

Would be interested in picking up this issue, if that's okay :)

@typeid
Copy link
Contributor

typeid commented Aug 15, 2023

/assign

@typeid
Copy link
Contributor

typeid commented Aug 15, 2023

I believe the issue is the following:

  • we are using markerdocs as mdBook preprocessor to generate most of our References section (e.g. CRD Validation)
  • this preprocessor writes HTML but the text fields also contain markdown (e.g. this line)
  • we call html.EscapeString() on the output of the preprocessor (see here)
  • the preprocessed output is then parsed as markdown by mdBook

Basically, the issue doesn't seem to be the quotation marks, but the backticks. mdBook handles the content as raw strings (code block) and doesn't unescape the quotation marks.

  1. Raw text:
 object: `{policy: "delete"}`
  1. Preprocessor wraps it with HTML in escaped format
object: `{policy: "delete"}`
  1. mdBook picks up on the markdown backticks and further wraps it in the according HTML without interpreting the escaped characters:
<code class="hljs">{policy: &#34;delete&#34;}</code>

I'm not yet sure how to move forward with this.
One possibility might be to modify the writeHTML function to not call html.EscapeString on the parts of the string that are between backticks.

@camilamacedo86
Copy link
Member

It seems fixed so I am closing this one.
Feel free to re-open if you see a need for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. kind/bug Categorizes issue or PR as related to a bug. kind/documentation Categorizes issue or PR as related to documentation.
Projects
None yet
Development

No branches or pull requests

3 participants