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 17 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/deploy-gh-pages.yaml
Expand Up @@ -2,7 +2,6 @@ name: Deploy to GitHub Pages

on:
push:
branches: [main]

jobs:
deploy-to-pages:
Expand Down
6 changes: 1 addition & 5 deletions Makefile
Expand Up @@ -65,15 +65,11 @@ pep_rss:
$(PYTHON) generate_rss.py

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

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
28 changes: 20 additions & 8 deletions build.py
Expand Up @@ -9,17 +9,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")
parser.add_argument("-l", "--check-links", action="store_true",
help='Checks validity of links within PEP sources. '
AA-Turner marked this conversation as resolved.
Show resolved Hide resolved
'Cannot be used with "-f" or "-d".')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they cannot be used together, why not properly codify this as a mutually exclusive argument group? Then the arguments will be displayed appropriately automatically without the need to hardcode this message, it will fail early with an informative error message, and your code doesn't need to handle it yourself.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not properly codify this as a mutually exclusive argument group

Laziness ;-) When originally putting it together it was a simpler thing, which grew larger.

A

parser.add_argument("-f", "--build-files", action="store_true",
help='Renders PEPs to "pep-XXXX.html" files (Default). '
AA-Turner marked this conversation as resolved.
Show resolved Hide resolved
'Cannot be used with "-d" or "-l".')
parser.add_argument("-d", "--build-dirs", action="store_true",
help='Renders PEPs to "index.html" files within "pep-XXXX" directories. '
AA-Turner marked this conversation as resolved.
Show resolved Hide resolved
'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)
parser.add_argument("-w", "--fail-on-warning", action="store_true",
help="Fails Sphinx on warnings.")
AA-Turner marked this conversation as resolved.
Show resolved Hide resolved
parser.add_argument("-n", "--nitpicky", action="store_true",
help="Runs Sphinx in 'nitpicky' mode, "
AA-Turner marked this conversation as resolved.
Show resolved Hide resolved
"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.")

# extra build steps
parser.add_argument("-i", "--index-file", action="store_true") # for PEP 0
parser.add_argument("-i", "--index-file", action="store_true", # for PEP 0
help="Copies PEP 0 to a base index file.")
AA-Turner marked this conversation as resolved.
Show resolved Hide resolved

return parser.parse_args()

Expand Down Expand Up @@ -53,7 +65,7 @@ def create_index_file(html_root: Path, builder: str) -> None:
sphinx_builder = "linkcheck"
else:
# default builder
sphinx_builder = "dirhtml"
sphinx_builder = "html"

# other configuration
config_overrides = {}
Expand Down
1 change: 0 additions & 1 deletion conf.py
Expand Up @@ -43,7 +43,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
2 changes: 1 addition & 1 deletion contents.rst
Expand Up @@ -3,7 +3,7 @@ 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
102 changes: 102 additions & 0 deletions docs/build.rst
@@ -0,0 +1,102 @@
..
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

.. code-block:: console

$ python -m venv venv
AA-Turner marked this conversation as resolved.
Show resolved Hide resolved
$ . venv/bin/activate
AA-Turner marked this conversation as resolved.
Show resolved Hide resolved
(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 -j 8
AA-Turner marked this conversation as resolved.
Show resolved Hide resolved

.. 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


All arguments to ``build.py``
AA-Turner marked this conversation as resolved.
Show resolved Hide resolved
-----------------------------
AA-Turner marked this conversation as resolved.
Show resolved Hide resolved

For details on options to ``build.py``, run:
AA-Turner marked this conversation as resolved.
Show resolved Hide resolved

.. code-block:: console

(venv) $ python build.py --help