Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

litgen options

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 everything

  • Multiple 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:

Loading...

srcmlcpp options

litgen is based on srcmlcpp, which also provides some options, via LitgenOptions.srcmlcpp_options. They are available at srcmlcpp/srcmlcpp_options.py

Loading...