Skip to content

Commit cf1d4e6

Browse files
committed
Split build target into smaller, reusable ones
Doing so means we now can reuse the logic that fixes the include:: directives in the cpython documentation in our CI job, avoiding repeating ourselves, making maintenance easier and avoiding subtle bugs. Being able to reuse the rest of the steps (do_build, pospell, etc) requires more care, as the Makefile is constrained to requiring a virtual environment (which we don't create on CI), and also doesn't allow us to pass command-line arguments to list specific files to check. Signed-off-by: Rodrigo Tobar <[email protected]>
1 parent de16a1a commit cf1d4e6

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,6 @@ jobs:
8888
# Construcción de la documentación
8989
- name: Construir documentación
9090
run: |
91-
# FIXME: Relative paths for includes in 'cpython'
92-
sed -i -e 's|.. include:: ../includes/wasm-notavail.rst|.. include:: ../../../../includes/wasm-notavail.rst|g' cpython/Doc/**/*.rst
93-
sed -i -e 's|.. include:: ../distutils/_setuptools_disclaimer.rst|.. include:: ../../../../distutils/_setuptools_disclaimer.rst|g' cpython/Doc/**/*.rst
94-
sed -i -e 's|.. include:: ./_setuptools_disclaimer.rst|.. include:: ../../../_setuptools_disclaimer.rst|g' cpython/Doc/**/*.rst
95-
sed -i -e 's|.. include:: token-list.inc|.. include:: ../../../token-list.inc|g' cpython/Doc/**/*.rst
96-
sed -i -e 's|.. include:: ../../using/venv-create.inc|.. include:: ../using/venv-create.inc|g' cpython/Doc/**/*.rst
97-
sed -i -e 's|.. include:: ../../../using/venv-create.inc|.. include:: ../../using/venv-create.inc|g' cpython/Doc/**/*.rst
98-
sed -i -e 's|.. include:: /using/venv-create.inc|.. include:: ../../../../using/venv-create.inc|g' cpython/Doc/**/*.rst
91+
make fix_relative_paths
9992
# Normal build
10093
PYTHONWARNINGS=ignore::FutureWarning,ignore::RuntimeWarning sphinx-build -j auto -W --keep-going -b html -d cpython/Doc/_build/doctree -D language=es . cpython/Doc/_build/html

Makefile

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,17 @@ help:
3838
# before this. If passing SPHINXERRORHANDLING='', warnings will not be
3939
# treated as errors, which is good to skip simple Sphinx syntax mistakes.
4040
.PHONY: build
41-
build: setup
41+
build: setup fix_relative_paths do_build
42+
43+
.PHONY: do_build
44+
do_build:
45+
# Normal build
46+
PYTHONWARNINGS=ignore::FutureWarning,ignore::RuntimeWarning $(VENV)/bin/sphinx-build -j auto -W --keep-going -b html -d $(OUTPUT_DOCTREE) -D language=$(LANGUAGE) . $(OUTPUT_HTML) && \
47+
echo "Success! Open file://`pwd`/$(OUTPUT_HTML)/index.html, " \
48+
"or run 'make serve' to see them in http://localhost:8000";
49+
50+
.PHONY: fix_relative_paths
51+
fix_relative_paths:
4252
# FIXME: Relative paths for includes in 'cpython'
4353
# See more about this at https://github.com/python/python-docs-es/issues/1844
4454
sed -i -e 's|.. include:: ../includes/wasm-notavail.rst|.. include:: ../../../../includes/wasm-notavail.rst|g' cpython/Doc/**/*.rst
@@ -48,11 +58,6 @@ build: setup
4858
sed -i -e 's|.. include:: ../../using/venv-create.inc|.. include:: ../using/venv-create.inc|g' cpython/Doc/**/*.rst
4959
sed -i -e 's|.. include:: ../../../using/venv-create.inc|.. include:: ../../using/venv-create.inc|g' cpython/Doc/**/*.rst
5060
sed -i -e 's|.. include:: /using/venv-create.inc|.. include:: ../../../../using/venv-create.inc|g' cpython/Doc/**/*.rst
51-
# Normal build
52-
PYTHONWARNINGS=ignore::FutureWarning,ignore::RuntimeWarning $(VENV)/bin/sphinx-build -j auto -W --keep-going -b html -d $(OUTPUT_DOCTREE) -D language=$(LANGUAGE) . $(OUTPUT_HTML) && \
53-
echo "Success! Open file://`pwd`/$(OUTPUT_HTML)/index.html, " \
54-
"or run 'make serve' to see them in http://localhost:8000";
55-
5661

5762
# setup: After running "venv" target, prepare that virtual environment with
5863
# a local clone of cpython repository and the translation files.

0 commit comments

Comments
 (0)