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

[QUESTION] Why are description strings joined with double newlines? #258

Open
dfkki123508 opened this issue Sep 13, 2022 · 3 comments
Open
Labels
enhancement New feature or request

Comments

@dfkki123508
Copy link
Contributor

For me it causes problems when trying to render markdown, e.g.

@validate()
def fun():
    """summary

    | One | Two | Three |
    |-----|-----|-------|
    | a   | b   | c     |

    | One | Two | Three |

    |-----|-----|-------|

    | a   | b   | c     |

    """

results in the spec as:

"description": "| One | Two | Three | |-----|-----|-------| | a | b | c |\n\n| One | Two | Three |\n\n|-----|-----|-------|\n\n| a | b | c |"

I did not find a possiblity to render single newlines. Can you help me?
PS: I am referring to this line:

description = "\n\n".join(docstring_parts[1:])

Thanks!

@kemingy
Copy link
Member

kemingy commented Sep 13, 2022

Hi, @dfkki123508 thanks for your feedback.

I think the parse_comments function doesn't support single newlines. There are two parts.

docstring_parts[i] = docstring_parts[i].replace("\n", " ")

This line ensures that users can write long descriptions in multiple lines.

description = "\n\n".join(docstring_parts[1:])

This line ensures that different sections (split by \n\n) will have a clear separation in the document.

I admit that we didn't cover your use case. I'll try to find a better way to handle this.

@kemingy kemingy added the bug Something isn't working label Sep 13, 2022
@dfkki123508
Copy link
Contributor Author

Thanks for the quick answer! I think a workaround is probably to use html tags, but have to try it out :)

@kemingy
Copy link
Member

kemingy commented Sep 13, 2022

Thanks for the quick answer! I think a workaround is probably to use html tags, but have to try it out :)

HTML should work. BTW, for this kind of Markdown flavor table, I guess I can only provide a <code><\code> HTML tag. I guess swagger/redoc won't render it to the real HTML table.

So, maybe using the HTML code directly will be better for your use case?

@kemingy kemingy added enhancement New feature or request and removed bug Something isn't working labels Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants