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

Reformat MD files to limit line lengths to 80 characters #4540

Merged
merged 8 commits into from
Aug 6, 2024

Conversation

MichaelSimons
Copy link
Member

@MichaelSimons MichaelSimons commented Aug 6, 2024

This is in response to https://github.com/dotnet/source-build/pull/4539/files#r1705996684. I originally hoped to re-enable the MD013 rule but discovered it applies to code blocks as well. There are several places where this produces undesirable results therefore I am leaving the rule disabled but still re-formatted the MD files to limit the long lines. I used the 'Rewrap' vscode extension to reformat the files.

Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

1 similar comment
Copy link

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@MichaelSimons MichaelSimons force-pushed the md-line-length branch 5 times, most recently from 99d2e0e to fdd1469 Compare August 6, 2024 20:51
@MichaelSimons MichaelSimons changed the title Md line length Reformat MD files to limit line lengths to 80 characters Aug 6, 2024
@MichaelSimons MichaelSimons marked this pull request as ready for review August 6, 2024 21:06
@MichaelSimons MichaelSimons requested review from a team and removed request for premun and mthalman August 6, 2024 21:07
Copy link
Member

@ellahathaway ellahathaway left a comment

Choose a reason for hiding this comment

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

I'm a little disappointed that this rule can't be enabled. Do you have examples of code blocks which currently violate this rule? I'm wondering if we'd be able to adjust them to fit the line length or not.

Edit: https://github.com/DavidAnson/markdownlint/blob/main/doc/md013.md seems to suggest that code_block_line_length can be specified (default is 80). I think this is the correct repo... it references markdownlint-cli which is used in our github action.

Building for unsupported architectures require cross-compilaton on the supported
platform. Determine the compatible host to build which provides
cross-compilation toolchain. [IBM has
published](https://community.ibm.com/community/user/powerdeveloper/blogs/sapana-khemkar/2023/01/13/cross-build-dotnet7-on-x86-ibm-power?CommunityKey=8cc2a1f0-6307-48cb-9178-ace50920244e)
Copy link
Member

Choose a reason for hiding this comment

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

Does the line limit not apply here because this is a link?

Copy link
Member Author

Choose a reason for hiding this comment

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

Link urls are excluded from the limit.

@MichaelSimons
Copy link
Member Author

Do you have examples of code blocks which currently violate this rule?

Yes, you can see the attempts in this PR - https://github.com/dotnet/source-build/actions/runs/10273766628/job/28428985773

A good example is the xml code snippet here - https://github.com/dotnet/source-build/blob/main/Documentation/poison-report-format.md#interpreting-the-poison-report. We are intending to give a snippet of the poison report. Reformatting it (specifically line 12) doesn't feel right to me. Other places we have code blocks that includes commands to execute. Breaking these apart across multiple will hurt the UX when they are intended to be copy/paste. I could specify the code block line length to a large value so that we can have the rule enabled. Thoughts?

@ellahathaway
Copy link
Member

I could specify the code block line length to a large value so that we can have the rule enabled. Thoughts?

This sounds good to me!

// line length
"MD013": {
"code_block_line_length": 256,
"heading_line_length": 96
Copy link
Member Author

Choose a reason for hiding this comment

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

@MichaelSimons MichaelSimons merged commit b05c0da into dotnet:main Aug 6, 2024
2 checks passed
@MichaelSimons MichaelSimons deleted the md-line-length branch August 6, 2024 22:27
@mthalman
Copy link
Member

mthalman commented Aug 7, 2024

Is there precedence for 80 characters? It seems quite unnecessarily small.

@MichaelSimons
Copy link
Member Author

Is there precedence for 80 characters? It seems quite unnecessarily small.

This is a fairly widely used practice. I personally think it is becoming a bit dated. From the internet:

Rows longer than 80 characters should be split into multiple lines where appropriate. This helps make it easier for reviewers to make review comments and for the contributors to see where the requested changes are (without scrolling). It is also easier to see the lines in split view mode when the lines don’t wrap on the screen. It will also improve the readability when using git diff.

@MichaelSimons
Copy link
Member Author

I will also note all of the MD written by @dagood followed this practice already.

@dagood
Copy link
Member

dagood commented Aug 7, 2024

FWIW, my new favorite Markdown style is to use one line per sentence. 😄 Very nice diffs for typical edits, usually short enough to not be all that annoying in the occasional non-wrapping viewer, and actually quite nice for the authoring/editing process, mechanically. Downside: less readable (IMO) before Markdown rendering is applied, which might actually influence how you write. (Still getting used to it.)

A random other thing that bugs me about 80 columns is this:

Refer to the [build
instructions](https://github.com/dotnet/installer/blob/main/README.md#build-net-from-source-source-build)
to review how to build the .NET SDK from source.

I think it's signficantly more readable to chop, but I don't think I've seen an editor/wrapper that does it this way (and sticking to what tools will give you is wise):

Refer to the
[build instructions](https://github.com/dotnet/installer/blob/main/README.md#build-net-from-source-source-build)
to review how to build the .NET SDK from source.

(For context: I also chop code rather than wrap it to generally keep it under 100 columns, and these opinions have pretty similar roots IMO.)

@MichaelSimons
Copy link
Member Author

my new favorite Markdown style is to use one line per sentence.

I've seen this. I have to say I am not the biggest fan. 😄

I agree the way links are handled by tooling is generally not the way I would prefer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants