Skip to content

Commit 0e24fc5

Browse files
committed
PEP 639: Format code blocks with appropriate syntax highlighting
1 parent a6a2d10 commit 0e24fc5

1 file changed

Lines changed: 79 additions & 43 deletions

File tree

pep-0639.rst

Lines changed: 79 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,9 @@ license files and MUST NOT raise an error.
655655
.. _639-default-patterns:
656656

657657
If the ``license-files`` key is not present and not explicitly marked as
658-
``dynamic``, tools MUST assume a default value of the following::
658+
``dynamic``, tools MUST assume a default value of the following:
659+
660+
.. code-block:: toml
659661
660662
license-files.globs = ["LICEN[CS]E*", "COPYING*", "NOTICE*", "AUTHORS*"]
661663
@@ -2005,32 +2007,40 @@ as it did previously, since Setuptools relies on its own automatic
20052007
inclusion of license-related files matching common patterns,
20062008
such as the ``LICENSE`` file it uses.
20072009

2008-
It includes the following license-related metadata in its ``setup.cfg``::
2010+
It includes the following license-related metadata in its ``setup.cfg``:
2011+
2012+
.. code-block:: ini
20092013
20102014
[metadata]
20112015
classifiers =
20122016
License :: OSI Approved :: MIT License
20132017
2014-
The simplest migration to this PEP would consist of using this instead::
2018+
The simplest migration to this PEP would consist of using this instead:
2019+
2020+
.. code-block:: ini
20152021
20162022
[metadata]
20172023
license_expression = MIT
20182024
2019-
Or, in a :pep:`621` ``pyproject.toml``::
2025+
Or, in a :pep:`621` ``pyproject.toml``:
2026+
2027+
.. code-block:: toml
20202028
20212029
[project]
20222030
license-expression = "MIT"
20232031
2024-
The output core metadata for the distribution packages would then be::
2032+
The output core metadata for the distribution packages would then be:
2033+
2034+
.. code-block:: email
20252035
20262036
License-Expression: MIT
20272037
License-File: LICENSE
20282038
2029-
The ``LICENSE`` file would be stored at ``/setuptools-{version}/LICENSE``
2030-
in the sdist and ``/setuptools-{version}.dist-info/license_files/LICENSE``
2039+
The ``LICENSE`` file would be stored at ``/setuptools-${VERSION}/LICENSE``
2040+
in the sdist and ``/setuptools-${VERSION}.dist-info/license_files/LICENSE``
20312041
in the wheel, and unpacked from there into the site directory (e.g.
20322042
``site-packages``) on installation; ``/`` is the root of the respective archive
2033-
and ``{version}`` the version of the Setuptools release in the core metadata.
2043+
and ``${VERSION}`` the version of the Setuptools release in the core metadata.
20342044

20352045

20362046
.. _639-example-advanced:
@@ -2040,14 +2050,18 @@ Advanced example
20402050

20412051
Suppose Setuptools were to include the licenses of the third-party projects
20422052
that are vendored in the ``setuptools/_vendor/`` and ``pkg_resources/_vendor``
2043-
directories; specifically::
2053+
directories; specifically:
2054+
2055+
.. code-block:: text
20442056
20452057
packaging==21.2
20462058
pyparsing==2.2.1
20472059
ordered-set==3.1.1
20482060
more_itertools==8.8.0
20492061
2050-
The license expressions for these projects are::
2062+
The license expressions for these projects are:
2063+
2064+
.. code-block:: text
20512065
20522066
packaging: Apache-2.0 OR BSD-2-Clause
20532067
pyparsing: MIT
@@ -2056,7 +2070,9 @@ The license expressions for these projects are::
20562070
20572071
A comprehensive license expression covering both Setuptools
20582072
proper and its vendored dependencies would contain these metadata,
2059-
combining all the license expressions into one. Such an expression might be::
2073+
combining all the license expressions into one. Such an expression might be:
2074+
2075+
.. code-block:: text
20602076
20612077
MIT AND (Apache-2.0 OR BSD-2-Clause)
20622078
@@ -2070,14 +2086,18 @@ of the MIT license and the copyrights used by Setuptools, ``pyparsing``,
20702086

20712087
Specifically, we assume the license files are located at the following
20722088
paths in the project source tree (relative to the project root and
2073-
``pyproject.toml``)::
2089+
``pyproject.toml``):
2090+
2091+
.. code-block:: ini
20742092
20752093
LICENSE
20762094
setuptools/_vendor/packaging/LICENSE
20772095
setuptools/_vendor/packaging/LICENSE.APACHE
20782096
setuptools/_vendor/packaging/LICENSE.BSD
20792097
2080-
Putting it all together, our ``setup.cfg`` would be::
2098+
Putting it all together, our ``setup.cfg`` would be:
2099+
2100+
.. code-block:: ini
20812101
20822102
[metadata]
20832103
license_expression = MIT AND (Apache-2.0 OR BSD-2-Clause)
@@ -2088,7 +2108,9 @@ Putting it all together, our ``setup.cfg`` would be::
20882108
setuptools/_vendor/packaging/LICENSE.BSD
20892109
20902110
In a :pep:`621` ``pyproject.toml``, with license files specified explicitly
2091-
via the ``paths`` subkey, this would look like::
2111+
via the ``paths`` subkey, this would look like:
2112+
2113+
.. code-block:: toml
20922114
20932115
[project]
20942116
license-expression = "MIT AND (Apache-2.0 OR BSD-2-Clause)"
@@ -2099,7 +2121,9 @@ via the ``paths`` subkey, this would look like::
20992121
"setuptools/_vendor/LICENSE.BSD",
21002122
]
21012123
2102-
Or alternatively, matched via glob patterns, this could be::
2124+
Or alternatively, matched via glob patterns, this could be:
2125+
2126+
.. code-block:: toml
21032127
21042128
[project]
21052129
license-expression = "MIT AND (Apache-2.0 OR BSD-2-Clause)"
@@ -2109,38 +2133,46 @@ Or alternatively, matched via glob patterns, this could be::
21092133
]
21102134
21112135
With either approach, the output core metadata in the distribution
2112-
would be::
2136+
would be:
2137+
2138+
.. code-block:: email
21132139
21142140
License-Expression: MIT AND (Apache-2.0 OR BSD-2-Clause)
21152141
License-File: LICENSE
21162142
License-File: setuptools/_vendor/packaging/LICENSE
21172143
License-File: setuptools/_vendor/packaging/LICENSE.APACHE
21182144
License-File: setuptools/_vendor/packaging/LICENSE.BSD
21192145
2120-
In the resulting sdist, with ``/`` as the root of the archive and ``{version}``
2146+
In the resulting sdist, with ``/`` as the root of the archive and ``${VERSION}``
21212147
the version of the Setuptools release specified in the core metadata,
2122-
the license files would be located at the paths::
2148+
the license files would be located at the paths:
2149+
2150+
.. code-block:: shell
21232151
2124-
/setuptools-{version}/LICENSE
2125-
/setuptools-{version}/setuptools/_vendor/packaging/LICENSE
2126-
/setuptools-{version}/setuptools/_vendor/packaging/LICENSE.APACHE
2127-
/setuptools-{version}/setuptools/_vendor/packaging/LICENSE.BSD
2152+
/setuptools-${VERSION}/LICENSE
2153+
/setuptools-${VERSION}/setuptools/_vendor/packaging/LICENSE
2154+
/setuptools-${VERSION}/setuptools/_vendor/packaging/LICENSE.APACHE
2155+
/setuptools-${VERSION}/setuptools/_vendor/packaging/LICENSE.BSD
21282156
21292157
In the built wheel, with ``/`` being the root of the archive and
2130-
``{version}`` as the previous, the license files would be stored at::
2158+
``{version}`` as the previous, the license files would be stored at:
21312159

2132-
/setuptools-{version}.dist-info/license_files/LICENSE
2133-
/setuptools-{version}.dist-info/license_files/setuptools/_vendor/packaging/LICENSE
2134-
/setuptools-{version}.dist-info/license_files/setuptools/_vendor/packaging/LICENSE.APACHE
2135-
/setuptools-{version}.dist-info/license_files/setuptools/_vendor/packaging/LICENSE.BSD
2160+
.. code-block:: shell
2161+
2162+
/setuptools-${VERSION}.dist-info/license_files/LICENSE
2163+
/setuptools-${VERSION}.dist-info/license_files/setuptools/_vendor/packaging/LICENSE
2164+
/setuptools-${VERSION}.dist-info/license_files/setuptools/_vendor/packaging/LICENSE.APACHE
2165+
/setuptools-${VERSION}.dist-info/license_files/setuptools/_vendor/packaging/LICENSE.BSD
21362166
21372167
Finally, in the installed project, with ``site-packages`` being the site dir
2138-
and ``{version}`` as the previous, the license files would be installed to::
2168+
and ``{version}`` as the previous, the license files would be installed to:
2169+
2170+
.. code-block:: shell
21392171
2140-
site-packages/setuptools-{version}.dist-info/license_files/LICENSE
2141-
site-packages/setuptools-{version}.dist-info/license_files/setuptools/_vendor/packaging/LICENSE
2142-
site-packages/setuptools-{version}.dist-info/license_files/setuptools/_vendor/packaging/LICENSE.APACHE
2143-
site-packages/setuptools-{version}.dist-info/license_files/setuptools/_vendor/packaging/LICENSE.BSD
2172+
site-packages/setuptools-${VERSION}.dist-info/license_files/LICENSE
2173+
site-packages/setuptools-${VERSION}.dist-info/license_files/setuptools/_vendor/packaging/LICENSE
2174+
site-packages/setuptools-${VERSION}.dist-info/license_files/setuptools/_vendor/packaging/LICENSE.APACHE
2175+
site-packages/setuptools-${VERSION}.dist-info/license_files/setuptools/_vendor/packaging/LICENSE.BSD
21442176
21452177
21462178
.. _639-example-conversion:
@@ -2149,16 +2181,22 @@ Conversion example
21492181
------------------
21502182

21512183
Suppose we were to return to our simple Setuptools case.
2152-
Per the specification, given it only has the following license classifier::
2184+
Per the specification, given it only has the following license classifier:
2185+
2186+
.. code-block:: email
21532187
21542188
Classifier: License :: OSI Approved :: MIT License
21552189
21562190
And no value for the ``License`` field, or equivalently, if it had a
2157-
value of::
2191+
value of:
2192+
2193+
.. code-block:: email
21582194
21592195
License: MIT
21602196
2161-
Then the suggested value for the ``License-Expression`` field would be::
2197+
Then the suggested value for the ``License-Expression`` field would be:
2198+
2199+
.. code-block:: email
21622200
21632201
License-Expression: MIT
21642202
@@ -2173,20 +2211,16 @@ situation themselves.
21732211
Expression examples
21742212
-------------------
21752213

2176-
Some additional examples of valid ``License-Expression`` values::
2214+
Some additional examples of valid ``License-Expression`` values:
21772215

2178-
License-Expression: MIT
2216+
.. code-block:: email
21792217
2218+
License-Expression: MIT
21802219
License-Expression: BSD-3-Clause
2181-
21822220
License-Expression: MIT AND (Apache-2.0 OR BSD-2-clause)
2183-
21842221
License-Expression: MIT OR GPL-2.0-or-later OR (FSFUL AND BSD-2-Clause)
2185-
21862222
License-Expression: GPL-3.0-only WITH Classpath-Exception-2.0 OR BSD-3-Clause
2187-
21882223
License-Expression: LicenseRef-Public-Domain OR CC0-1.0 OR Unlicense
2189-
21902224
License-Expression: LicenseRef-Proprietary
21912225
21922226
@@ -2348,7 +2382,9 @@ There are two overlapping core metadata fields to document a license: the
23482382
license ``Classifier`` `strings <classifiers_>`__ prefixed with ``License ::``
23492383
and the ``License`` `field <licensefield_>`__ as free text.
23502384

2351-
The core metadata ``License`` field documentation is currently::
2385+
The core metadata ``License`` field documentation is currently:
2386+
2387+
.. code-block:: rst
23522388
23532389
License
23542390
=======

0 commit comments

Comments
 (0)