Browse code

Add make command for previewing API docs

Much easier than the previous method of copying over to the docs
repository and generating the docs.

And, as @cpuguy83 pointed out, that actually didn't work
because the PR that adds Swagger docs isn't merged yet. Oopsy.

Signed-off-by: Ben Firshman <ben@firshman.co.uk>

Ben Firshman authored on 2016/12/03 02:37:56
Showing 2 changed files
... ...
@@ -66,6 +66,8 @@ DOCKER_FLAGS := docker run --rm -i --privileged $(DOCKER_ENVS) $(DOCKER_MOUNT) $
66 66
 BUILD_APT_MIRROR := $(if $(DOCKER_BUILD_APT_MIRROR),--build-arg APT_MIRROR=$(DOCKER_BUILD_APT_MIRROR))
67 67
 export BUILD_APT_MIRROR
68 68
 
69
+SWAGGER_DOCS_PORT ?= 9000
70
+
69 71
 # if this session isn't interactive, then we don't want to allocate a
70 72
 # TTY, which would fail, but if it is interactive, we do want to attach
71 73
 # so that the user can send e.g. ^C through.
... ...
@@ -156,3 +158,11 @@ swagger-gen:
156 156
 		--entrypoint hack/generate-swagger-api.sh \
157 157
 		-e GOPATH=/go \
158 158
 		quay.io/goswagger/swagger:0.7.4
159
+
160
+.PHONY: swagger-docs
161
+swagger-docs: ## preview the API documentation
162
+	@echo "API docs preview will be running at http://localhost:$(SWAGGER_DOCS_PORT)"
163
+	@docker run --rm -v $(PWD)/api/swagger.yaml:/usr/share/nginx/html/swagger.yaml \
164
+		-e 'REDOC_OPTIONS=hide-hostname="true" lazy-rendering' \
165
+		-p $(SWAGGER_DOCS_PORT):80 \
166
+		bfirsh/redoc:1.6.2
... ...
@@ -37,6 +37,6 @@ There is hopefully enough example material in the file for you to copy a similar
37 37
 
38 38
 When you make edits to `swagger.yaml`, you may want to check the generated API documentation to ensure it renders correctly.
39 39
 
40
-All the documentation generation is done in the documentation repository, [docker/docker.github.io](https://github.com/docker/docker.github.io). The Swagger definition is vendored periodically into this repository, but you can manually copy over the Swagger definition to test changes.
40
+Run `make swagger-docs` and a preview will be running at `http://localhost`. Some of the styling may be incorrect, but you'll be able to ensure that it is generating the correct documentation.
41 41
 
42
-Copy `api/swagger.yaml` in this repository to `engine/api/[VERSION_NUMBER]/swagger.yaml` in the documentation repository, overwriting what is already there. Then, run `docker-compose up` in the documentation repository and browse to [http://localhost:4000/engine/api/](http://localhost:4000/engine/api/) when it finishes rendering.
42
+The production documentation is generated by vendoring `swagger.yaml` into [docker/docker.github.io](https://github.com/docker/docker.github.io).