rest_framework.utils.formatting

Utility functions to return a formatted name and description for a given view.

Module Contents

remove_trailing_string(content, trailing)

Strip trailing component trailing from content if it exists. Used when generating names from view classes.

dedent(content)

Remove leading indent from a block of text. Used when generating descriptions from docstrings.

Note that python’s textwrap.dedent doesn’t quite cut it, as it fails to dedent multiline docstrings that include unindented text on the initial line.

camelcase_to_spaces(content)

Translate ‘CamelCaseNames’ to ‘Camel Case Names’. Used when generating names from view classes.

markup_description(description)

Apply HTML markup to the given description.