GitLab documentation is stored in projects with code and treated like code. Therefore, we use processes similar to those used for code to maintain standards and quality of documentation.
We have tests:
- To lint the words and structure of the documentation.
- To check the validity of internal links within the documentation suite.
- To check the validity of links from UI elements, such as files in
For the specifics of each test run in our CI/CD pipelines, see the configuration for those tests in the relevant projects:
Run tests locally
Similar to previewing your changes locally, you can also run these tests on your local computer. This has the advantage of:
- Speeding up the feedback loop. You can know of any problems with the changes in your branch without waiting for a CI/CD pipeline to run.
- Lowering costs. Running tests locally is cheaper than running tests on the cloud infrastructure GitLab uses.
To run tests locally, it's important to:
- Install the tools, and keep them up to date.
- Run linters, documentation link tests, and UI link tests the same way they are run in CI/CD pipelines. It's important to use same configuration we use in CI/CD pipelines, which can be different than the default configuration of the tool.
Lint checks are performed by the
script and can be executed as follows:
Navigate to the
MD_DOC_PATH points to the file or directory you would like to run lint checks for.
If you omit it completely, it defaults to the
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
This requires you to either:
- Have the required lint tools installed on your computer.
- A working Docker installation, in which case an image with these tools pre-installed is used.
Documentation link tests
To execute documentation link tests locally:
Navigate to the
Run the following commands:
# Check for broken internal links bundle exec nanoc check internal_links # Check for broken external links (might take a lot of time to complete). # This test is set to be allowed to fail and is run only in the gitlab-docs project CI bundle exec nanoc check internal_anchors
UI link tests
ui-docs-links lint job uses
haml-lint to test that all documentation links from
UI elements (
app/views files, for example) are linking to valid pages and anchors.
To run the
ui-docs-links test locally:
gitlabdirectory in a terminal window.
bundle exec haml-lint -i DocumentationLinks
If you receive an error the first time you run this test, run
bundle install, which
installs the dependencies for GitLab, and try again.
If you don't want to install all of the dependencies to test the links, you can:
gitlabdirectory in a terminal window.
gem install haml_lint
haml-lint -i DocumentationLinks
If you manually install
haml-lint with this process, it does not update automatically
and you should make sure your version matches the version used by GitLab.
At GitLab, we mostly use:
Our Documentation Style Guide and Markdown Guide elaborate on which choices must be made when selecting Markdown syntax for GitLab documentation. This tool helps catch deviations from those guidelines.
markdownlint configuration is found in the following projects:
This configuration is also used in build pipelines.
You can use markdownlint:
Vale supports creating custom tests that extend any of
several types of checks, which we store in the
.linting/vale/styles/gitlab directory in the
documentation directory of projects.
You can find Vale configuration in the following projects:
This configuration is also used in build pipelines, where error-level rules are enforced.
You can use Vale:
- On the command line.
- In a code editor.
- In a Git hook. Vale only reports errors in the Git hook (the same configuration as the CI/CD pipelines), and does not report suggestions or warnings.
Vale result types
Vale returns three types of results:
- Suggestion-level results are writing tips and aren't displayed in CI job output. Suggestions don't break CI. See a list of suggestion-level rules.
- Warning-level results are Style Guide violations, aren't displayed in CI job output, and should contain clear explanations of how to resolve the warning. Warnings may be technical debt, or can be future error-level test items (after the Technical Writing team completes its cleanup). Warnings don't break CI. See a list of warning-level rules.
- Error-level results are Style Guide violations, and should contain clear explanations about how to resolve the error. Errors break CI and are displayed in CI job output. of how to resolve the error. Errors break CI and are displayed in CI job output. See a list of error-level rules.
Vale spelling test
When Vale flags a valid word as a spelling mistake, you can fix it following these guidelines:
|jargon||Rewrite the sentence to avoid it.|
|correctly-capitalized name of a product or service||Add the word to the vale spelling exceptions list.|
|name of a person||Remove the name if it's not needed, or add the vale exception code in-line.|
|a command, variable, code, or similar||Put it in backticks or a code block. For example:
|UI text from GitLab||Verify it correctly matches the UI, then: If it does not match the UI, update it. If it matches the UI, but the UI seems incorrect, create an issue to see if the UI needs to be fixed. If it matches the UI and seems correct, add it to the vale spelling exceptions list.|
|UI text from a third-party product||Rewrite the sentence to avoid it, or add the vale exception code in-line.|
Vale readability score
As a general guideline, the lower the score, the more readable the documentation.
For example, a page that scores
12 before a set of changes, and
9 after, indicates an iterative improvement to readability. The score is not an exact science, but is meant to help indicate the
general complexity level of the page.
The readability score is calculated by using the following formula:
(.39 x ASL) + (11.8 x ASW) – 15.59
ASLis average sentence length (the number of words divided by the number of sentences).
ASWis the average number of syllables per word (the number of syllables divided by the number of words).
- The score excludes headings, code blocks, and lists.
yarn global add markdownlint-cli
We recommend installing the version of
variables:section) when building the
vale. For example, to install using
brewfor macOS, run:
brew install vale
These tools can be integrated with your code editor.
It's important to use linter versions that are the same or newer than those run in CI/CD. This provides access to new features and possible bug fixes.
To match the versions of
vale used in the GitLab projects, refer to the
versions used (see
when building the
image:docs-lint-markdown Docker image containing these tools for CI/CD.
||This command is for macOS only.|
|Vale||Specific||n/a||Not possible using
Using linters in your editor is more convenient than having to run the commands from the command line.
To configure markdownlint in your editor, install one of the following as appropriate:
- Sublime Text
- Visual Studio Code
- Vim ALE plugin.
To configure Vale in your editor, install one of the following as appropriate:
In the extension's settings:
- Select the Use CLI checkbox.
- In the Config setting, enter an absolute
.vale.iniin one of the cloned GitLab repositories on your computer.
- In the Path setting, enter the absolute path to the Vale binary. In most
valeshould work. To find the location, run
which valein a terminal.
Vim ALE plugin.
We don't use Vale Server.
Configure pre-push hooks
Git pre-push hooks allow Git users to:
- Run tests or other processes before pushing a branch.
- Avoid pushing a branch if failures occur with these tests.
lefthook is a Git hooks manager, making configuring,
installing, and removing Git hooks easy.
To set up
lefthook for documentation linting, see
Pre-push static analysis.
Show subset of Vale alerts
You can set Visual Studio Code to display only a subset of Vale alerts when viewing files:
- Go to Preferences > Settings > Extensions > Vale.
- In Vale CLI: Min Alert Level, select the minimum alert level you want displayed in files.
To display only a subset of Vale alerts when running Vale from the command line, use
--minAlertLevel flag, which accepts
suggestion. Combine it with
to point to the configuration file within the project, if needed:
vale --config .vale.ini --minAlertLevel error doc/**/*.md
Omit the flag to display all alerts, including
suggestion level alerts.
Disable Vale tests
You can disable a specific Vale linting rule or all Vale linting rules for any portion of a document:
- To disable a specific rule, add a
<!-- vale gitlab.rulename = NO -->tag before the text, and a
<!-- vale gitlab.rulename = YES -->tag after the text, replacing
rulenamewith the filename of a test in the GitLab styles directory.
- To disable all Vale linting rules, add a
<!-- vale off -->tag before the text, and a
<!-- vale on -->tag after the text.
Whenever possible, exclude only the problematic rule and lines.
For more information, see Vale's documentation.
Disable markdownlint tests
To disable all markdownlint rules, add a
<!-- markdownlint-disable --> tag before the text, and a
<!-- markdownlint-enable --> tag after the text.
To disable only a specific rule,
add the rule number to the tag, for example
<!-- markdownlint-disable MD044 -->
<!-- markdownlint-enable MD044 -->.
Whenever possible, exclude only the problematic lines.