Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 676: 'dark mode', documentation, spec update, implementation update #2239

Merged
merged 30 commits into from
Jan 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
8a4d4df
Update Makefile
AA-Turner Jan 13, 2022
4ae7aa3
Fix PEP 9
AA-Turner Jan 13, 2022
c14d665
Fix comment blocks
AA-Turner Jan 13, 2022
137e929
Dark mode
AA-Turner Jan 12, 2022
15e17ae
Promote sidebar one level
AA-Turner Jan 14, 2022
50f64dd
Update footer logic, add bottom horizontal rule
AA-Turner Jan 13, 2022
db5a86b
Clean up extension initialisation
AA-Turner Jan 14, 2022
0357bb3
Pull request rendering statement
AA-Turner Jan 13, 2022
7667c57
Add end user docs
AA-Turner Jan 13, 2022
7b84816
Add system overview docs
AA-Turner Jan 14, 2022
63aab74
TESTING - deploy on branch
AA-Turner Jan 12, 2022
7ebe572
Prefer `'` over `~` for underlines
AA-Turner Jan 14, 2022
b80261a
Jinja2 is dead, long live Jinja
AA-Turner Jan 14, 2022
02454bc
Fix numbering
AA-Turner Jan 14, 2022
da92ca1
Correct a stylistic aberration
AA-Turner Jan 14, 2022
ae83e8f
Add help text in `build.py`
AA-Turner Jan 14, 2022
466d4e6
Better elements of style
AA-Turner Jan 14, 2022
edf95e9
Defer to the PUG
AA-Turner Jan 15, 2022
0528da6
Serial over parallel, at least on Windows
AA-Turner Jan 15, 2022
816ee61
Two changes, almost verbatim
AA-Turner Jan 15, 2022
5ef0adf
Revert "TESTING - deploy on branch"
AA-Turner Jan 15, 2022
c6961ce
Dark mode button
AA-Turner Jan 15, 2022
90a5f22
Remove useless complexity, use the imperative voice
AA-Turner Jan 15, 2022
8a93ec4
Make code blocks toggle-able
AA-Turner Jan 15, 2022
c5aa8df
Adjust colours
AA-Turner Jan 15, 2022
8ca1b55
Exclude within argparse
AA-Turner Jan 15, 2022
39e21a2
Add explicit licence text
AA-Turner Jan 15, 2022
838d43f
Adorn `build.py` with a shebang
AA-Turner Jan 16, 2022
0eeac96
All change in dark mode code themes
AA-Turner Jan 16, 2022
fbb2d2e
Enable execution
AA-Turner Jan 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,11 @@ pep_rss:
$(PYTHON) generate_rss.py

pages: pep_rss
$(SPHINX_BUILD) --index-file
$(SPHINX_BUILD) --build-dirs

sphinx:
$(SPHINX_BUILD)

# for building Sphinx without a web-server
sphinx-local:
$(SPHINX_BUILD) --build-files

fail-warning:
$(SPHINX_BUILD) --fail-on-warning

Expand Down
49 changes: 30 additions & 19 deletions build.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#!/usr/bin/env python3
# This file is placed in the public domain or under the
# CC0-1.0-Universal license, whichever is more permissive.

"""Build script for Sphinx documentation"""

import argparse
Expand All @@ -9,17 +13,29 @@
def create_parser():
parser = argparse.ArgumentParser(description="Build PEP documents")
# alternative builders:
parser.add_argument("-l", "--check-links", action="store_true")
parser.add_argument("-f", "--build-files", action="store_true")
parser.add_argument("-d", "--build-dirs", action="store_true")
builders = parser.add_mutually_exclusive_group()
builders.add_argument("-l", "--check-links", action="store_const",
dest="builder", const="linkcheck",
help='Check validity of links within PEP sources. '
'Cannot be used with "-f" or "-d".')
builders.add_argument("-f", "--build-files", action="store_const",
dest="builder", const="html",
help='Render PEPs to "pep-NNNN.html" files (default). '
'Cannot be used with "-d" or "-l".')
builders.add_argument("-d", "--build-dirs", action="store_const",
dest="builder", const="dirhtml",
help='Render PEPs to "index.html" files within "pep-NNNN" directories. '
'Cannot be used with "-f" or "-l".')

# flags / options
parser.add_argument("-w", "--fail-on-warning", action="store_true")
parser.add_argument("-n", "--nitpicky", action="store_true")
parser.add_argument("-j", "--jobs", type=int, default=1)

# extra build steps
parser.add_argument("-i", "--index-file", action="store_true") # for PEP 0
parser.add_argument("-w", "--fail-on-warning", action="store_true",
help="Fail the Sphinx build on any warning.")
parser.add_argument("-n", "--nitpicky", action="store_true",
help="Run Sphinx in 'nitpicky' mode, "
"warning on every missing reference target.")
parser.add_argument("-j", "--jobs", type=int, default=1,
help="How many parallel jobs to run (if supported). "
"Integer, default 1.")

return parser.parse_args()

Expand All @@ -45,15 +61,11 @@ def create_index_file(html_root: Path, builder: str) -> None:
doctree_directory = build_directory / ".doctrees"

# builder configuration
if args.build_files:
sphinx_builder = "html"
elif args.build_dirs:
sphinx_builder = "dirhtml"
elif args.check_links:
sphinx_builder = "linkcheck"
if args.builder is not None:
sphinx_builder = args.builder
else:
# default builder
sphinx_builder = "dirhtml"
sphinx_builder = "html"

# other configuration
config_overrides = {}
Expand All @@ -71,6 +83,5 @@ def create_index_file(html_root: Path, builder: str) -> None:
parallel=args.jobs,
)
app.build()

if args.index_file:
create_index_file(build_directory, sphinx_builder)

create_index_file(build_directory, sphinx_builder)
4 changes: 3 additions & 1 deletion conf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# This file is placed in the public domain or under the
# CC0-1.0-Universal license, whichever is more permissive.

"""Configuration for building PEPs using Sphinx."""

from pathlib import Path
Expand Down Expand Up @@ -43,7 +46,6 @@

# HTML output settings
html_math_renderer = "maths_to_html" # Maths rendering
html_title = "peps.python.org" # Set <title/>

# Theme settings
html_theme_path = ["pep_sphinx_extensions"]
Expand Down
4 changes: 3 additions & 1 deletion contents.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
.. This file is placed in the public domain or under the
CC0-1.0-Universal license, whichever is more permissive.

Python Enhancement Proposals (PEPs)
***********************************


This is an internal Sphinx page, please go to the :doc:`PEP Index<pep-0000>`.
This is an internal Sphinx page, please go to the :doc:`PEP Index <pep-0000>`.


.. toctree::
Expand Down
106 changes: 106 additions & 0 deletions docs/build.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
..
Author: Adam Turner


Building PEPs Locally
=====================

Whilst editing a PEP, it is useful to review the rendered output locally.
This can also be used to check that the PEP is valid reStructuredText before
submission to the PEP editors.

The rest of this document assumes you are working from a local clone of the
`PEPs repository <https://github.com/python/peps>`__, with Python 3.9 or later
installed.


Render PEPs locally
-------------------

1. Create a virtual environment and install requirements.

The rest of these instructions assume an active virtual environment named
``venv``.
The Python Packaging User Guide contains
`instructions on creating a virtual environment <https://packaging.python.org/en/latest/guides/installing-using-pip-and-virtual-environments/#creating-a-virtual-environment>`__
for reference.

.. code-block:: console

(venv) $ python -m pip install --upgrade pip
AA-Turner marked this conversation as resolved.
Show resolved Hide resolved
(venv) $ python -m pip install -r requirements.txt

2. **(Optional)** Delete prior build files.
Generally only needed when making changes to the rendering system itself.

.. code-block:: console

$ rm -rf build

3. Run the build script:

.. code-block:: console

(venv) $ make sphinx

If you don't have access to ``make``, run:

.. code-block:: ps1con

(venv) PS> python build.py

.. note::

There may be a series of warnings about unreferenced citations or labels.
Whilst these are valid warnings, they do not impact the build process.

4. Navigate to the ``build`` directory of your PEPs repo to find the HTML pages.
PEP 0 provides a formatted index, and may be a useful reference.


``build.py`` tools
------------------

Several additional tools can be run through ``build.py``, or the Makefile.


Check links
'''''''''''

Check the validity of links within PEP sources (runs the `Sphinx linkchecker
<https://www.sphinx-doc.org/en/master/usage/builders/index.html#sphinx.builders.linkcheck.CheckExternalLinksBuilder>`__).

.. code-block:: console

(venv) $ python build.py --check-links
(venv) $ make check-links


Stricter rendering
''''''''''''''''''

Run in `nit-picky <https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-nitpicky>`__
mode.
This generates warnings for all missing references.

.. code-block:: console

(venv) $ python build.py --nitpicky

Fail the build on any warning.
As of January 2022, there are around 250 warnings when building the PEPs.

.. code-block:: console

(venv) $ python build.py --fail-on-warning
(venv) $ make fail-warning


``build.py`` usage
------------------

For details on the command-line options to the ``build.py`` script, run:

.. code-block:: console

(venv) $ python build.py --help
Loading