-
Notifications
You must be signed in to change notification settings - Fork 104
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
Fix usage and hyperlinks in kubectl reference #142
Fix usage and hyperlinks in kubectl reference #142
Conversation
…ending ] as part of the clickable url.
…ssing from the usage.
Generating a preview now... |
Here is a kubectl reference docs preview generated using the code in this PR: |
/assign @steveperry-53 |
/cc @kbhawkey |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: brianpursley, tengqm 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 |
👀 |
@@ -250,7 +250,9 @@ func WriteCommandFile(manifest *Manifest, t *template.Template, params TopLevelC | |||
"|", "|", | |||
"<", "<", | |||
">", ">", | |||
) | |||
"[", "<span>[</span>", | |||
"]", "<span>]</span>", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously:
[<a href="http://golang.org/pkg/text/template/#pkg-overview]">http://golang.org/pkg/text/template/#pkg-overview]</a>. </td>
Now (from generated sample (https://deploy-preview-19864--kubernetes-io-master-staging.netlify.com/docs/reference/generated/kubectl/kubectl-commands#-em-poddisruptionbudget-em-):
<td>Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates <span>[</span><a href="http://golang.org/pkg/text/template/#pkg-overview">http://golang.org/pkg/text/template/#pkg-overview</a><span>]</span>. </td>
</tr>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It just wraps the square brackets in spans, so they don't get merged into the hyperlink url. Probably only needed to do that for the closing square bracket but wanted to be consistent.
Do you think that will cause a problem for it to render that way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way this should remove the need to do the manual fix that used to have the be performed every time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand. What happened to the middle ]
bracket in the original ref?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The middle ], the one that got attached to #pkg-overview]
is gone... it wasn't supposed to be part of the URL.
The problem was that having ] directly after the URL, with no spaces, was messing up the markdown processor, and it was considering it to be part of the URL.
The problem arises because kubectl's cobra command is not trying to generate markdown, but the reference-docs generator is taking the output from kubectl and running it through a markdown processor and some things like [ ] are being interpreted as markdown's URL syntax when really it should be treated more like parentheses.
There isn't a great way to escape ] in markdown, so a solution (the one I chose in this PR) is to wrap it with so that markdown won't try to interpret it as a symbol to be processed.
For reference, if you run kubectl apply --help
here is the part where this shows up:
--template='': Template string or path to template file to use when -o=go-template, -o=go-template-file. The
template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
But again, this is in the command-line output, which is not markdown, so it displays fine in the command line because there is no markdown processor to mess it up.
I hope that I have understood and answered your question. Let me know if I haven't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @brianpursley . I wanted to know what happened to the extra ]
and assumed that the parser no longer generated this character because of the new formatting. Your solution works around the problem. Ideally, the kubectl
text formatting corrections could be made in the upstream code. There are a number of fixes in this code for formatting issues.
/lgtm
Fixes command usage missing
kubectl
Fixes subcommand usage missing
kubectl <maincommand>
Fixes problem with hyperlinks surrounded by [ ] not displaying correctly...
Fixes kubernetes/website#18444