summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile64
1 files changed, 56 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 9a5aa1d..193fd54 100644
--- a/Makefile
+++ b/Makefile
@@ -17,6 +17,14 @@ SERVER_BIN = $(BIN_DIR)/weles
BUILD_DOCKER_IMAGE = weles-build-img
BUILD_DOCKER_CONTAINER = weles-build
+DOC_DIR = doc
+SPHINX_DOCKER_IMAGE = weles-doc-image
+SPHINX_DOCKER_CONTAINER = weles-doc-container
+SPHINX_DOCKER_CONTAINER_WORKDIR = /doc
+SWAGGER_DOCKER_IMAGE = swaggerapi/swagger-codegen-cli
+SWAGGER_DOCKER_CONTAINER = weles-swagger-container
+SWAGGER_DOCKER_CONTAINER_WORKDIR = /local
+
.PHONY: all
all: docker-build
@@ -75,18 +83,58 @@ swagger-models-generate: swagger.yml COPYING
-s ./server \
-r ./COPYING \
-.PHONY: swagger-docs-html
-swagger-docs-html: swagger.yml
- mkdir -p doc/build/swagger
+.PHONY: docs
+docs: docs-swagger docs-sphinx
+
+.PHONY: clean-docs
+clean-docs: clean-docs-swagger clean-docker-swagger clean-docs-sphinx clean-docker-sphinx
+
+.PHONY: docs-sphinx
+docs-sphinx: docker-image-sphinx
docker run \
--rm \
- -v $$PWD:/local \
- --user `id -u $$USER`:`id -g $$USER` \
- swaggerapi/swagger-codegen-cli \
+ --volume "`pwd`:${SPHINX_DOCKER_CONTAINER_WORKDIR}" \
+ --user "`id -u $$USER`:`id -g $$USER`" \
+ --name "${SPHINX_DOCKER_CONTAINER}" "${SPHINX_DOCKER_IMAGE}" \
+ make -C "${SPHINX_DOCKER_CONTAINER_WORKDIR}/${DOC_DIR}" html
+
+.PHONY: docker-image-sphinx
+docker-image-sphinx:
+ docker build -t "${SPHINX_DOCKER_IMAGE}" ${DOC_DIR}
+
+.PHONY: clean-docs-sphinx
+clean-docs-sphinx:
+ -rm -r "${DOC_DIR}/build"
+
+.PHONY: clean-docker-sphinx
+clean-docker-sphinx:
+ -docker rm "${SPHINX_DOCKER_CONTAINER}"
+ -docker rmi "${SPHINX_DOCKER_IMAGE}"
+
+# docs-swagger generates API documentation in HTML format, to be used by
+# Sphinx.
+.PHONY: docs-swagger
+docs-swagger: swagger.yml
+ mkdir -p ${DOC_DIR}/source/_static/swagger
+ docker run \
+ --rm \
+ -v "`pwd`:${SWAGGER_DOCKER_CONTAINER_WORKDIR}" \
+ --user "`id -u $$USER`:`id -g $$USER`" \
+ --name "${SWAGGER_DOCKER_CONTAINER}" \
+ "${SWAGGER_DOCKER_IMAGE}"\
generate \
- -i local/swagger.yml \
+ -i "${SWAGGER_DOCKER_CONTAINER_WORKDIR}/swagger.yml" \
-l html \
- -o /local/doc/build/swagger/
+ -o "${SWAGGER_DOCKER_CONTAINER_WORKDIR}/${DOC_DIR}/source/_static/swagger/"
+
+.PHONY: clean-docs-swagger
+clean-docs-swagger:
+ -rm -rf doc/source/_static/swagger
+
+.PHONY: clean-docker-swagger
+clean-docker-swagger:
+ -docker rm "${SWAGGER_DOCKER_CONTAINER}"
+ -docker rmi "${SWAGGER_DOCKER_IMAGE}"
vendor: Gopkg.lock
dep ensure -v -vendor-only