How do we best display code examples on MDN Web Docs? #111
Replies: 5 comments 1 reply
-
I have implemented some features to the code block. That will further improve the user experience: lineNo.movDetailed info is on the PR page: mdn/yari#6372 As the wrapped lines become more distinguishable, it may save us from manually chopping the long lines in markdown code fences. Also, it seems we detest limiting the line length. Linting PRsWe shouldn't make contribution process confusing/hard. With current lint configurations, during daily manual linting, we are finding only 4-5 fills with small issues. Refer https://github.com/mdn/content/pull/16315/files. Also, automatic changes to code may lead to merge conflicts in local repos. Daily lint PRsIf we lint once a day, there will be one less step getting the PR merged. Also, no lint issue will get skipped. To add a new lint rule it's good to fix it in the entire repo first then add it to the daily task. @teoli2003 has explained it well. |
Beta Was this translation helpful? Give feedback.
-
Comment from @OnkarRuikar in mdn/yari#6372 (comment):
|
Beta Was this translation helpful? Give feedback.
-
Additional input from @hamishwillee: |
Beta Was this translation helpful? Give feedback.
-
Just want to jump in on this. Docusaurus (which both Alexey and I are maintainers of) uses a toggle button between "wrapping" and "non-wrapping" mode: https://docusaurus.io/tests/pages/code-block-tests#code-block-wrapping-tests Line numbers are not necessary IMO since I've never found a need to say "look at line X" where it's not convertible to a comment. Highlight lines are implemented in Docusaurus as "magic comments": https://docusaurus.io/docs/markdown-features/code-blocks#highlighting-with-comments They are not necessary on MDN, though, since it's very hard to create a uniform rule about when and where we should use highlight lines, and comments convey the semantics better. |
Beta Was this translation helpful? Give feedback.
-
I'm closing this due to linting updates which have happened. If anyone wants to suggest any other updates to code blocks, feel free to open an issue on yari 👍 |
Beta Was this translation helpful? Give feedback.
-
In mdn/yari#6083 @lex111 proposed a change to how
pre
blocks are currently styled and displayed. Quoting from the pull request:In the following comment @caugner made a valid point that the change might degrade the experience for some users. Quoting from the pull request:
A conversation has evolved from there, so I believe it is a good time to start a discussion and reach an actionable conclusion. As mentioned in this comment, I do believe we can improve the current user experience by combining @lex111’s proposal with @caugner’s suggestion and merging the referenced pull request.
There is a larger topic in play here related to linting code examples within the content and applying standard formatting using a tool such as Prettier as mentioned by @Rumyra.
There are valuable suggestions from others in the pull request thread as well, which should also be taken into account here.
Related issues
Historic reference
Beta Was this translation helpful? Give feedback.
All reactions