datamodel-code-generator
datamodel-code-generator copied to clipboard
Split long descriptions on multiple lines
Description strings are currently injected as a single line, which is troublesome for long strings. We should ideally split them across multiple lines in such cases:
class Cfg(BaseModel):
b: Optional[str] = Field(
None,
description="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut arcu velit, fringilla nec enim dictum, luctus bibendum dui. Maecenas eget ex ac velit auctor mollis. Integer enim ex, pharetra sed sapien id, tincidunt fermentum eros.",
)
class Cfg(BaseModel):
b: Optional[str] = Field(
None,
description=(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut arcu velit, fringilla nec enim dictum, luctus "
"bibendum dui. Maecenas eget ex ac velit auctor mollis. Integer enim ex, pharetra sed sapien id, tincidunt"
" fermentum eros."
),
)
For this the user should perhaps pass some target line length 👍
@gaborbernat Thank you for your great suggestion. OK, I will add the CLI Option.
@gaborbernat
I have forgotten to write this comment.
I added this feature as --wrap-string-literal to version 0.11.11
How come the generated strings are now quoted with ' instead of "?
@gaborbernat I'm sorry for my late reply 🙇
How come the generated strings are now quoted with ' instead of "?
I think the problem is related skip-string-normalization option in toml.
Could you show me your pyproject.toml?