Skip to content

Commit 3ef6bf2

Browse files
dduportaltraefiker
authored andcommitted
Documentation: Introduces a check stage to validate HTML and links
1 parent 2721c20 commit 3ef6bf2

16 files changed

+116
-30
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ env:
1616

1717
script:
1818
- echo "Skipping tests... (Tests are executed on SemaphoreCI)"
19+
- if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then make docs-verify; fi
1920

2021
before_deploy:
2122
- >

CONTRIBUTING.md

+37-8
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,11 @@ Integration tests must be run from the `integration/` directory and require the
160160

161161
The [documentation site](http://docs.traefik.io/) is built with [mkdocs](http://mkdocs.org/)
162162

163-
### Method 1: `Docker` and `make`
163+
### Building Documentation
164164

165-
You can test documentation using the `docs` target.
165+
#### Method 1: `Docker` and `make`
166+
167+
You can build the documentation and serve it locally with livereloading, using the `docs` target:
166168

167169
```bash
168170
$ make docs
@@ -177,11 +179,18 @@ docker run --rm -v /home/user/go/github/containous/traefik:/mkdocs -p 8000:8000
177179

178180
And go to [http://127.0.0.1:8000](http://127.0.0.1:8000).
179181

180-
### Method 2: `mkdocs`
182+
If you only want to build the documentation without serving it locally, you can use the following command:
183+
184+
```bash
185+
$ make docs-build
186+
...
187+
```
188+
189+
#### Method 2: `mkdocs`
181190

182191
First make sure you have python and pip installed
183192

184-
```shell
193+
```bash
185194
$ python --version
186195
Python 2.7.2
187196
$ pip --version
@@ -190,22 +199,42 @@ pip 1.5.2
190199

191200
Then install mkdocs with pip
192201

193-
```shell
202+
```bash
194203
pip install --user -r requirements.txt
195204
```
196205

197-
To test documentation locally run `mkdocs serve` in the root directory, this should start a server locally to preview your changes.
206+
To build documentation locally and serve it locally,
207+
run `mkdocs serve` in the root directory,
208+
this should start a server locally to preview your changes.
198209

199-
```shell
210+
```bash
200211
$ mkdocs serve
201212
INFO - Building documentation...
202-
WARNING - Config value: 'theme'. Warning: The theme 'united' will be removed in an upcoming MkDocs release. See http://www.mkdocs.org/about/release-notes/ for more details
203213
INFO - Cleaning site directory
204214
[I 160505 22:31:24 server:281] Serving on http://127.0.0.1:8000
205215
[I 160505 22:31:24 handlers:59] Start watching changes
206216
[I 160505 22:31:24 handlers:61] Start detecting changes
207217
```
208218

219+
### Verify Documentation
220+
221+
You can verify that the documentation meets some expectations, as checking for dead links, html markup validity.
222+
223+
```bash
224+
$ make docs-verify
225+
docker build -t traefik-docs-verify ./script/docs-verify-docker-image ## Build Validator image
226+
...
227+
docker run --rm -v /home/travis/build/containous/traefik:/app traefik-docs-verify ## Check for dead links and w3c compliance
228+
=== Checking HTML content...
229+
Running ["HtmlCheck", "ImageCheck", "ScriptCheck", "LinkCheck"] on /app/site/basics/index.html on *.html...
230+
```
231+
232+
If you recently changed the documentation, do not forget to clean it to have it rebuilt:
233+
234+
```bash
235+
$ make docs-clean docs-verify
236+
...
237+
```
209238

210239
## How to Write a Good Issue
211240

Makefile

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: all
1+
.PHONY: all docs-verify docs docs-clean docs-build
22

33
TRAEFIK_ENVS := \
44
-e OS_ARCH_ARG \
@@ -22,6 +22,7 @@ REPONAME := $(shell echo $(REPO) | tr '[:upper:]' '[:lower:]')
2222
TRAEFIK_IMAGE := $(if $(REPONAME),$(REPONAME),"containous/traefik")
2323
INTEGRATION_OPTS := $(if $(MAKE_DOCKER_HOST),-e "DOCKER_HOST=$(MAKE_DOCKER_HOST)", -e "TEST_CONTAINER=1" -v "/var/run/docker.sock:/var/run/docker.sock")
2424
TRAEFIK_DOC_IMAGE := traefik-docs
25+
TRAEFIK_DOC_VERIFY_IMAGE := $(TRAEFIK_DOC_IMAGE)-verify
2526

2627
DOCKER_BUILD_ARGS := $(if $(DOCKER_VERSION), "--build-arg=DOCKER_VERSION=$(DOCKER_VERSION)",)
2728
DOCKER_RUN_OPTS := $(TRAEFIK_ENVS) $(TRAEFIK_MOUNT) "$(TRAEFIK_DEV_IMAGE)"
@@ -94,11 +95,23 @@ image-dirty: binary ## build a docker traefik image
9495
image: clear-static binary ## clean up static directory and build a docker traefik image
9596
docker build -t $(TRAEFIK_IMAGE) .
9697

98+
docs-image:
99+
docker build -t $(TRAEFIK_DOC_IMAGE) -f docs.Dockerfile .
100+
97101
docs: docs-image
98102
docker run $(DOCKER_RUN_DOC_OPTS) $(TRAEFIK_DOC_IMAGE) mkdocs serve
99103

100-
docs-image:
101-
docker build -t $(TRAEFIK_DOC_IMAGE) -f docs.Dockerfile .
104+
docs-build: site
105+
106+
docs-verify: site
107+
docker build -t $(TRAEFIK_DOC_VERIFY_IMAGE) ./script/docs-verify-docker-image ## Build Validator image
108+
docker run --rm -v $(CURDIR):/app $(TRAEFIK_DOC_VERIFY_IMAGE) ## Check for dead links and w3c compliance
109+
110+
site: docs-image
111+
docker run $(DOCKER_RUN_DOC_OPTS) $(TRAEFIK_DOC_IMAGE) mkdocs build
112+
113+
docs-clean:
114+
rm -rf $(CURDIR)/site
102115

103116
clear-static:
104117
rm -rf static

docs.Dockerfile

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
FROM alpine
1+
FROM alpine:3.7
22

33
ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.local/bin
44

55
COPY requirements.txt /mkdocs/
66
WORKDIR /mkdocs
7+
VOLUME /mkdocs
78

8-
RUN apk --update upgrade \
9-
&& apk --no-cache --no-progress add py-pip \
10-
&& rm -rf /var/cache/apk/* \
11-
&& pip install --user -r requirements.txt
9+
RUN apk --no-cache --no-progress add py-pip \
10+
&& pip install --user -r requirements.txt

docs/configuration/acme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ For example, the rule `Host:test1.traefik.io,test2.traefik.io` will request a ce
371371

372372
!!! warning
373373
`onHostRule` option can not be used to generate wildcard certificates.
374-
Refer to [wildcard generation](/configuration/acme/#wildcard-domain) for further information.
374+
Refer to [wildcard generation](/configuration/acme/#wildcard-domains) for further information.
375375

376376
### `storage`
377377

docs/configuration/api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
debug = true
3131
```
3232

33-
For more customization, see [entry points](/configuration/entrypoints/) documentation and [examples](/user-guide/examples/#ping-health-check).
33+
For more customization, see [entry points](/configuration/entrypoints/) documentation and the examples below.
3434

3535
## Web UI
3636

docs/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
</p>
44

55
[![Build Status SemaphoreCI](https://semaphoreci.com/api/v1/containous/traefik/branches/master/shields_badge.svg)](https://semaphoreci.com/containous/traefik)
6-
[![Docs](https://img.shields.io/badge/docs-current-brightgreen.svg)](https://docs.traefik.io)
6+
[![Docs](https://img.shields.io/badge/docs-current-brightgreen.svg)](/)
77
[![Go Report Card](https://goreportcard.com/badge/github.com/containous/traefik)](https://goreportcard.com/report/github.com/containous/traefik)
88
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/containous/traefik/blob/master/LICENSE.md)
99
[![Join the chat at https://slack.traefik.io](https://img.shields.io/badge/style-register-green.svg?style=social&label=Slack)](https://slack.traefik.io)

docs/user-guide/cluster.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ If this instance fails, another manager will be automatically elected.
2626

2727
## Træfik cluster and Let's Encrypt
2828

29-
**In cluster mode, ACME certificates have to be stored in [a KV Store entry](/configuration/acme/#storage-kv-entry).**
29+
**In cluster mode, ACME certificates have to be stored in [a KV Store entry](/configuration/acme/#as-a-key-value-store-entry).**
3030

3131
Thanks to the Træfik cluster mode algorithm (based on [the Raft Consensus Algorithm](https://raft.github.io/)), only one instance will contact Let's encrypt to solve the challenges.
3232

33-
The others instances will get ACME certificate from the KV Store entry.
33+
The others instances will get ACME certificate from the KV Store entry.

docs/user-guide/examples.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ These variables have to be set on the machine/container that host Træfik.
223223

224224
These variables are described [in this section](/configuration/acme/#provider).
225225

226-
More information about wildcard certificates are available [in this section](/configuration/acme/#wildcard-domain).
226+
More information about wildcard certificates are available [in this section](/configuration/acme/#wildcard-domains).
227227

228228
### onHostRule option and provided certificates (with HTTP challenge)
229229

docs/user-guide/grpc.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ We don't need specific configuration to use gRPC in Træfik, we just need to use
4545

4646
This section explains how to use Traefik as reverse proxy for gRPC application with self-signed certificates.
4747

48-
<p align="center">
49-
<img src="/img/grpc.svg" alt="gRPC architecture" title="gRPC architecture" />
50-
</p>
48+
![gRPC architecture](/img/grpc.svg)
5149

5250
### gRPC Server certificate
5351

docs/user-guide/kv-config.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ whoami4:
5656
5757
### Upload the configuration in the Key-value store
5858
59-
We should now fill the store with the Træfik global configuration, as we do with a [TOML file configuration](/toml).
59+
We should now fill the store with the Træfik global configuration.
6060
To do that, we can send the Key-value pairs via [curl commands](https://www.consul.io/intro/getting-started/kv.html) or via the [Web UI](https://www.consul.io/intro/getting-started/ui.html).
6161
6262
Fortunately, Træfik allows automation of this process using the `storeconfig` subcommand.
@@ -445,4 +445,4 @@ Then remove the line `storageFile = "acme.json"` from your TOML config file.
445445

446446
That's it!
447447

448-
![](https://i.giphy.com/ujUdrdpX7Ok5W.gif)
448+
![GIF Magica](https://i.giphy.com/ujUdrdpX7Ok5W.gif)

docs/user-guide/marathon.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Following is the order by which Traefik tries to identify the port (the first on
3030

3131
## Applications with multiple ports
3232

33-
Some Marathon applications may expose multiple ports. Traefik supports creating one so-called _service_ per port using [specific labels](/configuration/backends/marathon#service-level).
33+
Some Marathon applications may expose multiple ports. Traefik supports creating one so-called _segment_ per port using [segment labels](/configuration/backends/marathon#applications-with-multiple-ports-segment-labels).
3434

3535
For instance, assume that a Marathon application exposes a web API on port 80 and an admin interface on port 8080. It would then be possible to make each service available by specifying the following Marathon labels:
3636

docs/user-guide/swarm-mode.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -330,4 +330,4 @@ X-Forwarded-Proto: http
330330
X-Forwarded-Server: 77fc29c69fe4
331331
```
332332
333-
![](https://i.giphy.com/ujUdrdpX7Ok5W.gif)
333+
![GIF Magica](https://i.giphy.com/ujUdrdpX7Ok5W.gif)

docs/user-guide/swarm.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,4 +178,4 @@ X-Forwarded-Proto: http
178178
X-Forwarded-Server: 8fbc39271b4c
179179
```
180180
181-
![](https://i.giphy.com/ujUdrdpX7Ok5W.gif)
181+
![GIF Magica](https://i.giphy.com/ujUdrdpX7Ok5W.gif)
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM alpine:3.7
2+
3+
RUN apk --no-cache --no-progress add \
4+
ca-certificates \
5+
curl \
6+
findutils \
7+
ruby-bigdecimal \
8+
ruby-ffi \
9+
ruby-json \
10+
ruby-nokogiri \
11+
tini \
12+
&& gem install --no-document html-proofer
13+
14+
COPY ./validate.sh /validate.sh
15+
16+
WORKDIR /app
17+
VOLUME ["/tmp","/app"]
18+
19+
ENTRYPOINT ["/sbin/tini","-g","sh"]
20+
CMD ["/validate.sh"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/sh
2+
3+
set -eu
4+
5+
PATH_TO_SITE="/app/site"
6+
[ -d "${PATH_TO_SITE}" ]
7+
8+
NUMBER_OF_CPUS="$(grep -c processor /proc/cpuinfo)"
9+
10+
11+
echo "=== Checking HTML content..."
12+
13+
# Search for all HTML files except the theme's partials
14+
# and pipe this to htmlproofer with parallel threads
15+
# (one htmlproofer per vCPU)
16+
find "${PATH_TO_SITE}" -type f -not -path "/app/site/theme/*" \
17+
-name "*.html" -print0 \
18+
| xargs -0 -r -P "${NUMBER_OF_CPUS}" -I '{}' \
19+
htmlproofer \
20+
--check-html \
21+
--alt_ignore="/traefik.logo.png/" \
22+
--url-ignore "/localhost:/,/127.0.0.1:/,/fonts.gstatic.com/,/.minikube/,/github.com\/containous\/traefik\/*edit*/,/github.com\/containous\/traefik\/$/" \
23+
'{}'
24+
## HTML-proofer options at https://github.com/gjtorikian/html-proofer#configuration
25+
26+
echo "= Documentation checked successfuly."

0 commit comments

Comments
 (0)