lib.text

Text related utilities for Django Docutils.

django_docutils.lib.text.is_uncapitalized_word(value)[source]

Return True if term/word segment is special uncap term (e.g. “django-“).

Parameters:

value (str) – string value from template

Returns:

True if term or word is uncapitalized.

Return type:

bool

Functions can be declared via DJANGO_DOCUTILS_TEXT in django settings via string imports. The filters accept one argument (the word). If you don’t want the word/pattern capitalized, return True. Anything else capitalizes as normal.

How to create filters:

def handle_uncapped_word(value: str) -> bool:
    if value.startswith('django-'):
        return True
    if 'vs' in value:
        return True
    return False

In your settings:

DJANGO_DOCUTILS_LIB_TEXT = {
    'uncapitalized_word_filters': [
        'project.path.to.handle_uncapped_word'
    ]
}
django_docutils.lib.text.smart_capfirst(value)[source]

Capitalize the first character of the value.

Return type:

str

Parameters:

value (str)

django_docutils.lib.text.smart_title(value)[source]

Convert a string into titlecase, except for special cases.

Django can still be capitalized, but it must already be like that.

Return type:

str

Parameters:

value (str)