Repository: scipy/scipy

Issue:
BUG: CLI help is not accessible using light themes
Using a light theme in the terminal, the new dev CLI (`do.py`) has accessibility issues with examples.

<img width="1603" alt="Screenshot 2022-05-25 at 12 38 13" src="https://user-images.githubusercontent.com/23188539/171394140-8e9ce380-bb13-4c29-ab5a-1d7d5685662c.png">

It just seems to be a colour configuration as highlighting the block reveals the text.

cc @sayantikabanik 


Discussion:
### Gist of my exploration of the above issue

We are using rich-click, for CLI styling and colour pallet. The issue drill downs to rich text highlight

**Possible workarounds and way forward**
- Ability to detect the terminal background and fine-tune the markdown styling/colours based on the same (Related discussion:- https://github.com/Textualize/rich/discussions/1170)

- Another workaround could be wrapping the markdown around a code block highlighting the text. This ended up changing the CLI structure. (screenshot below) maybe little more digging could help solve the CLI structure issue.
![Screenshot 2022-05-26 at 1 09 37 PM](https://user-images.githubusercontent.com/17350312/171591585-68e6fa5b-2e74-44c0-a57e-40055e8cf24d.png)

Seems like only option 2 would be robust and low maintenance. Thank you for investigating.
Hi! I am new in Scipy and I would like to solve this issue. What result we expect? The one shown by @sayantikabanik?

Tks!
Hi @mariprudencio 👋 I think @sayantikabanik is working on this already. If you have other approaches feel free to participate in the discussion though.
@tupui thanks for the reply.

I have good results using the second approach pointed out by @sayantikabanik, but I think we have different results for different OS.

FYI, I'm using Linux Mint 20 (Ulyana). The results I have (after possible correction) were as follow:

Light theme:
![light_theme](https://user-images.githubusercontent.com/8270586/173709020-8801f9d6-e81b-40de-b2d8-84457a9bc037.png)

Dark theme:
![dark_theme](https://user-images.githubusercontent.com/8270586/173709051-05607e39-964b-4724-a926-72b29a7ccd01.png)

If this can be useful for this issue, I can show the way I did it :smile: but I understand if this is not the right solution or if another contributor has a better.



@mariprudencio your results look good to me. The important thing here is to have something readable. So anything would be an improvement over the current behaviour.

@sayantikabanik can you coordinate with @mariprudencio?
Sorry for the delayed response @mariprudencio @tupui, I had to take some time off due to my health condition.

The issue with the second approach is that it alters the structure of the `CLI` interface, the help text/ examples associated with a task should appear only when the user adds the `--help` flag. If this behaviour could be fixed I guess we are good to go.

Resolving patch:
diff --git a/dev.py b/dev.py
--- a/dev.py
+++ b/dev.py
@@ -263,11 +263,11 @@ class CLI(CliGroup):
 def cli(ctx, **kwargs):
     """Developer Tool for SciPy
 
-    Commands that require a built/installed instance are marked with :wrench:.
+    \bCommands that require a built/installed instance are marked with :wrench:.
 
 
+    \b**python dev.py --build-dir my-build test -s stats**
 
-    **python dev.py --build-dir my-build test -s stats**
     """
     CLI.update_context(ctx, kwargs)
 
@@ -372,6 +372,8 @@ def get_test_runner(project_module):
 class Build(Task):
     """:wrench: build & install package on path
 
+    \b
+    ```python
     Examples:
 
     $ python dev.py build --asan ;
@@ -379,6 +381,7 @@ class Build(Task):
         LD_PRELOAD=$(gcc --print-file-name=libasan.so)
         python dev.py test -v -t
         ./scipy/ndimage/tests/test_morphology.py -- -s
+    ```
     """
     ctx = CONTEXT
 
@@ -618,11 +621,14 @@ def run(cls, add_path=False, **kwargs):
 class Test(Task):
     """:wrench: Run tests
 
+    \b
+    ```python
     Examples:
 
     $ python dev.py test -s {SAMPLE_SUBMODULE}
     $ python dev.py test -t scipy.optimize.tests.test_minimize_constrained
     $ python dev.py test -s stats -- --tb=line
+    ```
     """
     ctx = CONTEXT
 
@@ -714,12 +720,14 @@ def run(cls, pytest_args, **kwargs):
 class Bench(Task):
     """:wrench: Run benchmarks
 
+    \b
+    ```python
      Examples:
 
     $ python dev.py bench -t integrate.SolveBVP
     $ python dev.py bench -t linalg.Norm
     $ python dev.py bench --compare main
-
+    ```
     """
     ctx = CONTEXT
     TASK_META = {
@@ -926,6 +934,7 @@ class Doc(Task):
     """:wrench: Build documentation
 
 TARGETS: Sphinx build targets [default: 'html']
+
 """
     ctx = CONTEXT
 
@@ -1073,9 +1082,12 @@ def run(cls, pythonpath, extra_argv, **kwargs):
 def notes(ctx_obj, version_args):
     """:ledger: Release notes and log generation
 
+    \b
+    ```python
      Example:
 
     $ python dev.py notes v1.7.0 v1.8.0
+    ```
     """
     if version_args:
         sys.argv = version_args
@@ -1095,9 +1107,12 @@ def notes(ctx_obj, version_args):
 def authors(ctx_obj, revision_args):
     """:ledger: Generate list of authors who contributed within revision interval
 
+    \b
+    ```python
     Example:
 
     $ python dev.py authors v1.7.0 v1.8.0
+    ```
     """
     if revision_args:
         sys.argv = revision_args


Test patch: