Skip to content

Commit 91ea4c5

Browse files
committed
Use Sphinx code-blocks (instead of ReST).
1 parent 7f07ca6 commit 91ea4c5

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

README.rst

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ that use configuration files.
1010
.. _click: https://click.pocoo.org/
1111

1212

13-
EXAMPLE::
13+
EXAMPLE:
1414

15-
# -- FILE: *.py
15+
.. code-block:: python
16+
17+
# -- FILE: example_command_with_configfile.py (PART 1)
1618
# BASIC SOLUTION FOR: Command that uses one or more configuration files.
1719
import click
1820
@@ -40,9 +42,11 @@ before the command-line parsing begins.
4042
In addition, there should be a simple way to specify the configuration schema
4143
in the configuration file in a similar way like the command-line options.
4244
An example how this functionality may look like, is shown in the following
43-
code snippet::
45+
code snippet:
46+
47+
.. code-block:: python
4448
45-
# -- FILE: *.py
49+
# -- FILE: example_command_with_configfile.py (PART 2)
4650
# Description of sections in a confguration file: *.ini
4751
from click_configfile import matches_section, Param, SectionSchema
4852
@@ -72,6 +76,8 @@ The example shows that the ``Param`` class supports similar arguments like a
7276

7377
An example for a valid configuration file with this schema is::
7478

79+
.. code-block:: ini
80+
7581
# -- FILE: foo.ini
7682
[foo]
7783
flag = yes # -- SUPPORTS: true, false, yes, no (case-insensitive)
@@ -90,9 +96,11 @@ An example for a valid configuration file with this schema is::
9096
9197
9298
The following code snippet shows the remaing core implementation of reading
93-
the configuration file (and parsing the configuration file data)::
99+
the configuration file (and parsing the configuration file data):
100+
101+
.. code-block:: python
94102
95-
# -- FILE: *.py
103+
# -- FILE: example_command_with_configfile.py (PART 3)
96104
import configparser # HINT: Use backport for Python2
97105
from click_configparser import generate_configfile_names, \
98106
select_config_sections, parse_config_section
@@ -148,10 +156,11 @@ the configuration file (and parsing the configuration file data)::
148156
The source code snippet above already contains a large number of generic
149157
functionality. Most of it can be avoided for processing a specific
150158
configuration file by using the ``ConfigFileReader`` class.
159+
The resulting source code is:
151160

152-
The resulting source code is::
161+
.. code-block:: python
153162
154-
# -- FILE: hello_command.py
163+
# -- FILE: example_command_with_configfile.py (ALL PARTS: simplified)
155164
from click_configfile import ConfigFileReader, Param, SectionSchema
156165
from click_configfile import matches_section
157166
import click

0 commit comments

Comments
 (0)