Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make pdoc preserve whitespace?

I'm trying to generate documentation using pdoc, where my docstrings look like this:

"""
I am a description of what a method does

:param param1: an integer
:param param2: a str
"""

I found this question: How to preserve line breaks when generating python docs using sphinx but the suggestion of prefixing each line with | did not work for me (it just showed up like this)

| :param param1: an integer | :param param2: a str

any ideas short of using \n at the end of every line?

like image 277
Colleen Avatar asked Sep 21 '15 20:09

Colleen


1 Answers

So, I've been having the same issue. Just figured it out. Pdoc uses markdown. You want to use a softbreak in mark down to tell it to create a newline while still keeping things grouped. A soft break is achieved by putting two trailing spaces at the end of the line you want to end with a new line.

You can check out this tutorial to see what I mean. http://www.markdowntutorial.com/lesson/7/

Additionally, be aware of what editor you are using. It might be removing trailing spaces! Trailing spaces removed on Python heredoc lines in PyCharm

"""
I am a description of what a method does

:param param1: an integer  <-- line ends right here with two spaces
:param param2: a str
"""
like image 162
bravosierra99 Avatar answered Oct 22 '22 07:10

bravosierra99