-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
Add code fencing example in the style guidlines #12783
Conversation
c348a8e
to
a444f1a
Compare
Deploy preview for kubernetes-io-master-staging ready! Built with commit c348a8e https://deploy-preview-12783--kubernetes-io-master-staging.netlify.com |
a444f1a
to
0558760
Compare
Deploy preview for kubernetes-io-master-staging ready! Built with commit a444f1a https://deploy-preview-12783--kubernetes-io-master-staging.netlify.com |
0558760
to
96b59e7
Compare
Deploy preview for kubernetes-io-master-staging ready! Built with commit 8bbf749 https://deploy-preview-12783--kubernetes-io-master-staging.netlify.com |
96b59e7
to
9a0094f
Compare
/assign @Bradamant3 |
just a note to let people know that the
vs
|
@@ -110,6 +110,12 @@ document, use the backtick (`). | |||
<tr><th>Do</th><th>Don't</th></tr> | |||
<tr><td>The <code>kubectl run</code> command creates a Deployment.</td><td>The "kubectl run" command creates a Deployment.</td></tr> | |||
<tr><td>For declarative management, use <code>kubectl apply</code>.</td><td>For declarative management, use "kubectl apply".</td></tr> | |||
<tr><td>For bash code use <code>shell</code>.</td><td>For bash use <code>bash</code> or <code>sh</code>.</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.
This seems confusing. What should I use for code written for a POSIX shell? What about for code that specifically expects bash
?
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.
What about for code that specifically expects
bash
?
do you have an example for that ?
I have a question about code fencing style. example (using "^" instead of "`") ^^^shell ^^^???
|
@makocchi-git I asked a similar question as part of #12739 |
@makocchi-git i could be missing s'thing here, why a command output can't be formatted like "```" ? Maybe the reviewers can chime in and clarify a bit but imo using backtick instead of "^^^" is better |
/hold Thanks for the PR and for all the related discussions in the related issue and PR. But can you say a bit more about why we need this PR and especially the enforcement of it (which I see others offering in related PRs)? We don't have syntax highlighting in the docs output for snippets in different languages, so this isn't something that affects the visible usability of the docs, and it's hard to imagine enforcing compliance going forward. We've tried pretty hard to keep the style guide simple, and compliance is already an ongoing point of discussion. So I'm concerned about adding complexity when the UX value isn't clear. (In any case, this wouldn't be the right place for the proposed recommendations -- the section that's added to is about inline code formatting, not about fenced code blocks.) |
@Bradamant3 thank you for taking the time to review it
For someone new to the code base it could be very confusing to pick the option:
You can argue that everyone can use whatever they want but i thought that since there is a style guide then whoever is reviewing the PR will be aware of it and will try to enforce it
I agree it doesn't add value from user perspective (ie - business value if i can use this term) however from code/ developer perspective i personally believe there is some value - see above. Also i personally like to keep code clear/ clean
okay, fair point
i used this section because in the guide it says
There is no specific section for code fencing however i'm happy to change it - just let me know your preference |
@DanyC97 Thank you for the PR. All, thanks for the discussion. All things considered, I recommend keeping it simple: just use a triple backtick, and don't try to specify what kind of code it is. Based on my experience with this doc set, I don't think authors and reviewers will go to the trouble of making sure every code snippet has the proper language or shell label. Given that the labels have no effect on the rendered pages, I don't see the point in working toward making the docs adhere to this more specific form of labeling code snippets. |
@steveperry-53 I'm not sure I've understood what you're saying here, specifically:
I see that https://kubernetes.io/docs/reference/kubectl/cheatsheet/#bash renders with highlighting, and that's something I find useful. It sounds like you might be saying that the highlighting there doesn't happen, or maybe that all code blocks are highlighted using the same rules whatever way they are labelled. |
in addition to what @sftim said, let me add my comments @steveperry-53
if that is the case (although i do love coloring like @sftim already mentioned) fine but i'd like to see consistency across the board. i.e - strip all md files to adhere to this new rule if that is the case
happy to be the picky person in order to help with the compliance and keep the docs aligned with the guidelines
if that is the case then how come other pages do show some differences ?I'm aware of a page which use a custom shortcode but everyone else doesn't and nobody is using the built in hugo highlights shortcode |
@DanyC97, Maybe I'm wrong about not getting highlighting differences. @Bradamant3, do you know whether the labels on code fences make any difference in the rendered snippets? |
Thanks @zacharysarah for the clear and sensible summary. @steveperry-53 I haven't seen other examples like the ones that sftim and Zach point to -- I think it's fair to say they're not common. I also thought I'd seen plenty of examples marked as |
thank you all for taking the time to review and provide your input, much appreciated. @zacharysarah regarding
fair point, thank you 👍 |
052816e
to
6b886a0
Compare
6b886a0
to
826663a
Compare
@zacharysarah pls help review |
@zacharysarah maybe for another PR i think we can (if you agree) standardize on the guidelines expressed here And in that way we can kill 2 birds with 1 stone:
|
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.
@DanyC97 Some more feedback.
</table> | ||
|
||
{{< note >}} Syntax highlighting is supported but optional {{< /note >}} |
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.
Make sure to end the sentence with a period. It's also helpful to specify what this is related to.
{{< note >}}
The website supports syntax highlighting for code samples, but specifying a language isn't required. For example, you can enable highlighting for Python samples by enclosing the sample like so:
<code>```py
import foo
```</code>.
{{< /note >}}
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.
feedback taken, thanks.
just added the word ,is optional
826663a
to
587a2a5
Compare
@zacharysarah let me know if anything else is missing |
/sig docs |
</table> | ||
|
||
{{< note >}} | ||
The website supports syntax highlighting for code samples, but specifying a language isn't required, is optional. For example, you can enable highlighting for Python samples by enclosing the sample like so: |
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.
@DanyC97 One final nit. Let's use this wording instead:
The website supports syntax highlighting for code samples, but specifying a language is optional.
Otherwise LGTM 👍
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.
done @zacharysarah
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.
@DanyC97 Be sure to remember the period at the end. 😉
/hold cancel |
587a2a5
to
99c0bac
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: zacharysarah 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 |
* Add code fencing example in the style guidlines * Add a period
* Add code fencing example in the style guidlines * Add a period
This PR should bring more clarity on the code fencing style guidelines.