Skip to content

reprexlite.config

Classes

ParsingMethod

Bases: str, Enum

Methods for parsing input strings.

Attributes:

Name Type Description
AUTO str

Automatically identify reprex-style or doctest-style input.

DECLARED str

Use configured values for parsing.

ReprexConfig dataclass

ReprexConfig(
    editor: Optional[str] = None,
    venue: Venue = Venue.GH,
    advertise: Optional[bool] = None,
    session_info: bool = False,
    style: bool = False,
    prompt: str = "",
    continuation: str = "",
    comment: str = "#>",
    keep_old_results: bool = False,
    parsing_method: ParsingMethod = ParsingMethod.AUTO,
    input_prompt: Optional[str] = None,
    input_continuation: Optional[str] = None,
    input_comment: Optional[str] = None,
)

Configuration dataclass for reprexlite. Used to configure input parsing and output formatting.

Parameters:

Name Type Description Default
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.

None
venue str

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.

GH
advertise bool

Whether to include a footer that credits reprexlite. If unspecified, will depend on specified venue formatter's default.

None
session_info bool

Include details about session and environment that the reprex was generated with.

False
style bool

Whether to autoformat code with black. Requires black to be installed.

False
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.

False
parsing_method str

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.

AUTO
input_prompt 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.

None
input_continuation 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.

None
input_comment 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.

None

Venue

Bases: str, Enum

Enum for specifying the output venue for a reprex.

Attributes:

Name Type Description
GH str

GitHub-flavored Markdown

DS str

Discourse

SO str

StackOverflow

HTML str

HTML

PY str

Python script

RTF str

Rich Text Format

SLACK str

Slack markup