Function translate_pattern

Source
pub fn translate_pattern(pattern: &str) -> String
Expand description

Translates shell-style glob pattern to regex pattern.

This implements the same logic as Sphinx’s _translate_pattern function:

  • ** matches any files and zero or more directories and subdirectories
    • matches everything except a directory separator
  • ? matches any single character except a directory separator
  • [seq] matches any character in seq
  • [!seq] matches any character not in seq

Based on Python’s fnmatch.translate but with modifications for path handling.