Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task done
mosc9575 opened this issue Jul 31, 2024 · 1 comment
Closed
1 task done
Labels
Docs Needs Triage Issue that has not been reviewed by a pandas team member

Comments

@mosc9575
Copy link
Contributor

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.

@mosc9575 mosc9575 added Docs Needs Triage Issue that has not been reviewed by a pandas team member labels Jul 31, 2024
@mroeschke
Copy link
Member

Thanks for the report, but IIRC this is essentially a duplicate of #56388 so closing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Docs Needs Triage Issue that has not been reviewed by a pandas team member
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants