sphinx-autoapi/autoapi/utils.py

16 lines
347 B
Python
Raw Normal View History

import unicodedata
import re
# From Django
2019-01-27 05:20:45 +00:00
def slugify(value):
"""
Converts to lowercase, removes non-word characters (alphanumerics and
underscores) and converts spaces to hyphens. Also strips leading and
trailing whitespace.
"""
2019-01-27 05:20:45 +00:00
value = re.sub(r"[^\w\s-]", "", value).strip()
return re.sub(r"[-\s]+", "-", value)