Skip to main content

DocFunction

ClassDataClassSource

DocFunction(
type: Literal["function"] = "function",
name: str,
descr: str,
args: list[DocArgument] = [],
retval: list[DocArgument] = [],
is_yield: bool = False,
f_type: FunctionType = FunctionType.FUNCTION,
prefix: str = "",
slang: str = "",
lineno: int = 0,
overloads: list[DocFunctionOverload] = []
)

The docstring and basic information of a function.

This serializable data type contains the signature of a function, and the corresponding docstring of function body, arguments, and results.

Fields​

NameTypeRequired
Description
typeLiteral["function"]The identifier of this documentation item.
namestrThe name of the function.
descrstrThe description body of the function.
argslist[DocArgument]The list of input arguments of the function.
retvallist[DocArgument]The list of returned values of the function.
is_yieldboolA flag. If it is True, the function returns an iterator.
f_typeFunctionTypeThe type of the function.
prefixstrAn optional prefix. If specified, will add it before the function name in the v2 signature.
slangstrThe internal code identifying this function. It needs to be specified when the function is a vanilla function (f_type is "function") to provide the identification of the source code.
linenointThe line number where the function is defined. If the number is unknown, this value will be 0.
overloadslist[DocFunctionOverload]The overloads of this function. If existing, will override the default docstrings.

Methods​

as_md_text​

v_1: str = self.as_md_text(renderer: ProtocolComponent)

Render as Markdown text.

Requires​

NameTypeRequired
Description
rendererProtocolComponentThe renderer providing component rendering.

Returns​

NameType
Description
v_1strThe Markdown text rendered from the function.

Properties​

is_private​

is_private: bool = self.is_private

A flag specifying whether the function is private.


str_v2​

str_v2: str = self.str_v2

Render as V2 string.

The v2 string is in the following format:

ret: type = name(arg1: type1, arg2: type2 = default2, ...)

which is more compact than the default string.