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

Keep indentation in doc comments and simplify #1082

Merged
merged 1 commit into from
Oct 4, 2024

Conversation

oxalica
Copy link
Contributor

@oxalica oxalica commented Oct 3, 2024

Leading spaces is significant for Markdown and we should not blindlessly trim them, which may break Markdown lists or code blocks.

Here we strip the minimal indentation of all non-empty doc comment lines, so we can both keep Markdown semantics and avoid unnecessary leading spaces immediately after the /// token.

Eg.

use utoipa::{OpenApi, ToSchema};

/// Summary
///
/// List:
/// - foo
///   bar
/// - baz
#[derive(ToSchema)]
struct Typ {}

The bar line is indented and should continue the previous paragraph in the first unordered list element foo. But if stripping the leading whitespaces, bar will start a new paragraph, which is incorrect.

Copy link
Owner

@juhaku juhaku left a comment

Choose a reason for hiding this comment

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

This is super 💯 Same drill could you mark the changes to the CHANGELOG in utoipa-gen since it touches it's functionality.

Leading spaces is significant for Markdown and we should not blindlessly
trim them, which may break Markdown lists or code.

Here we strip the minimal indentation of all non-empty doc comment
lines, so we can both keep Markdown semantics and avoid unnecessary
leading spaces immediately after the `///` token.
@oxalica oxalica force-pushed the feat/keep-comment-indent branch from b9e7131 to 8f266f1 Compare October 3, 2024 22:40
@oxalica oxalica requested a review from juhaku October 3, 2024 22:40
@juhaku juhaku merged commit 33e64c7 into juhaku:master Oct 4, 2024
11 checks passed
@oxalica oxalica deleted the feat/keep-comment-indent branch October 4, 2024 22:09
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.

2 participants