How do you style docstrings in python?

Question:

I want to style docstrings but I wasn’t able to find a clear document detailing how to go about it

"""
line 1 - I want this in bold

line 2 - I want this in italics

line 3 - I want the text color different

/n

line 4 - I want this line to have 2 blank lines ontop of it
"""

No matter the amount of blank lines I put inside the docstring they only produce a single newline for every line, the n character does nothing. Could anyone point me to how I could do things line change colors, bold, and indentation and spaces? Thank you!

EDIT:
For reference I am using pycharm, if there is a difference between how docstrings work between vscode or other IDEs

Asked By: YEETMESOMEYEEZY

||

Answers:

To include special formatting in a docstring, you can use bold, italics, or monospace text. You can also use inline code blocks by enclosing the code in backticks (“`). Here is an example:

def my_function():
    """
    This is a docstring.
    
    **Bold**, *italics*, and `monospace` text are supported.
    
    This is an inline code block: `print('Hello, world!')`
    """
    pass

You cannot change the text color or add extra blank lines inside a docstring. Docstrings are plain text, and do not support any kind of special formatting or layout. The purpose of docstrings is to document the code, not to add visual formatting.

Answered By: Pingu
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.