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

docs: Use sphinx-copybutton prompt regex to fully capture examples #1617

Merged
merged 5 commits into from
Oct 6, 2021

Conversation

matthewfeickert
Copy link
Member

@matthewfeickert matthewfeickert commented Oct 5, 2021

Description

Apply results of executablebooks/sphinx-copybutton#82 (released in sphinx-copybutton v0.3.0) to use the copybutton_prompt_text regex support to accept both >>> and ... as valid prompt text (along with the others shown in executablebooks/sphinx-copybutton#82 to safeguard against future prompts) to allow for the "hello world" example from the README

pyhf/README.rst

Lines 42 to 52 in 6db5223

>>> import pyhf
>>> model = pyhf.simplemodels.uncorrelated_background(
... signal=[12.0, 11.0], bkg=[50.0, 52.0], bkg_uncertainty=[3.0, 7.0]
... )
>>> data = [51, 48] + model.config.auxdata
>>> test_mu = 1.0
>>> CLs_obs, CLs_exp = pyhf.infer.hypotest(
... test_mu, data, model, test_stat="qtilde", return_expected=True
... )
>>> print(f"Observed: {CLs_obs}, Expected: {CLs_exp}")
Observed: 0.05251497423736956, Expected: 0.06445320535890459

to be copied correctly.

This is covered in more depth in the sphinx-copybutton docs on how to Strip and configure input prompts for code cells.

Checklist Before Requesting Reviewer

  • Tests are passing
  • "WIP" removed from the title of the pull request
  • Selected an Assignee for the PR to be responsible for the log summary

Before Merging

For the PR Assignees:

  • Summarize commit messages into a comprehensive review of the PR
* Add copybutton_prompt_text regex support to allow for the prompt character to be `>>>`, `$`, or `...` to handle newlines
   - c.f. https://sphinx-copybutton.readthedocs.io/en/latest/#strip-and-configure-input-prompts-for-code-cells
* Add support for HERE-document syntax with $ prompt
* Update minimum required version of sphinx-copybutton to v0.3.2 to ensure HERE-document support

@matthewfeickert matthewfeickert added docs Documentation related fix A bug fix labels Oct 5, 2021
@matthewfeickert matthewfeickert self-assigned this Oct 5, 2021
@matthewfeickert
Copy link
Member Author

@codecov
Copy link

codecov bot commented Oct 5, 2021

Codecov Report

Merging #1617 (b15f600) into master (6db5223) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1617   +/-   ##
=======================================
  Coverage   97.70%   97.70%           
=======================================
  Files          63       63           
  Lines        4048     4048           
  Branches      576      576           
=======================================
  Hits         3955     3955           
  Misses         54       54           
  Partials       39       39           
Flag Coverage Δ
contrib 25.44% <ø> (ø)
unittests 97.48% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6db5223...b15f600. Read the comment docs.

Probably won't need prompts of format:
* [12345]:
* ...:
docs/conf.py Outdated Show resolved Hide resolved
@matthewfeickert
Copy link
Member Author

https://sphinx-copybutton.readthedocs.io/en/latest/#strip-and-configure-input-prompts-for-code-cells actually covered and fixed all my issues. The HERE-document syntax option is super nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation related fix A bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants