Newline character in doctstring not supported
See original GitHub issueMy docstrings Examples have string arguments containing newline characters. Despite being placed inside a code section, they are broken:
class WikiPage():
"""
The class for a Gitlab Wiki page. This class is used to handle a local copy of the wiki repository file (i.e., a wiki page gitlab.v4.objects.ProjectWiki or one of gitlab.v4.objects.Project.wikis)
\```
{
'content' = '# My content with newlines\n\n',
'format' = 'markdown',
...
\```
Further, Examples (google-style) are broken as well:

here’s my YAML file:
# mkdocs.yml
site_name: Grafana Wiki
theme:
name: "material"
markdown_extensions:
- pymdownx.arithmatex
plugins:
- mkdocstrings:
handlers:
python:
docstring_style: "google"
docstring_options: "true"
setup_commands:
- import sys
- sys.path.append("..")
watch:
- ..
# index.md
::: WikiPage:WikiPage
handler: "python"
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to preserve line breaks when generating python docs ...
I am using Sphinx for generating docs for a python project. The output html is not preserving the line breaks which ...
Read more >Making a string with new line characters using docstrings?...
Hi! This part of the video confused me; can someone (
Read more >Black removes newline from a multiline docstring. · Issue #1635
I am expecting black to not remove newlines from strings. ... rule if the the docstring is within three characters of the line-length...
Read more >Inconsistent Whitespace error occurrence when using Python ...
The docstring might not contain a completely valid Python statement but see that it contains a quoted string with the newline character in ......
Read more >Built-in Functions — Python 3.11.1 documentation
When compiling a string with multi-line code in 'single' or 'eval' mode, input must be terminated by at least one newline character. This...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
In the end I will close this as there’s nothing we can do: it’s how Python works. Consider this:
To Pyhon, your
\n
is not any different than a literal new line.\n
is, actually, a new line character.Two workarounds:
Feel free to further comment on this 🙂
i’ll go with raw thank you for your help!