documentation icon indicating copy to clipboard operation
documentation copied to clipboard

Remove >>> from code blocks

Open Eric-Arellano opened this issue 1 year ago • 2 comments

It's common to see code blocks like this:

>>> 1 + 1
2

The >>> is emulating a REPL like IPython. However, it's not very useful to our end users because they cannot use our copy-code button. Better is this:

print(1 + 1)
2

We should fix:

  • [ ] guides
  • [ ] migration-guides
  • [ ] qiskit-ibm-runtime/dev
  • [ ] qiskit/dev

Use rg '>>>' to find violations.

In Sphinx, you'd fix this with something like this:

.. code-block:: python
  
  print(1 + 1)

.. code-block:: text
  
  2

Eric-Arellano avatar Oct 02 '24 20:10 Eric-Arellano

Hi, can you assigned me to this issue please?

a-dubaj avatar Oct 09 '24 16:10 a-dubaj

Sure, @a-dubaj. Thanks for offering to help! It'd be great to focus on docs/guides and docs/migration-guides to start. The API docs are updated in other repositories and could be handled separately.

Eric-Arellano avatar Oct 09 '24 16:10 Eric-Arellano

Hey @a-dubaj how is this going?

Eric-Arellano avatar Oct 28 '24 17:10 Eric-Arellano

Hi @Eric-Arellano,

I'd like to work on this issue! My plan is to:

Search for all occurrences of >>> in the documentation using grep. Replace >>> with appropriate Python print() statements where needed. Ensure that modified examples remain correct and readable. Build the documentation locally to verify the changes. I'll submit a PR soon. Let me know if you have any suggestions or specific guidelines to follow. Thanks!

Gyan-max avatar Feb 08 '25 05:02 Gyan-max

That would be much appreciated, @Gyan-max! I recommend starting with the qiskit/documentation repository (this one). Be careful not to change the docs/api folder because those docs are auto-generated, so your change will be reverted the next time we update the API docs.

grep

I recommend ripgrep https://github.com/BurntSushi/ripgrep :) One of the most useful CLI tools out there

Eric-Arellano avatar Feb 08 '25 12:02 Eric-Arellano

ThankYou @Eric-Arellano for assigning this issue. I'm on it and will raise a PR asap.

Gyan-max avatar Feb 08 '25 16:02 Gyan-max

Closed in https://github.com/Qiskit/documentation/pull/2698

frankharkins avatar Apr 08 '25 17:04 frankharkins