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

Add multiline doc logic to the pretty printer #1048

Merged
merged 2 commits into from
Jan 17, 2023

Conversation

vkleen
Copy link
Contributor

@vkleen vkleen commented Jan 17, 2023

This PR makes the pretty printer emit multiline strings if it encounters documentation metadata containing newlines. Previously, as I complained about in #1044, the pretty printer would unconditionally insert a hard newline after the opening double quote. Additionally, it would indent the documentation string and thereby change the semantics of the code.

With this PR, multiline strings are used when necessary and single line strings are used whenever the docstring does not contain newlines. Additionally, there's a regression test using the new snapshot testing infrastructure.

Closes #1044

src/pretty.rs Outdated Show resolved Hide resolved
@github-actions github-actions bot temporarily deployed to pull request January 17, 2023 14:30 Inactive
src/pretty.rs Outdated Show resolved Hide resolved
src/pretty.rs Outdated Show resolved Hide resolved
src/pretty.rs Show resolved Hide resolved
@vkleen vkleen merged commit 9453ad6 into master Jan 17, 2023
@vkleen vkleen deleted the pretty-printer-doc-metadata branch January 17, 2023 17:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pretty printer produces spurious newlines
3 participants