Skip to content

Commit 651b606

Browse files
committed
[docs versions] set up versioned documentation (automated build and deploy)
1 parent 72b5529 commit 651b606

File tree

19 files changed

+2330
-1
lines changed

19 files changed

+2330
-1
lines changed

.circleci/config.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
docs_deploy: &docs
2+
docker:
3+
- image: node:8.10.0
4+
steps:
5+
- checkout
6+
- attach_workspace:
7+
at: docs/_build
8+
- run:
9+
name: Disable jekyll builds
10+
command: touch docs/_build/html/.nojekyll
11+
- run:
12+
name: Install and configure dependencies
13+
command: |
14+
npm install -g --silent [email protected]
15+
git config user.email "[email protected]"
16+
git config user.name "ci-build"
17+
- add_ssh_keys:
18+
fingerprints:
19+
- "ae:95:0c:cc:09:84:64:99:92:82:b7:b5:f4:a7:e9:23"
20+
- run:
21+
name: Deploy docs to gh-pages branch
22+
command: gh-pages --dotfiles --message "doc(update) [skip ci]" --dist docs/_build/html
23+
124
version: 2
225
jobs:
326
tests:
@@ -169,6 +192,58 @@ jobs:
169192
paths:
170193
- resources
171194

195+
build_docs:
196+
docker:
197+
- image: python:3.7.4
198+
environment:
199+
- FSLOUTPUTTYPE: NIFTI
200+
- SUBJECTS_DIR: /tmp/subjects
201+
steps:
202+
- restore_cache:
203+
keys:
204+
- docs-v1-{{ .Branch }}-{{ .Revision }}
205+
- docs-v1-{{ .Branch }}-
206+
- docs-v1-master
207+
- docs-v1-
208+
paths:
209+
- ./docs/_build/_html
210+
- checkout
211+
- run:
212+
name: Create subjects folder
213+
command: mkdir -p $SUBJECTS_DIR
214+
- run:
215+
name: Install Graphviz
216+
command: apt update && apt -y install graphviz
217+
- run:
218+
name: Install deps
219+
command: pip install --no-cache-dir -r docs/requirements.txt
220+
- run:
221+
name: Build only this commit
222+
command: make -C docs SPHINXOPTS="-W" BUILDDIR="_build/no_version_html" html
223+
- store_artifacts:
224+
path: ./docs/_build/no_version_html
225+
- run:
226+
name: Generate Versioned Docs
227+
command: |
228+
set +e
229+
force_versioned="$( git log --format=oneline -n 1 $CIRCLE_SHA1 | grep -i -E '\[docs?[ _]?versions?\]' )"
230+
set -e
231+
if [[ "x${CIRCLE_TAG}" = "x" && "${CIRCLE_BRANCH}" != "master" && "x${force_versioned}" = "x" ]]; then
232+
echo "Not a tag or master branch - skipping versioned docs."
233+
circleci step halt
234+
else
235+
make -f ./docs/Makefile versioned CURBRANCH=${CIRCLE_TAG:-$CIRCLE_BRANCH}
236+
fi
237+
- save_cache:
238+
key: docs-v1-{{ .Branch }}-{{ .Revision }}
239+
paths:
240+
- ./docs/_build/_html
241+
- persist_to_workspace:
242+
root: docs/_build
243+
paths: html
244+
- store_artifacts:
245+
path: ./docs/_build/html
246+
172247
update_skel:
173248
machine:
174249
image: circleci/classic:201711-01
@@ -251,12 +326,21 @@ jobs:
251326
twine check dist/*
252327
twine upload dist/*
253328
329+
deploy_docs_tag:
330+
<<: *docs
331+
332+
deploy_docs_master:
333+
<<: *docs
334+
254335
workflows:
255336
version: 2
256337
build_test_deploy:
257338
jobs:
258339
- tests:
259340
filters:
341+
branches:
342+
ignore:
343+
- /docs?\/.*/
260344
tags:
261345
only: /.*/
262346
- deploy_pypi:
@@ -275,3 +359,22 @@ workflows:
275359
only: /master/
276360
tags:
277361
ignore: /.*/
362+
363+
- build_docs:
364+
filters:
365+
branches:
366+
ignore:
367+
- /tests?\/.*/
368+
tags:
369+
only: /.*/
370+
371+
- deploy_docs_master:
372+
requires:
373+
- tests
374+
- update_skel
375+
- build_docs
376+
filters:
377+
branches:
378+
only: /master/
379+
tags:
380+
ignore: /.*/

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ instance/
6565

6666
# Sphinx documentation
6767
docs/_build/
68+
docs/api/
6869

6970
# PyBuilder
7071
target/

docs/Makefile

Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
# Makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = sphinx-build
7+
PAPER =
8+
BUILDDIR = _build
9+
CURBRANCH = master
10+
PYTHONPATH = $(PWD)
11+
12+
# User-friendly check for sphinx-build
13+
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
14+
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
15+
endif
16+
17+
# Internal variables.
18+
PAPEROPT_a4 = -D latex_paper_size=a4
19+
PAPEROPT_letter = -D latex_paper_size=letter
20+
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
21+
# the i18n builder cannot share the environment and doctrees with the others
22+
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
23+
24+
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
25+
26+
help:
27+
@echo "Please use \`make <target>' where <target> is one of"
28+
@echo " html to make standalone HTML files"
29+
@echo " dirhtml to make HTML files named index.html in directories"
30+
@echo " singlehtml to make a single large HTML file"
31+
@echo " pickle to make pickle files"
32+
@echo " json to make JSON files"
33+
@echo " htmlhelp to make HTML files and a HTML help project"
34+
@echo " qthelp to make HTML files and a qthelp project"
35+
@echo " devhelp to make HTML files and a Devhelp project"
36+
@echo " epub to make an epub"
37+
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
38+
@echo " latexpdf to make LaTeX files and run them through pdflatex"
39+
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
40+
@echo " text to make text files"
41+
@echo " man to make manual pages"
42+
@echo " texinfo to make Texinfo files"
43+
@echo " info to make Texinfo files and run them through makeinfo"
44+
@echo " gettext to make PO message catalogs"
45+
@echo " changes to make an overview of all changed/added/deprecated items"
46+
@echo " xml to make Docutils-native XML files"
47+
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
48+
@echo " linkcheck to check all external links for integrity"
49+
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
50+
51+
52+
clean:
53+
rm -rf $(BUILDDIR)/*
54+
rm -rf reference/*
55+
56+
html:
57+
PYTHONPATH=$(PYTHONPATH) $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
58+
@echo
59+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
60+
61+
dirhtml:
62+
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
63+
@echo
64+
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
65+
66+
singlehtml:
67+
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
68+
@echo
69+
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
70+
71+
pickle:
72+
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
73+
@echo
74+
@echo "Build finished; now you can process the pickle files."
75+
76+
json:
77+
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
78+
@echo
79+
@echo "Build finished; now you can process the JSON files."
80+
81+
htmlhelp:
82+
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
83+
@echo
84+
@echo "Build finished; now you can run HTML Help Workshop with the" \
85+
".hhp project file in $(BUILDDIR)/htmlhelp."
86+
87+
qthelp:
88+
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
89+
@echo
90+
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
91+
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
92+
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/templateflow.qhcp"
93+
@echo "To view the help file:"
94+
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/templateflow.qhc"
95+
96+
devhelp:
97+
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
98+
@echo
99+
@echo "Build finished."
100+
@echo "To view the help file:"
101+
@echo "# mkdir -p $$HOME/.local/share/devhelp/templateflow"
102+
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/templateflow"
103+
@echo "# devhelp"
104+
105+
epub:
106+
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
107+
@echo
108+
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
109+
110+
latex:
111+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
112+
@echo
113+
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
114+
@echo "Run \`make' in that directory to run these through (pdf)latex" \
115+
"(use \`make latexpdf' here to do that automatically)."
116+
117+
latexpdf:
118+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
119+
@echo "Running LaTeX files through pdflatex..."
120+
$(MAKE) -C $(BUILDDIR)/latex all-pdf
121+
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
122+
123+
latexpdfja:
124+
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
125+
@echo "Running LaTeX files through platex and dvipdfmx..."
126+
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
127+
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
128+
129+
text:
130+
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
131+
@echo
132+
@echo "Build finished. The text files are in $(BUILDDIR)/text."
133+
134+
man:
135+
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
136+
@echo
137+
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
138+
139+
texinfo:
140+
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
141+
@echo
142+
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
143+
@echo "Run \`make' in that directory to run these through makeinfo" \
144+
"(use \`make info' here to do that automatically)."
145+
146+
info:
147+
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
148+
@echo "Running Texinfo files through makeinfo..."
149+
make -C $(BUILDDIR)/texinfo info
150+
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
151+
152+
gettext:
153+
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
154+
@echo
155+
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
156+
157+
changes:
158+
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
159+
@echo
160+
@echo "The overview file is in $(BUILDDIR)/changes."
161+
162+
linkcheck:
163+
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
164+
@echo
165+
@echo "Link check complete; look for any errors in the above output " \
166+
"or in $(BUILDDIR)/linkcheck/output.txt."
167+
168+
doctest:
169+
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
170+
@echo "Testing of doctests in the sources finished, look at the " \
171+
"results in $(BUILDDIR)/doctest/output.txt."
172+
173+
xml:
174+
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
175+
@echo
176+
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
177+
178+
pseudoxml:
179+
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
180+
@echo
181+
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
182+
183+
versioned:
184+
PYTHONPATH=$(PYTHONPATH) sphinx-versioning -vv -l ./docs/conf.py build -r $(CURBRANCH) ./docs/ docs/$(BUILDDIR)/html/

docs/_static/RTD-advanced-conf.png

1.37 MB
Loading

docs/_static/git.png

12.8 KB
Loading

0 commit comments

Comments
 (0)