Configuration¶
reprexlite has the following configuration options.
Note
Command-line option names for these configuration variables use hyphens instead of underscores.
Name | Type | Description |
---|---|---|
editor |
Optional[str] |
Command-line program name of editor to use. If not specified, check $EDITOR and $VISUAL environment variables. If 'ipython', will launch the IPython interactive editor. |
venue |
reprexlite.config.Venue |
Key to identify the output venue that the reprex will be shared in. Used to select an appropriate formatter. See "Venues Formatting" documentation for formats included with reprexlite. |
advertise |
Optional[bool] |
Whether to include a footer that credits reprexlite. If unspecified, will depend on specified venue formatter's default. |
session_info |
bool |
Include details about session and environment that the reprex was generated with. |
style |
bool |
Whether to autoformat code with black. Requires black to be installed. |
prompt |
str |
Prefix to use as primary prompt for code lines. |
continuation |
str |
Prefix to use as secondary prompt for continued code lines. |
comment |
str |
Prefix to use for results returned by expressions. |
keep_old_results |
bool |
Whether to additionally include results of expressions detected in the original input when formatting the reprex output. |
parsing_method |
reprexlite.config.ParsingMethod |
Method for parsing input. 'auto' will automatically detect either default reprex-style input or standard doctest-style input. 'declared' will allow you to specify custom line prefixes. Values for 'prompt', 'continuation', and 'comment' will be used for both output formatting and input parsing, unless the associated 'input_*' override settings are supplied. |
input_prompt |
Optional[str] |
Prefix to use as primary prompt for code lines when parsing input. Only used if 'parsing_method' is 'declared'. If not set, 'prompt' is used for both input parsing and output formatting. |
input_continuation |
Optional[str] |
Prefix to use as secondary prompt for continued code lines when parsing input. Only used if 'parsing_method' is 'declared'. If not set, 'prompt' is used for both input parsing and output formatting. |
input_comment |
Optional[str] |
Prefix to use for results returned by expressions when parsing input. Only used if 'parsing_method' is 'declared'. If not set, 'prompt' is used for both input parsing and output formatting. |
Configuration files¶
reprexlite supports reading default configuration values from configuration files. Both project-level files and user-level files are supported.
pyproject.toml
¶
reprexlite will search the nearest pyproject.toml
file in the current working directory and any parent directory.
Configuration for reprexlite should be in the [tool.reprexlite]
table following standard pyproject.toml
specifications. For example:
[tool.reprexlite]
editor = "some_editor"
reprexlite.toml
or .reprexlite.toml
¶
reprexlite also supports files named reprexlite.toml
or .reprexlite.toml
for project-level configuration. It will also search for these in the current working directory or any parent directory.
For reprexlite-specific files, all configuration options should be declared in the root namespace.
editor = "some_editor"
User-level configuration¶
reprexlite supports searching standard platform-specific user configuration directories as determined by platformdirs. Here are typical locations depending on platform:
Platform | Path |
---|---|
Linux | ~/.config/reprexlite/config.toml |
MacOS | ~/Library/Application Support/reprexlite/config.toml |
Windows | C:\Users\<username>\AppData\Local\reprexlite\config.toml |
You can check where your user configuration would be with
python -m platformdirs
Look for the section -- app dirs (without optional 'version')
for the value of user_config_dir
. The value for MyApp
is reprexlite
. The configuration file should be named config.toml
inside that directory.