Skip to content

Commit 41225bb

Browse files
authored
Merge pull request #9179 from BinderDavid/fix-7977
Make users-guide buildable from within doc/ subdirectory
2 parents 84acb0e + 8ed6ecf commit 41225bb

File tree

3 files changed

+45
-32
lines changed

3 files changed

+45
-32
lines changed

Makefile

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -200,33 +200,13 @@ bootstrap-jsons: $(BOOTSTRAP_GHC_VERSIONS:%=bootstrap-json-%)
200200
# documentation
201201
##############################################################################
202202

203-
# TODO: when we have sphinx-build2 ?
204-
SPHINXCMD:=sphinx-build
205-
# Flag -n ("nitpick") warns about broken references
206-
# Flag -W turns warnings into errors
207-
# Flag --keep-going continues after errors
208-
SPHINX_FLAGS:=-n -W --keep-going -E
209-
SPHINX_HTML_OUTDIR:=dist-newstyle/doc/users-guide
210-
USERGUIDE_STAMP:=$(SPHINX_HTML_OUTDIR)/index.html
211-
212-
# do pip install every time so we have up to date requirements when we build
213-
users-guide: .python-sphinx-virtualenv $(USERGUIDE_STAMP)
214-
$(USERGUIDE_STAMP) : doc/*.rst
215-
mkdir -p $(SPHINX_HTML_OUTDIR)
216-
(. ./.python-sphinx-virtualenv/bin/activate && pip install -r doc/requirements.txt && $(SPHINXCMD) $(SPHINX_FLAGS) doc $(SPHINX_HTML_OUTDIR))
217-
218-
.python-sphinx-virtualenv:
219-
python3 -m venv .python-sphinx-virtualenv
220-
(. ./.python-sphinx-virtualenv/bin/activate)
221-
222-
# This goal is intended for manual invocation, always rebuilds.
223-
.PHONY: users-guide-requirements
224-
users-guide-requirements: doc/requirements.txt
203+
.PHONY: users-guide
204+
users-guide:
205+
$(MAKE) -C doc users-guide
225206

226-
.PHONY: doc/requirements.txt
227-
doc/requirements.txt: .python-sphinx-virtualenv
228-
. .python-sphinx-virtualenv/bin/activate \
229-
&& make -C doc build-and-check-requirements
207+
.PHONY: users-guide-requirements
208+
users-guide-requirements:
209+
$(MAKE) -C doc users-guide-requirements
230210

231211
ifeq ($(shell uname), Darwin)
232212
PROCS := $(shell sysctl -n hw.logicalcpu)

doc/Makefile

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,40 @@
1212
#
1313
#
1414
SKJOLD_GITHUB_API_TOKEN ?= ${GITHUB_TOKEN}
15+
# TODO: when we have sphinx-build2 ?
16+
SPHINXCMD:=sphinx-build
17+
# Flag -n ("nitpick") warns about broken references
18+
# Flag -W turns warnings into errors
19+
# Flag --keep-going continues after errors
20+
SPHINX_FLAGS:=-n -W --keep-going -E
21+
SPHINX_HTML_OUTDIR:=../dist-newstyle/doc/users-guide
22+
USERGUIDE_STAMP:=$(SPHINX_HTML_OUTDIR)/index.html
23+
PYTHON_VIRTUALENV_ACTIVATE:=../.python-sphinx-virtualenv/bin/activate
24+
25+
# Python virtual environment
26+
##############################################################################
27+
28+
# Create a python virtual environment in the root of the cabal repository.
29+
$(PYTHON_VIRTUALENV_ACTIVATE):
30+
python3 -m venv ../.python-sphinx-virtualenv
31+
(. $(PYTHON_VIRTUALENV_ACTIVATE))
32+
33+
# Users guide
34+
##############################################################################
35+
36+
# do pip install every time so we have up to date requirements when we build
37+
users-guide: $(PYTHON_VIRTUALENV_ACTIVATE) $(USERGUIDE_STAMP)
38+
$(USERGUIDE_STAMP) : *.rst
39+
mkdir -p $(SPHINX_HTML_OUTDIR)
40+
(. $(PYTHON_VIRTUALENV_ACTIVATE) && pip install -r requirements.txt && $(SPHINXCMD) $(SPHINX_FLAGS) . $(SPHINX_HTML_OUTDIR))
41+
42+
# Requirements
43+
##############################################################################
44+
45+
##
46+
# This goal is intended for manual invocation, always rebuilds.
47+
.PHONY: users-guide-requirements
48+
users-guide-requirements: requirements.txt
1549

1650
.PHONY: build-and-check-requirements
1751
build-and-check-requirements: requirements.txt check-requirements
@@ -21,8 +55,8 @@ build-and-check-requirements: requirements.txt check-requirements
2155
# requirements.txt is generated from requirements.in
2256
# via pip-compile included in the pip-tools package.
2357
# See https://modelpredict.com/wht-requirements-txt-is-not-enough
24-
requirements.txt: requirements.in
25-
. ../.python-sphinx-virtualenv/bin/activate \
58+
requirements.txt: requirements.in $(PYTHON_VIRTUALENV_ACTIVATE)
59+
. $(PYTHON_VIRTUALENV_ACTIVATE) \
2660
&& pip install --upgrade pip \
2761
&& pip install pip-tools \
2862
&& pip-compile requirements.in
@@ -37,7 +71,7 @@ check-requirements:
3771
echo "WARNING: Neither SKJOLD_GITHUB_API_TOKEN nor GITHUB_TOKEN is set." \
3872
; echo "Vulnerability check via skjold might fail when using the GitHub GraphQL API." \
3973
; fi
40-
. ../.python-sphinx-virtualenv/bin/activate \
74+
. $(PYTHON_VIRTUALENV_ACTIVATE) \
4175
&& pip install skjold \
4276
&& skjold audit
4377
# NB: For portability, we use '.' (sh etc.) instead of 'source' (bash).

doc/README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ http://cabal.readthedocs.io/
1111

1212
### How to build it
1313

14-
Building the documentation requires Python 3 and PIP. From the root of cabal
15-
repository run:
14+
Building the documentation requires Python 3 and PIP. Run the following command either from the root of the cabal repository or from the `docs/` subdirectory:
1615

1716
``` console
1817
make users-guide
@@ -33,7 +32,7 @@ generation step run
3332
> make users-guide-requirements
3433
```
3534

36-
in the root of the repository.
35+
either from the root of the cabal repository or from the `docs/` subdirectory.
3736

3837
Note that generating `requirements.txt` is sensitive to the Python version.
3938
The version currently used is stamped at the top of `requirements.txt`.

0 commit comments

Comments
 (0)