Improve highlighting of some code blocks. (GH-6401)

(cherry picked from commit 46936d5a71d1683dbd8ddb6d7f39aab50ecfec50)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
diff --git a/Doc/library/faulthandler.rst b/Doc/library/faulthandler.rst
index d0c4cd0..94ebd87 100644
--- a/Doc/library/faulthandler.rst
+++ b/Doc/library/faulthandler.rst
@@ -152,10 +152,10 @@
 Example
 -------
 
-.. highlight:: sh
-
 Example of a segmentation fault on Linux with and without enabling the fault
-handler::
+handler:
+
+.. code-block:: shell-session
 
     $ python3 -c "import ctypes; ctypes.string_at(0)"
     Segmentation fault
diff --git a/Doc/library/json.rst b/Doc/library/json.rst
index bcad61a..85798fa 100644
--- a/Doc/library/json.rst
+++ b/Doc/library/json.rst
@@ -100,9 +100,9 @@
     ['[2.0', ', 1.0', ']']
 
 
-.. highlight:: bash
+Using :mod:`json.tool` from the shell to validate and pretty-print:
 
-Using :mod:`json.tool` from the shell to validate and pretty-print::
+.. code-block:: shell-session
 
     $ echo '{"json":"obj"}' | python -m json.tool
     {
@@ -113,8 +113,6 @@
 
 See :ref:`json-commandline` for detailed documentation.
 
-.. highlight:: python3
-
 .. note::
 
    JSON is a subset of `YAML <http://yaml.org/>`_ 1.2.  The JSON produced by
@@ -647,8 +645,6 @@
 when serializing instances of "exotic" numerical types such as
 :class:`decimal.Decimal`.
 
-.. highlight:: bash
-
 .. _json-commandline:
 
 Command Line Interface
@@ -665,7 +661,9 @@
 and pretty-print JSON objects.
 
 If the optional ``infile`` and ``outfile`` arguments are not
-specified, :attr:`sys.stdin` and :attr:`sys.stdout` will be used respectively::
+specified, :attr:`sys.stdin` and :attr:`sys.stdout` will be used respectively:
+
+.. code-block:: shell-session
 
     $ echo '{"json": "obj"}' | python -m json.tool
     {
@@ -684,7 +682,9 @@
 
 .. cmdoption:: infile
 
-   The JSON file to be validated or pretty-printed::
+   The JSON file to be validated or pretty-printed:
+
+   .. code-block:: shell-session
 
       $ python -m json.tool mp_films.json
       [
diff --git a/Doc/library/logging.config.rst b/Doc/library/logging.config.rst
index 0637837..1f9d7c7 100644
--- a/Doc/library/logging.config.rst
+++ b/Doc/library/logging.config.rst
@@ -538,7 +538,9 @@
 id.  If, however, a user defines a ``my.package.MyHandler`` which has
 an ``alternate`` handler, the configuration system would not know that
 the ``alternate`` referred to a handler.  To cater for this, a generic
-resolution system allows the user to specify::
+resolution system allows the user to specify:
+
+.. code-block:: yaml
 
     handlers:
       file:
@@ -552,7 +554,9 @@
 analogous way to strings with the ``ext://`` prefix, but looking
 in the configuration itself rather than the import namespace.  The
 mechanism allows access by dot or by index, in a similar way to
-that provided by ``str.format``.  Thus, given the following snippet::
+that provided by ``str.format``.  Thus, given the following snippet:
+
+.. code-block:: yaml
 
     handlers:
       email:
diff --git a/Doc/library/logging.rst b/Doc/library/logging.rst
index 88f804a..f9eda17 100644
--- a/Doc/library/logging.rst
+++ b/Doc/library/logging.rst
@@ -179,7 +179,9 @@
 
       You can specify *stack_info* independently of *exc_info*, e.g. to just show
       how you got to a certain point in your code, even when no exceptions were
-      raised. The stack frames are printed following a header line which says::
+      raised. The stack frames are printed following a header line which says:
+
+      .. code-block:: none
 
           Stack (most recent call last):
 
@@ -198,7 +200,9 @@
          logger = logging.getLogger('tcpserver')
          logger.warning('Protocol problem: %s', 'connection reset', extra=d)
 
-      would print something like  ::
+      would print something like
+
+      .. code-block:: none
 
          2006-02-08 22:20:02,165 192.168.0.1 fbloggs  Protocol problem: connection reset
 
@@ -939,7 +943,9 @@
 
    You can specify *stack_info* independently of *exc_info*, e.g. to just show
    how you got to a certain point in your code, even when no exceptions were
-   raised. The stack frames are printed following a header line which says::
+   raised. The stack frames are printed following a header line which says:
+
+   .. code-block:: none
 
        Stack (most recent call last):
 
@@ -957,7 +963,9 @@
       d = {'clientip': '192.168.0.1', 'user': 'fbloggs'}
       logging.warning('Protocol problem: %s', 'connection reset', extra=d)
 
-   would print something like::
+   would print something like:
+
+   .. code-block:: none
 
       2006-02-08 22:20:02,165 192.168.0.1 fbloggs  Protocol problem: connection reset
 
diff --git a/Doc/library/site.rst b/Doc/library/site.rst
index ae40813..0003a7c 100644
--- a/Doc/library/site.rst
+++ b/Doc/library/site.rst
@@ -222,7 +222,7 @@
 The :mod:`site` module also provides a way to get the user directories from the
 command line:
 
-.. code-block:: sh
+.. code-block:: shell-session
 
    $ python3 -m site --user-site
    /home/user/.local/lib/python3.3/site-packages
diff --git a/Doc/library/timeit.rst b/Doc/library/timeit.rst
index 8bbadf1..d922fd6 100644
--- a/Doc/library/timeit.rst
+++ b/Doc/library/timeit.rst
@@ -25,7 +25,7 @@
 The following example shows how the :ref:`timeit-command-line-interface`
 can be used to compare three different expressions:
 
-.. code-block:: sh
+.. code-block:: shell-session
 
    $ python3 -m timeit '"-".join(str(n) for n in range(100))'
    10000 loops, best of 5: 30.2 usec per loop
@@ -264,7 +264,7 @@
 
 It is possible to provide a setup statement that is executed only once at the beginning:
 
-.. code-block:: sh
+.. code-block:: shell-session
 
    $ python -m timeit -s 'text = "sample string"; char = "g"'  'char in text'
    5000000 loops, best of 5: 0.0877 usec per loop
@@ -293,7 +293,7 @@
 Here we compare the cost of using :func:`hasattr` vs. :keyword:`try`/:keyword:`except`
 to test for missing and present object attributes:
 
-.. code-block:: sh
+.. code-block:: shell-session
 
    $ python -m timeit 'try:' '  str.__bool__' 'except AttributeError:' '  pass'
    20000 loops, best of 5: 15.7 usec per loop
diff --git a/Doc/library/tokenize.rst b/Doc/library/tokenize.rst
index 02a0428..4c0a0ce 100644
--- a/Doc/library/tokenize.rst
+++ b/Doc/library/tokenize.rst
@@ -218,7 +218,7 @@
 of the line/column coordinates where the token is found, the second column is
 the name of the token, and the final column is the value of the token (if any)
 
-.. code-block:: sh
+.. code-block:: shell-session
 
     $ python -m tokenize hello.py
     0,0-0,0:            ENCODING       'utf-8'
@@ -244,7 +244,7 @@
 
 The exact token type names can be displayed using the :option:`-e` option:
 
-.. code-block:: sh
+.. code-block:: shell-session
 
     $ python -m tokenize -e hello.py
     0,0-0,0:            ENCODING       'utf-8'
diff --git a/Doc/library/zipapp.rst b/Doc/library/zipapp.rst
index a9a61c9..26b0f19 100644
--- a/Doc/library/zipapp.rst
+++ b/Doc/library/zipapp.rst
@@ -27,7 +27,7 @@
 Python code.  When run, the archive will execute the ``main`` function from
 the module ``myapp`` in the archive.
 
-.. code-block:: sh
+.. code-block:: shell-session
 
    $ python -m zipapp myapp -m "myapp:main"
    $ python myapp.pyz
@@ -41,7 +41,7 @@
 
 When called as a program from the command line, the following form is used:
 
-.. code-block:: sh
+.. code-block:: shell-session
 
    $ python -m zipapp source [options]
 
@@ -189,7 +189,7 @@
 
 Pack up a directory into an archive, and run it.
 
-.. code-block:: sh
+.. code-block:: shell-session
 
    $ python -m zipapp myapp
    $ python myapp.pyz
@@ -203,7 +203,7 @@
 To make the application directly executable on POSIX, specify an interpreter
 to use.
 
-.. code-block:: sh
+.. code-block:: shell-session
 
    $ python -m zipapp myapp -p "/usr/bin/env python"
    $ ./myapp.pyz
@@ -273,7 +273,7 @@
 2. Install all of your application's dependencies into the ``myapp`` directory,
    using pip:
 
-   .. code-block:: sh
+   .. code-block:: shell-session
 
       $ python -m pip install -r requirements.txt --target myapp
 
@@ -288,7 +288,7 @@
 
 4. Package the application using:
 
-   .. code-block:: sh
+   .. code-block:: shell-session
 
       $ python -m zipapp -p "interpreter" myapp