@@ -25,74 +25,50 @@ SERVE_BIND_ADDRESS ?= 127.0.0.1
25
25
TOP := $(dir $(firstword $(MAKEFILE_LIST ) ) )
26
26
# DOCROOT is the root of the mkdocs tree.
27
27
DOCROOT := $(abspath $(TOP ) )
28
- # GENROOT is the root of the generated documentation.
29
- GENROOT := $(DOCROOT ) /docs
30
28
31
29
# Grab the uid/gid to fix permissions due to running in a docker container.
32
30
GID := $(shell id -g)
33
31
UID := $(shell id -u)
34
32
35
33
# SOURCES is a list of a source files used to generate the documentation.
36
- SOURCES := $(shell find $(DOCROOT ) /docs-src -name \* .md)
34
+ SOURCES := $(shell find $(DOCROOT ) /docs -name \* .md)
37
35
SOURCES += mkdocs.yml docs.mk
38
36
39
37
# entrypoint
40
- all : .mkdocs.timestamp
38
+ all :
41
39
42
40
# Support docker images.
43
41
.PHONY : images
44
42
images : .mkdocs.dockerfile.timestamp
45
43
46
44
# build the image for mkdocs
47
- .mkdocs.dockerfile.timestamp : mkdocs.dockerfile
45
+ .mkdocs.dockerfile.timestamp : mkdocs.dockerfile mkdocs.requirements.txt
48
46
docker build -t $(MKDOCS_IMAGE ) -f mkdocs.dockerfile .
49
47
date > $@
50
48
51
- # generate the `docs` from SOURCES
52
- .mkdocs.timestamp : images $(SOURCES )
49
+ # serve runs mkdocs as a local webserver for interactive development.
50
+ # This will serve the live copy of the docs on 127.0.0.1:8000.
51
+ .PHONY : serve
52
+ serve : images
53
53
$(DOCKER ) run \
54
- --mount type=bind,source= $( DOCROOT ) ,target=/d \
54
+ -it \
55
55
--sig-proxy=true \
56
- --rm \
57
- $(MKDOCS_IMAGE ) \
58
- /bin/bash -c " cd /d && $( MKDOCS) build; find /d/docs -exec chown $( UID) :$( GID) {} \;"
59
- # Remove sitemap as it contains the timestamp, which is a source of a lot
60
- # of merge conflicts.
61
- rm docs/sitemap.xml docs/sitemap.xml.gz
62
- date > $@
63
-
64
- .PHONY : verify
65
- # verify that the docs have been properly updated.
66
- #
67
- # docs-src/.mkdocs-exclude contains a list of `diff -X` files to
68
- # exclude from the verification diff.
69
- verify : images
70
- $(DOCKER ) run \
71
56
--mount type=bind,source=$(DOCROOT ) ,target=/d \
72
- --sig-proxy=true \
57
+ -p $( SERVE_BIND_ADDRESS ) :8000:8000 \
73
58
--rm \
74
59
$(MKDOCS_IMAGE ) \
75
- /bin/bash -c " cd /d && $( MKDOCS) build --site-dir=/tmp/d && diff -X /d/docs-src/.mkdocs-exclude -qr /d/docs /tmp/d"
76
-
77
- # clean deletes generated files
78
- .PHONY : clean
79
- clean :
80
- test -f .mkdocs.timestamp && rm .mkdocs.timestamp || true
81
- test -f .mkdocs.dockerfile.timestamp && rm .mkdocs.dockerfile.timestamp || true
82
- rm -r $(GENROOT ) /* || true
60
+ /bin/bash -c " cd /d && $( MKDOCS) serve -a 0.0.0.0:8000"
83
61
84
- # serve runs mkdocs as a local webserver for interactive development.
85
- # This will serve the live copy of the docs on 127.0.0.1:8000.
86
- .PHONY : images serve
87
- serve :
62
+ # deploy will publish generated docs into gh-pages branch.
63
+ .PHONY : deploy
64
+ deploy : images
88
65
$(DOCKER ) run \
89
66
-it \
90
67
--sig-proxy=true \
91
68
--mount type=bind,source=$(DOCROOT ) ,target=/d \
92
- -p $(SERVE_BIND_ADDRESS ) :8000:8000 \
93
69
--rm \
94
70
$(MKDOCS_IMAGE ) \
95
- /bin/bash -c " cd /d && $( MKDOCS ) serve -a 0.0.0.0:8000 "
71
+ /bin/bash -c " cd /d && git config --global url. " https:// $$ GITHUB_USER: $$ GITHUB_TOKEN@github.com/ " .pushInsteadOf " https://github.com/ " && $( MKDOCS ) gh-deploy "
96
72
97
73
# help prints usage for this Makefile.
98
74
.PHONY : help
101
77
@echo " "
102
78
@echo " make Build the documentation"
103
79
@echo " make help Print this help message"
104
- @echo " make clean Delete generated files"
105
80
@echo " make serve Run the webserver for live editing (ctrl-C to quit)"
81
+ @echo " make deploy Publish generated docs into gh-pages branch"
106
82
107
83
# init creates a new mkdocs template. This is included for completeness.
108
84
.PHONY : images init
113
89
--rm \
114
90
$(MKDOCS_IMAGE ) \
115
91
/bin/bash -c " $( MKDOCS) new d; find /d -exec chown $( UID) :$( GID) {} \;"
116
-
0 commit comments