litgen uses numerous options which can be found here: litgen/options.py.
Note about __regex options¶
Many options in litgen end with the suffix __regex. These fields accept a RegexOrMatcher, i.e. either:
a regex string
or a callable (
Callable[[str], bool]) that decides whether a given name matches
Regex strings
Regex strings behave as usual in Python, except that an empty string "" matches nothing:
".*"→ matches everythingMultiple alternatives can be combined with
"|"(regex OR)
Example: to match exactly YourFunctionName or any function ending in _private, you can use: r"^YourFunctionName$|_private$"
Tips:
Always prefix regex strings with r (raw string) to avoid escaping issues.
Use anchors (^ and $) when you need exact matches.
Callables
Instead of a regex, you may also provide a callable, for example a lambda function that takes a single string argument (the name to match) and returns True if it matches, False otherwise.
Example: to match any name that ends with _internal, you can use:
options.fn_exclude_by_name__regex = lambda name: name.endswith("_internal")This can be useful when patterns are easier to express with Python logic than with regex.
litgen main options¶
Below, we show the content of litgen/options.py:
from codemanip import code_utils
from litgen.demo import litgen_demo
litgen_options_code = code_utils.download_url_content(
"https://raw.githubusercontent.com/pthom/litgen/main/src/litgen/options.py"
)
litgen_demo.show_python_code(litgen_options_code, title="litgen/options.py")srcmlcpp options¶
litgen is based on srcmlcpp, which also provides some options, via LitgenOptions.srcmlcpp_options. They are available at srcmlcpp
litgen_options_code = code_utils.download_url_content(
"https://raw.githubusercontent.com/pthom/litgen/main/src/srcmlcpp/srcmlcpp_options.py"
)
litgen_demo.show_python_code(litgen_options_code, title="srcmlcpp/srcmlcpp_options.py")