Skip to content

DOC: Add automatic exclusion of prompts from the copies using sphinx-copybutton #59369

@mosc9575

Description

@mosc9575

Pandas version checks

  • I have checked that the issue still exists on the latest versions of the docs on main here

Location of the documentation

In the docs the sphinx extension sphinx-copybutton is added but the output is not stripped. This means, that code is copied with possible outputs.

"sphinx_copybutton",

A possible solution is documented in the section using regex prompt identifiers.

Documentation problem

The main problem is, that examples in code blocks can have some output and will not work in a plain jupyter notebook cell without touching the copied code.

One possible example is in pandas.DataFrame.to_dict.

Suggested fix for documentation

The solution is to add

copybutton_prompt_text = r">>> |\.\.\. |\$ |In \[\d*\]: | {2,5}\.{3,}: | {5,8}: "
copybutton_prompt_is_regexp = True

to conf.py.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocsNeeds TriageIssue that has not been reviewed by a pandas team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions