pyproject_parser.utils

Utility functions.

Exceptions:

PyProjectDeprecationWarning

Warning for the use of deprecated features in pyproject.toml.

Functions:

content_type_from_filename(filename)

Return the inferred content type for the given (readme) filename.

render_markdown(content)

Attempt to render the given content as Markdown.

render_rst(content[, filename])

Attempt to render the given content as ReStructuredText.

exception PyProjectDeprecationWarning[source]

Bases: Warning

Warning for the use of deprecated features in pyproject.toml.

This is a user-facing warning which will be shown by default. For developer-facing warnings intended for direct consumers of this library, use a standard DeprecationWarning.

New in version 0.5.0.

content_type_from_filename(filename)[source]

Return the inferred content type for the given (readme) filename.

Parameters

filename (Union[str, Path, PathLike])

Return type

Literal['text/markdown', 'text/x-rst', 'text/plain']

render_markdown(content)[source]

Attempt to render the given content as Markdown.

Attention

This function has the following additional requirements:

docutils>=0.16
readme-renderer[md]>=27.0

These can be installed as follows:

python -m pip install pyproject-parser[readme]
Parameters

content (str)

render_rst(content, filename='<string>')[source]

Attempt to render the given content as ReStructuredText.

Attention

This function has the following additional requirements:

docutils>=0.16
readme-renderer[md]>=27.0

These can be installed as follows:

python -m pip install pyproject-parser[readme]
Parameters

Changed in version 0.8.0: Added the filename argument.