MCPcopy Index your code
hub / github.com/Breakthrough/PySceneDetect / add_backquotes_with_refs

Function add_backquotes_with_refs

docs/generate_cli_docs.py:113–128  ·  view source on GitHub ↗

Returns a transformation function that backquotes command examples, adding backquotes and references to any found options.

(refs: set[str])

Source from the content-addressed store, hash-verified

111
112
113def add_backquotes_with_refs(refs: set[str]) -> ty.Callable[[str], str]:
114 """Returns a transformation function that backquotes command examples, adding backquotes and
115 references to any found options."""
116
117 def _add_backquotes(s: re.Match) -> str:
118 to_add: str = s.string[s.start() : s.end()]
119 flag = re.search(r"-+[\w-]+[^\.\=\s\/]*", to_add)
120 if flag is not None and flag.string[flag.start() : flag.end()] in refs:
121 # add cross reference
122 cross_ref = flag.string[flag.start() : flag.end()]
123 option = s.string[s.start() : s.end()]
124 return f":option:`{option} <{cross_ref}>`"
125 else:
126 return add_backquotes(s)
127
128 return _add_backquotes
129
130
131def extract_default_value(s: str) -> tuple[str, str | None]:

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected