-
Notifications
You must be signed in to change notification settings - Fork 880
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
Format markdown files and rust code blocks in markdown files #5909
base: master
Are you sure you want to change the base?
Commits on Sep 12, 2023
-
Make ParseSess an optional arg to FormatHandler::handle_formatted_file
The only implementaiton of the `FormatHandler` trait is the one implemented for `Session`, and in that implementation we pass the `ParseSess` to `source_file::write_file`, which also takes the `ParseSess` as an optional argument. looking at the implementation of `source_file::write_file`, the `ParseSess` is optionally used to determine the file's original line ending instead of reading the file from the file system again to do so. Given the above explanation, I don't think there's any issue changing the signature of `FormatHandler::handle_formatted_file` and the implementation of `FormatHandler for Session`.
Configuration menu - View commit details
-
Copy full SHA for 6752286 - Browse repository at this point
Copy the full SHA 6752286View commit details -
update visibility of items related to markdown code block formatting
The visibility of several private items in comments.rs were updated to `pub(crate)`. These items will help when adding support for formatting rust code blocks in markdown files.
Configuration menu - View commit details
-
Copy full SHA for 0d4c4f6 - Browse repository at this point
Copy the full SHA 0d4c4f6View commit details -
add
CodeBlockAttribute::is_formattable_rust
methodA helper method used to determine if the code block contains rust code that should be formatted. This will help when implementing rust code block formatting in markdown files.
Configuration menu - View commit details
-
Copy full SHA for 1adcbf1 - Browse repository at this point
Copy the full SHA 1adcbf1View commit details -
Configuration menu - View commit details
-
Copy full SHA for beef9c5 - Browse repository at this point
Copy the full SHA beef9c5View commit details -
Configuration menu - View commit details
-
Copy full SHA for b87db9c - Browse repository at this point
Copy the full SHA b87db9cView commit details -
implement formatting code blocks in markdown files
The `rewrite_markdown` function will take markdown as input and apply rustfmt on rust code blocks. Because of how `pulldown-cmark-to-cmark` is implemented there will be some light rewriting of the markdown file outside of code block reformatting. This mostly relates to updating newlines after markdown elements like headers and lists, and possibly updating the indentation of indented code blocks. In the future we may even consider implementing doc comment rewriting in terms of `rewrite_markdown`.
Configuration menu - View commit details
-
Copy full SHA for 2295119 - Browse repository at this point
Copy the full SHA 2295119View commit details -
Allow users to format rust code in markdown code blocks
Now users can envoke rustfmt directly with a markdown file and the rust code within that file will be reformatted e.g. `rustfmt README.md`
Configuration menu - View commit details
-
Copy full SHA for 35c2f31 - Browse repository at this point
Copy the full SHA 35c2f31View commit details -
Allow mardown files in system tests
This will make it easeir to write tests for markdown codeblock reformatting.
Configuration menu - View commit details
-
Copy full SHA for 079c3af - Browse repository at this point
Copy the full SHA 079c3afView commit details -
Configuration menu - View commit details
-
Copy full SHA for f445fee - Browse repository at this point
Copy the full SHA f445feeView commit details