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

Add copy button to code blocks in PPT. #408

Merged
merged 1 commit into from
Feb 13, 2024
Merged

Conversation

delucchi-cmu
Copy link
Contributor

Change Description

Closes #407

Checklist

  • This PR is meant for the lincc-frameworks/python-project-template repo and not a downstream one instead.
  • This change is linked to an open issue
  • This change includes integration testing, or is small enough to be covered by existing tests

## sets up the expected prompt text from console blocks, and excludes it from
## the text that goes into the clipboard.
copybutton_exclude = '.linenos, .gp'
copybutton_prompt_text = ">> "
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this imply that we need to make sure that every line that is copied has >> at the beginning? Or does this simply mean that copybutton will attempt to remove a >> if it sees one?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok it looks like it's kinda both. https://sphinx-copybutton.readthedocs.io/en/latest/use.html#strip-and-configure-input-prompts-for-code-cells

My understanding is that it will only copy lines that have >> in this case, and when it does copy those, it will also remove the >> token. Pleas correct me if I'm way off.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My read (and what I've observed by painfully clicking the copy button on every code block in the PPT docs) is that it will show a copy button for EVERY code block.

If the code block is a "console" type, it will try to suppress (exclude) the "prompt" text, which is likely "$" or ">>>". We have been using just two ">> " for prompt text, and I think it looks nice, so I manually added it as a prompt text.

Copy link
Collaborator

@drewoldag drewoldag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a nice improvement

@delucchi-cmu delucchi-cmu merged commit 804c73f into main Feb 13, 2024
13 checks passed
@delucchi-cmu delucchi-cmu deleted the issue/407/copybutton branch February 13, 2024 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a copy button in documentation
2 participants