Python documentation (: obj: `str`) vs (str)

I read this Google Style Python Docstrings Example to understand how good Python documentation is written. But I can’t understand anything.

When documenting strings, there is such a strange notation.

For example, when documenting arguments, the documentation states that they should be written as follows:

Args: 
    arg1(str): The description for arg1

But in some other places the document writes something like:

Args: 
    param2 (:obj:`str`, optional): The second parameter.

In the second case, why is the string presented as :obj:`str`, and not just str? Why two submissions for stringsfirst? When will I use which?

+3
source share
1 answer

, Python: . -, :obj:str, Sphinx str Python.

, . docstrings ExampleError Docstrings Python :

Args:
    msg (str): Human readable string describing the exception.
    code (:obj:`int`, optional): Error code.
+1

Source: https://habr.com/ru/post/1663653/


All Articles