Skip to content

Commit

Permalink
docs: Fix highlighting in examples
Browse files Browse the repository at this point in the history
I never noticed when we added the license and copyright information to
the top of all the source files that we didn't account for the
lines highlighted in the included examples.  This adjusts things such
that (1) we don't include all that header stuff when generating the
docs, and only include the lines of code that are really relevant to
share on the examples page, and (2) the appropriate lines are
highlighted.
  • Loading branch information
jmgate committed Sep 12, 2024
1 parent 04cf2cc commit 149e48c
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions doc/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ straightforward it is to get up and running with it.
.. literalinclude:: ../../example/basic.py
:language: python
:linenos:
:lines: 10-
:caption: ``example/basic.py``
:emphasize-lines: 5,16-19
:emphasize-lines: 3,14-17

.. note::

The only thing you're adding to your script to take advantage of
``reverse_argparse`` is lines 7 and 19--22.
``reverse_argparse`` is lines 3 and 14--17.

Running the script, and passing an argument to it, yields the following:

Expand All @@ -37,8 +38,9 @@ arguments, but this time with default values.
.. literalinclude:: ../../example/default_values.py
:language: python
:linenos:
:lines: 10-
:caption: ``example/default_values.py``
:emphasize-lines: 10-11
:emphasize-lines: 8-9

Now running the script with the same command line arguments yields:

Expand All @@ -54,8 +56,9 @@ will be translated to an absolute path behind the scenes.
.. literalinclude:: ../../example/relative_references.py
:language: python
:linenos:
:lines: 10-
:caption: ``example/relative_references.py``
:emphasize-lines: 3,13
:emphasize-lines: 1,11

Now running the script and pointing to a file in your current working directory
yields:
Expand All @@ -73,8 +76,9 @@ standard format.
.. literalinclude:: ../../example/post_processing.py
:language: python
:linenos:
:lines: 10-
:caption: ``example/post_processing.py``
:emphasize-lines: 6,16,20-21
:emphasize-lines: 4,14,18-19

Now running the script and specifying a relative date/time yields:

Expand All @@ -92,8 +96,9 @@ different flags and corresponding values are.
.. literalinclude:: ../../example/pretty_printing.py
:language: python
:linenos:
:lines: 10-
:caption: ``example/pretty_printing.py``
:emphasize-lines: 28
:emphasize-lines: 26

Now running the script and specifying a relative date/time yields:

Expand All @@ -114,8 +119,9 @@ shows the subtle difference.
.. literalinclude:: ../../example/subparsers.py
:language: python
:linenos:
:lines: 10-
:caption: ``example/subparsers.py``
:emphasize-lines: 11-18
:emphasize-lines: 9-19

Running this script and using the ``foo`` subcommand yields:

Expand Down

0 comments on commit 149e48c

Please sign in to comment.