GitLab documentation is stored in projects with code, and treated like code. To maintain standards and quality of documentation, we use processes similar to those used for code.
Merge requests containing changes to Markdown (.md
) files run these CI/CD jobs:
docs-lint markdown
: Runs several types of tests, including:
lint-docs.sh
script: Miscellaneous testsdocs-lint links
: Checks the validity of relative links in the documentation suite.docs-lint mermaid
: Runs mermaidlint
to check for invalid Mermaid charts.rubocop-docs
: Checks links to documentation from .rb
files.eslint-docs
: Checks links to documentation from .js
and .vue
files.docs-lint redirects
: Checks for deleted or renamed documentation files without redirects.docs code_quality
and code_quality cache
: Runs code quality to add Vale warnings and errors into the MR changes tab (diff view).A few files are generated from scripts. A CI/CD job fails when either the source code files or the documentation files are updated without following the correct process:
graphql-verify
: Fails when doc/api/graphql/reference/_index.md
is not updated with the update process.docs-lint deprecations-and-removals
: Fails when doc/update/deprecations.md
is not updated with the update process.For a full list of automated files, see Automated pages.
Tests inlint-doc.sh
The tests in /scripts/lint-doc.sh
look for page content problems that Vale and markdownlint cannot test for. The docs-lint markdown
job fails if any of these lint-doc.sh
tests fail:
curl
) commands must use long-form options (--header
) instead of short options, like -h
.CHANGELOG.md
must not contain duplicate versions.doc/
directory must not be executable._index.md
instead of README.md
History
Mermaid builds charts and diagrams from code.
The script (scripts/lint/check_mermaid.mjs
) runs in the docs-lint mermaid
job for all merge requests that contain changes to Markdown files. The script returns an error if any Markdown files return a Mermaid syntax error.
To help debug your Mermaid charts, use the Mermaid Live Editor.
Tests indocs-lint links
and other jobs
To check for broken links, merge requests containing changes to Markdown (.md
) files run these jobs in their pipelines:
docs-lint links
job in the gitlab
project. For example: https://gitlab.com/gitlab-org/gitlab/-/jobs/7065686331.docs-lint links
job in the omnibus-gitlab
project. For example: https://gitlab.com/gitlab-org/omnibus-gitlab/-/jobs/7065337075.docs-lint links
job in the gitlab-operator
project.docs:lint markdown
job in the gitlab-runner
project, which includes link checking. For example: https://gitlab.com/gitlab-org/gitlab-runner/-/jobs/7056674997.check_docs_links
job in the charts/gitlab
project. For example: https://gitlab.com/gitlab-org/charts/gitlab/-/jobs/7066011619.These jobs check links, including anchor links, and report any problems. Any link that requires a network connection is skipped.
Tests for translated documentationTo ensure quality across all our translated content, we’ve implemented testing for our documentation in multiple languages. These tests mirror those used for the English version, but run on internationalized content in the /doc-locale/
or /docs-locale/
directories.
The docs-i18n-lint paths
job fails if translated files in /doc-locale
have no corresponding English source files. The job runs when:
/doc-locale
are modifiedWhen orphaned translation files are detected, localization team members handle the necessary deletions. English fallback content provides coverage until new translations are available.
Install documentation lintersTo help adhere to the documentation style guidelines, and improve the content added to documentation, install documentation linters and integrate them with your code editor. At a minimum, install markdownlint and Vale to match the checks run in build pipelines. Both tools can integrate with your code editor.
Run documentation tests locallySimilar to previewing your changes locally, you can also run documentation tests on your local computer. This has the advantage of:
It’s important to:
Installation and configuration instructions are available for:
lint-doc.sh
locally
Use a Rake task to run the lint-doc.sh
tests locally.
Prerequisites:
containerd
installation, to use an image with these tools pre-installed.Go to your gitlab
directory.
Run:
To specify a single file or directory you would like to run lint checks for, run:
MD_DOC_PATH=path/to/my_doc.md rake lint:markdown
The output should be similar to:
=> Linting documents at path /path/to/gitlab as <user>...
=> Checking for cURL short options...
=> Checking for CHANGELOG.md duplicate entries...
=> Checking /path/to/gitlab/doc for executable permissions...
=> Checking for new README.md files...
=> Linting markdown style...
=> Linting prose...
✔ 0 errors, 0 warnings and 0 suggestions in 1 file.
✔ Linting passed
Update linter configuration
Vale and markdownlint configurations are under source control in each project, so updates must be committed to each project individually.
The configuration in the gitlab
project should be treated as the source of truth, and all updates should first be made there.
On a regular basis, the changes made in gitlab
project to the Vale and markdownlint configuration should be synchronized to the other projects. In each of the supported projects:
Create a new branch. Add docs-
to the beginning or -docs
to the end of the branch name. Some projects use this convention to limit the jobs that run.
Copy the configuration files from the gitlab
project. For example, in the root directory of the project, run:
# Copy markdownlint configuration file
cp ../gitlab/.markdownlint-cli2.yaml .
# Remove existing Vale configuration in case some rules have been removed from the GitLab project
rm -r docs/.vale/gitlab
# Copy gitlab_base Vale configuration files for a project with documentation stored in 'docs' directory
cp -r ../gitlab/doc/.vale/gitlab_base docs/.vale
If updating gitlab-runner
, gitlab-omnibus
, charts/gitlab
, or gitlab-operator
, also copy the gitlab-docs
Vale configuration from the gitlab
project. For example, in the root directory of the project, run:
# Copy gitlab-docs Vale configuration files for a project with documentation stored in 'docs' directory
cp -r ../gitlab/doc/.vale/gitlab_docs docs/.vale
Review the diff created for .markdownlint-cli2.yaml
. For example, run:
git diff .markdownlint-cli2.yaml
Remove any changes that aren’t required. For example, customRules
is only used in the gitlab
project.
Review the diffs created for the Vale configuration. For example, run:
Remove unneeded changes to RelativeLinks.yml
. This rule is specific to each project.
Remove any .tmpl
files. These files are only used in the gitlab
project.
Run markdownlint-cli2
to check for any violations of the new rules. For example:
markdownlint-cli2 docs/**/*.md
Run Vale to check for any violations of the new rules. For example:
vale --minAlertLevel error docs
Commit the changes to the new branch. Some projects require conventional commits so check the contributing information for the project before committing.
Submit a merge request for review.
Lint tests run in CI/CD pipelines using images from the docs-gitlab-com
container registry.
If a new version of a dependency is released (like a new version of Vale), we should update the images to use the newer version. Then, we can update the configuration files in each of our documentation projects to point to the new image.
To update the linting images:
docs-gitlab-com
, open a merge request to update .gitlab-ci.yml
to use the new tooling version. (Example MR)Build docker images pipeline (Manual)
scheduled pipeline.test:image
job to complete, for example test:image:docs-lint-markdown
. If the job:
image:
job, for example, image:docs-lint-markdown
.image:
job passes, check the job’s log for the name of the new image. (Example job output)markdownlint
, vale
, or lychee
:
gitlab
:
.gitlab/ci/docs.gitlab-ci.yml
, update the image
in the .docs-markdown-lint-image:
section.scripts/lint-doc.sh
, update the registry_url
value in the run_locally_or_in_container()
section.gitlab-runner
: .gitlab/ci/_common.gitlab-ci.yml
, update the value of the DOCS_LINT_IMAGE
variable.omnibus-gitlab
: gitlab-ci-config/variables.yml
, update the value of the DOCS_LINT_IMAGE
variable.charts/gitlab
: .gitlab-ci.yml
, update the value of the DOCS_LINT_IMAGE
variable.cloud-native/gitlab-operator
: .gitlab-ci.yml
update the value of the DOCS_LINT_IMAGE
variable.gitlab-development-kit
: .gitlab-ci.yml
update the value of the DOCS_LINT_IMAGE
variable.Git pre-push hooks allow Git users to:
Lefthook is a Git hooks manager. It makes configuring, installing, and removing Git hooks simpler. Configuration for it is available in the lefthook.yml
file for the gitlab
project.
To set up Lefthook for documentation linting, see Pre-commit and pre-push static analysis with Lefthook.
To show Vale errors on commit or push, see Show Vale warnings on commit or push.
Disable linting on documentationSome, but not all, linting can be disabled on documentation files:
markdownlint
tests can be disabled for all or part of a file.You should use linter versions that are the same as those used in our CI/CD pipelines for maximum compatibility with the linting rules we use.
To match the versions of markdownlint-cli2
and vale
used in the GitLab projects, refer to:
asdf
, the .tool-versions
file in the project. For example, the .tool-versions
file in the gitlab
project.variables:
section) when building the image:docs-lint-markdown
Docker image containing these tools for CI/CD.Versions set in these two locations should be the same.
Tool Version Command Additional informationmarkdownlint-cli2
Latest yarn global add markdownlint-cli2
None. markdownlint-cli2
Specific yarn global add markdownlint-cli2@0.8.1
The @
indicates a specific version, and this example updates the tool to version 0.8.1
. Vale (using asdf
) Specific asdf install
Installs the version of Vale set in .tool-versions
file in a project. Vale (other) Specific Not applicable. Binaries can be directly downloaded. Vale (using brew
) Latest brew update && brew upgrade vale
This command is for macOS only. Supported projects
For the specifics of each test run in our CI/CD pipelines, see the configuration for those tests in the relevant projects:
We also run some documentation tests in these projects:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4