ska_sdp_piper.piper.configurations.doc_utils module

ska_sdp_piper.piper.configurations.doc_utils.is_nullable(annotation)[source]
Return type:

bool

ska_sdp_piper.piper.configurations.doc_utils.get_allowed_values(annotation)[source]
Return type:

list

ska_sdp_piper.piper.configurations.doc_utils.convert_description_to_line_string(desc)[source]

Converts the description of config param to a single line string suitable for sphinx node parsing

Parameters:

desc (str)

Return type:

str

Returns:

Description converted to a single line, with any indents removed

ska_sdp_piper.piper.configurations.doc_utils.convert_allowed_values_to_string(values)[source]

Convert "allowed values" parameter of Config Param to a string.

Parameters:

values (Iterable[Any] | None)

Return type:

str

Returns:

String representation of allowed values

ska_sdp_piper.piper.configurations.doc_utils.get_resolved_path(tp)[source]

Gets the fully qualified name of a type For builtins like int, str; the module name i.e. 'builtins' is not part of the output.

Return type:

str

Examples

>>> get_resolved_path(int)
"int"
>>> get_resolved_path(Any)
"typing.Any"
ska_sdp_piper.piper.configurations.doc_utils.convert_type_to_reST_string(tp)[source]

Convert a type to string compatible for intersphinx mapping

The input can be:

  1. single type

  2. an Annotated type — only the first arg (the actual type) is used

  3. a union type (Union or UnionType)

  4. a generic collection type (list, dict, set, etc.) — both the collection and its element types are linked

For cases 3 and 4, the types are converted to sphinx compatible string and joined using a comma.

Parameters:

tp (Type) -- type or tuple of type to convert to string

Return type:

str

Returns:

String representation of type / tuple of type

Examples

>>> convert_type_to_reST_string(int)
":py:class:`int`"
>>> convert_type_to_reST_string(float, Any)
":py:class:`float`, :py:class:`typing.Any`"
>>> convert_type_to_reST_string(float | int)
":py:class:`float` | :py:class:`int`"
>>> convert_type_to_reST_string(list[int])
":py:class:`~list`\[:py:class:`~int`\]"
>>> convert_type_to_reST_string(Annotated[int, "some metadata"])
":py:class:`~int`"