2018-06-06 11:32:38 +00:00
---
2020-09-29 18:09:52 +00:00
stage: none
group: Documentation Guidelines
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#designated-technical-writers
2018-06-06 11:32:38 +00:00
description: Learn how to contribute to GitLab Documentation.
---
# GitLab Documentation guidelines
2019-09-02 13:25:40 +00:00
GitLab's documentation is [intended as the single source of truth (SSOT) ](https://about.gitlab.com/handbook/documentation/ ) for information about how to configure, use, and troubleshoot GitLab. The documentation contains use cases and usage instructions for every GitLab feature, organized by product area and subject. This includes topics and workflows that span multiple GitLab features, and the use of GitLab with other applications.
2018-12-31 18:29:36 +00:00
2020-04-29 18:09:56 +00:00
In addition to this page, the following resources can help you craft and contribute to documentation:
2018-12-31 18:29:36 +00:00
2020-03-17 15:09:10 +00:00
- [Style Guide ](styleguide.md ) - What belongs in the docs, language guidelines, Markdown standards to follow, links, and more.
2018-12-31 18:37:06 +00:00
- [Structure and template ](structure.md ) - Learn the typical parts of a doc page and how to write each one.
2019-10-14 06:06:06 +00:00
- [Documentation process ](workflow.md ).
2019-10-14 03:06:12 +00:00
- [Markdown Guide ](../../user/markdown.md ) - A reference for all Markdown syntax supported by GitLab.
- [Site architecture ](site_architecture/index.md ) - How < https: // docs . gitlab . com > is built.
2020-04-21 21:09:38 +00:00
- [Documentation for feature flags ](feature_flags.md ) - How to write and update documentation for GitLab features deployed behind feature flags.
2018-12-31 18:29:36 +00:00
2019-04-16 05:17:36 +00:00
## Source files and rendered web locations
2018-12-21 03:08:27 +00:00
2020-03-02 09:07:59 +00:00
Documentation for GitLab, GitLab Runner, Omnibus GitLab, and Charts is published to < https: // docs . gitlab . com > . Documentation for GitLab is also published within the application at `/help` on the domain of the GitLab instance.
2019-10-11 06:06:27 +00:00
At `/help` , only help for your current edition and version is included. Help for other versions is available at < https: // docs . gitlab . com / archives /> .
2018-12-21 03:08:27 +00:00
2019-04-16 05:17:36 +00:00
The source of the documentation exists within the codebase of each GitLab application in the following repository locations:
2018-12-21 03:08:27 +00:00
| Project | Path |
| --- | --- |
2019-09-17 09:06:11 +00:00
| [GitLab ](https://gitlab.com/gitlab-org/gitlab/ ) | [`/doc` ](https://gitlab.com/gitlab-org/gitlab/tree/master/doc ) |
2018-12-21 03:08:27 +00:00
| [GitLab Runner ](https://gitlab.com/gitlab-org/gitlab-runner/ ) | [`/docs` ](https://gitlab.com/gitlab-org/gitlab-runner/tree/master/docs ) |
2020-06-29 15:08:56 +00:00
| [Omnibus GitLab ](https://gitlab.com/gitlab-org/omnibus-gitlab/ ) | [`/doc` ](https://gitlab.com/gitlab-org/omnibus-gitlab/tree/master/doc ) |
2019-10-11 06:06:27 +00:00
| [Charts ](https://gitlab.com/gitlab-org/charts/gitlab ) | [`/doc` ](https://gitlab.com/gitlab-org/charts/gitlab/tree/master/doc ) |
2018-12-21 03:08:27 +00:00
Documentation issues and merge requests are part of their respective repositories and all have the label `Documentation` .
2019-12-03 00:06:28 +00:00
### Branch naming
The [CI pipeline for the main GitLab project ](../pipelines.md ) is configured to automatically
run only the jobs that match the type of contribution. If your contribution contains
**only** documentation changes, then only documentation-related jobs will be run, and
the pipeline will complete much faster than a code contribution.
If you are submitting documentation-only changes to Runner, Omnibus, or Charts,
the fast pipeline is not determined automatically. Instead, create branches for
docs-only merge requests using the following guide:
| Branch name | Valid example |
|:----------------------|:-----------------------------|
| Starting with `docs/` | `docs/update-api-issues` |
| Starting with `docs-` | `docs-update-api-issues` |
| Ending in `-docs` | `123-update-api-issues-docs` |
2018-06-06 11:32:38 +00:00
## Contributing to docs
2018-12-31 19:25:53 +00:00
[Contributions to GitLab docs ](workflow.md ) are welcome from the entire GitLab community.
2018-12-21 03:08:27 +00:00
2020-09-28 06:09:56 +00:00
To ensure that GitLab docs are current, there are special processes and responsibilities for all [feature changes ](workflow.md ), that is development work that impacts the appearance, usage, or administration of a feature.
2018-12-21 03:08:27 +00:00
2020-09-28 06:09:56 +00:00
However, anyone can contribute [documentation improvements ](workflow.md ) that are not associated with a feature change. For example, adding a new doc on how to accomplish a use case that's already possible with GitLab or with third-party tools and GitLab.
2018-12-21 03:08:27 +00:00
2018-06-06 11:32:38 +00:00
## Markdown and styles
2019-07-11 11:58:49 +00:00
[GitLab docs ](https://gitlab.com/gitlab-org/gitlab-docs ) uses [GitLab Kramdown ](https://gitlab.com/gitlab-org/gitlab_kramdown )
2020-05-29 03:08:11 +00:00
as its Markdown rendering engine. See the [GitLab Markdown Guide ](https://about.gitlab.com/handbook/markdown-guide/ ) for a complete Kramdown reference.
2018-06-06 11:32:38 +00:00
2018-12-31 19:25:53 +00:00
Adhere to the [Documentation Style Guide ](styleguide.md ). If a style standard is missing, you are welcome to suggest one via a merge request.
2018-06-06 11:32:38 +00:00
2019-04-16 05:17:36 +00:00
## Folder structure and files
2019-04-17 21:21:12 +00:00
See the [Structure ](styleguide.md#structure ) section of the [Documentation Style Guide ](styleguide.md ).
2019-04-16 05:17:36 +00:00
2020-05-27 18:08:14 +00:00
## Metadata
To provide additional directives or useful information, we add metadata in YAML
2020-06-25 03:08:52 +00:00
format to the beginning of each product documentation page (YAML front matter).
All values are treated as strings and are only used for the
[docs website ](site_architecture/index.md ).
### Stage and group metadata
Each page should ideally have metadata related to the stage and group it
belongs to, as well as an information block as described below:
2020-07-01 09:09:30 +00:00
- `stage` : The [Stage ](https://about.gitlab.com/handbook/product/product-categories/#devops-stages )
2020-06-25 03:08:52 +00:00
to which the majority of the page's content belongs.
- `group` : The [Group ](https://about.gitlab.com/company/team/structure/#product-groups )
to which the majority of the page's content belongs.
- `info` : The following line, which provides direction to contributors regarding
how to contact the Technical Writer associated with the page's Stage and
Group:
```plaintext
To determine the technical writer assigned to the Stage/Group
associated with this page, see
https://about.gitlab.com/handbook/engineering/ux/technical-writing/#designated-technical-writers
```
2020-05-27 18:08:14 +00:00
For example, the following metadata would be at the beginning of a product
documentation page whose content is primarily associated with the Audit Events
feature:
```yaml
---
stage: Monitor
group: APM
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#designated-technical-writers
---
```
2020-09-11 21:08:44 +00:00
### Document type metadata
2020-06-25 03:08:52 +00:00
Originally discussed in [this epic ](https://gitlab.com/groups/gitlab-org/-/epics/1280 ),
2020-09-11 21:08:44 +00:00
each page should have a metadata tag called `type` . It can be one or more of the
following:
- `index` : It consists mostly of a list of links to other pages.
[Example page ](../../README.md ).
- `concepts` : The background or context of a subject.
[Example page ](../../topics/autodevops/index.md ).
- `howto` : Specific use case instructions.
[Example page ](../../ssh/README.md ).
- `tutorial` : Learn a process/concept by doing.
[Example page ](../../gitlab-basics/start-using-git.md ).
- `reference` : A collection of information used as a reference to use a feature
or a functionality. [Example page ](../../ci/yaml/README.md ).
2020-06-25 03:08:52 +00:00
### Redirection metadata
The following metadata should be added when a page is moved to another location:
2020-05-27 18:08:14 +00:00
- `redirect_to` : The relative path and filename (with an `.md` extension) of the
location to which visitors should be redirected for a moved page.
2020-09-29 18:09:52 +00:00
[Learn more ](#move-or-rename-a-page ).
2020-05-27 18:08:14 +00:00
- `disqus_identifier` : Identifier for Disqus commenting system. Used to keep
comments with a page that's been moved to a new URL.
[Learn more ](#redirections-for-pages-with-disqus-comments ).
2020-06-25 03:08:52 +00:00
### Comments metadata
The [docs website ](site_architecture/index.md ) has comments (provided by Disqus)
enabled by default. In case you want to disable them (for example in index pages),
set it to `false` :
```yaml
---
comments: false
---
```
### Additional page metadata
2020-09-11 21:08:44 +00:00
Each page can have additional, optional metadata (set in the
2020-06-25 03:08:52 +00:00
[default.html ](https://gitlab.com/gitlab-org/gitlab-docs/-/blob/fc3577921343173d589dfa43d837b4307e4e620f/layouts/default.html#L30-52 )
2020-09-11 21:08:44 +00:00
Nanoc layout), which will be displayed at the top of the page if defined:
2020-06-25 03:08:52 +00:00
- `reading_time` : If you want to add an indication of the approximate reading
time of a page, you can set `reading_time` to `true` . This uses a simple
[algorithm ](https://gitlab.com/gitlab-org/gitlab-docs/-/blob/master/lib/helpers/reading_time.rb )
to calculate the reading time based on the number of words.
2020-09-29 18:09:52 +00:00
## Move or rename a page
Moving or renaming a document is the same as changing its location. This process
requires specific steps to ensure that visitors can find the new
documentation page, whether they're using `/help` from a GitLab instance or by
visiting < https: / / docs . gitlab . com > .
2018-06-06 11:32:38 +00:00
2020-09-29 18:09:52 +00:00
Be sure to assign a technical writer to a page move or rename MR. Technical
Writers can help with any questions and can review your change.
2018-06-06 11:32:38 +00:00
2020-09-29 18:09:52 +00:00
To change a document's location, don't remove the old document, but instead
replace all of its content with the following:
2018-06-06 11:32:38 +00:00
2020-05-19 18:08:11 +00:00
```markdown
2020-04-28 21:09:35 +00:00
---
redirect_to: '../path/to/file/index.md'
---
This document was moved to [another location ](../path/to/file/index.md ).
2018-06-06 11:32:38 +00:00
```
2020-09-29 18:09:52 +00:00
Replace `../path/to/file/index.md` with the relative path to the old document.
The `redirect_to` variable supports both full and relative URLs; for example:
- `https://docs.gitlab.com/ee/path/to/file.html`
- `../path/to/file.html`
- `path/to/file.md`
2020-04-28 21:09:35 +00:00
2020-09-29 18:09:52 +00:00
The redirect works for < https: // docs . gitlab . com > , and any `*.md` paths are
changed to `*.html` . The description line following the `redirect_to` code
informs the visitor that the document changed location if the redirect process
doesn't complete successfully.
2018-06-06 11:32:38 +00:00
2020-04-09 06:09:30 +00:00
For example, if you move `doc/workflow/lfs/index.md` to
2018-06-06 11:32:38 +00:00
`doc/administration/lfs.md` , then the steps would be:
2020-04-09 06:09:30 +00:00
1. Copy `doc/workflow/lfs/index.md` to `doc/administration/lfs.md`
1. Replace the contents of `doc/workflow/lfs/index.md` with:
2018-06-06 11:32:38 +00:00
2020-05-19 18:08:11 +00:00
```markdown
2020-04-28 21:09:35 +00:00
---
redirect_to: '../../administration/lfs.md'
---
2019-07-31 08:28:51 +00:00
This document was moved to [another location ](../../administration/lfs.md ).
```
2018-06-06 11:32:38 +00:00
1. Find and replace any occurrences of the old location with the new one.
2020-04-28 21:09:35 +00:00
A quick way to find them is to use `git grep` on the repository you changed
the file from:
2018-06-06 11:32:38 +00:00
2020-01-30 15:09:15 +00:00
```shell
2019-07-31 08:28:51 +00:00
git grep -n "workflow/lfs/lfs_administration"
git grep -n "lfs/lfs_administration"
```
2018-06-06 11:32:38 +00:00
2020-10-14 00:08:48 +00:00
1. If the document being moved has any Disqus comments on it, follow the steps
described in [Redirections for pages with Disqus comments ](#redirections-for-pages-with-disqus-comments ).
2018-06-06 11:32:38 +00:00
Things to note:
- Since we also use inline documentation, except for the documentation itself,
the document might also be referenced in the views of GitLab (`app/`) which will
render when visiting `/help` , and sometimes in the testing suite (`spec/`).
2018-12-28 22:18:32 +00:00
You must search these paths for references to the doc and update them as well.
2018-06-06 11:32:38 +00:00
- The above `git grep` command will search recursively in the directory you run
it in for `workflow/lfs/lfs_administration` and `lfs/lfs_administration`
and will print the file and the line where this file is mentioned.
2020-03-17 15:09:10 +00:00
You may ask why the two greps. Since [we use relative paths to link to
2020-06-03 03:08:23 +00:00
documentation](styleguide.md#links), sometimes it might be useful to search a path deeper.
2018-06-06 11:32:38 +00:00
- The `*.md` extension is not used when a document is linked to GitLab's
2020-06-03 03:08:23 +00:00
built-in help page, which is why we omit it in `git grep` .
2018-08-16 09:30:04 +00:00
- Use the checklist on the "Change documentation location" MR description template.
2018-06-06 11:32:38 +00:00
2019-04-16 05:17:36 +00:00
### Redirections for pages with Disqus comments
2018-06-06 11:32:38 +00:00
2019-09-02 13:25:40 +00:00
If the documentation page being relocated already has Disqus comments,
2018-06-06 11:32:38 +00:00
we need to preserve the Disqus thread.
2019-10-11 06:06:27 +00:00
Disqus uses an identifier per page, and for < https: / / docs . gitlab . com > , the page identifier
2018-06-06 11:32:38 +00:00
is configured to be the page URL. Therefore, when we change the document location,
we need to preserve the old URL as the same Disqus identifier.
2020-05-19 18:08:11 +00:00
To do that, add to the front matter the variable `disqus_identifier` ,
using the old URL as value. For example, let's say we moved the document
2018-06-06 11:32:38 +00:00
available under `https://docs.gitlab.com/my-old-location/README.html` to a new location,
`https://docs.gitlab.com/my-new-location/index.html` .
2020-10-14 00:08:48 +00:00
Into the **new document** front matter, we add the following information. You must
include the file name in the `disqus_identifier` URL, even if it's `index.html` or `README.html` .
2018-06-06 11:32:38 +00:00
```yaml
---
2019-08-07 21:25:18 +00:00
disqus_identifier: 'https://docs.gitlab.com/my-old-location/README.html'
2018-06-06 11:32:38 +00:00
---
```
## Merge requests for GitLab documentation
Before getting started, make sure you read the introductory section
"[contributing to docs](#contributing-to-docs)" above and the
2018-12-28 06:13:27 +00:00
[documentation workflow ](workflow.md ).
2018-06-06 11:32:38 +00:00
2019-09-17 09:06:11 +00:00
- Use the current [merge request description template ](https://gitlab.com/gitlab-org/gitlab/blob/master/.gitlab/merge_request_templates/Documentation.md )
2020-04-30 06:10:03 +00:00
- Label the MR `Documentation` (can only be done by people with `developer` access, for example, GitLab team members)
- Assign the correct milestone per note below (can only be done by people with `developer` access, for example, GitLab team members)
2018-06-06 11:32:38 +00:00
2018-12-31 19:02:55 +00:00
Documentation will be merged if it is an improvement on existing content,
represents a good-faith effort to follow the template and style standards,
and is believed to be accurate.
2018-12-24 18:46:45 +00:00
2018-12-31 19:02:55 +00:00
Further needs for what would make the doc even better should be immediately addressed
2020-10-14 00:08:48 +00:00
in a follow-up merge request or issue.
2018-12-24 18:46:45 +00:00
2018-06-06 11:32:38 +00:00
If the release version you want to add the documentation to has already been
2020-05-18 18:08:22 +00:00
frozen or released, use the label `~"Pick into X.Y"` to get it merged into
2018-06-06 11:32:38 +00:00
the correct release. Avoid picking into a past release as much as you can, as
it increases the work of the release managers.
## GitLab `/help`
2019-07-10 03:55:54 +00:00
Every GitLab instance includes the documentation, which is available at `/help`
(`https://gitlab.example.com/help`). For example, < https: / / gitlab . com / help > .
2020-01-24 00:08:51 +00:00
The documentation available online on < https: // docs . gitlab . com > is deployed every four hours from the `master` branch of GitLab, Omnibus, and Runner. Therefore,
after a merge request gets merged, it will be available online on the same day.
However, it will be shipped (and available on `/help` ) within the milestone assigned
2018-09-20 07:13:30 +00:00
to the MR.
2020-01-24 00:08:51 +00:00
For example, let's say your merge request has a milestone set to 11.3, which
2018-09-20 07:13:30 +00:00
will be released on 2018-09-22. If it gets merged on 2018-09-15, it will be
available online on 2018-09-15, but, as the feature freeze date has passed, if
2020-05-18 18:08:22 +00:00
the MR does not have a `~"Pick into 11.3"` label, the milestone has to be changed
2018-09-20 07:13:30 +00:00
to 11.4 and it will be shipped with all GitLab packages only on 2018-10-22,
with GitLab 11.4. Meaning, it will only be available under `/help` from GitLab
2020-01-09 03:07:56 +00:00
11.4 onward, but available on < https: / / docs . gitlab . com / > on the same day it was merged.
2018-09-20 07:13:30 +00:00
### Linking to `/help`
2018-06-06 11:32:38 +00:00
When you're building a new feature, you may need to link the documentation
from GitLab, the application. This is normally done in files inside the
`app/views/` directory with the help of the `help_page_path` helper method.
In its simplest form, the HAML code to generate a link to the `/help` page is:
```haml
= link_to 'Help page', help_page_path('user/permissions')
```
The `help_page_path` contains the path to the document you want to link to with
the following conventions:
- it is relative to the `doc/` directory in the GitLab repository
- the `.md` extension must be omitted
- it must not end with a slash (`/`)
Below are some special cases where should be used depending on the context.
You can combine one or more of the following:
1. **Linking to an anchor link.** Use `anchor` as part of the `help_page_path`
method:
2019-07-31 08:28:51 +00:00
```haml
= link_to 'Help page', help_page_path('user/permissions', anchor: 'anchor-link')
```
2018-06-06 11:32:38 +00:00
1. **Opening links in a new tab.** This should be the default behavior:
2019-07-31 08:28:51 +00:00
```haml
= link_to 'Help page', help_page_path('user/permissions'), target: '_blank'
```
2018-06-06 11:32:38 +00:00
2020-09-11 18:08:42 +00:00
1. **Using a question icon.** Usually used in settings where a long
2018-06-06 11:32:38 +00:00
description cannot be used, like near checkboxes. You can basically use
2020-09-11 18:08:42 +00:00
any GitLab SVG icon, but prefer the `question-o` :
2018-06-06 11:32:38 +00:00
2019-07-31 08:28:51 +00:00
```haml
2020-09-11 18:08:42 +00:00
= link_to sprite_icon('question-o'), help_page_path('user/permissions')
2019-07-31 08:28:51 +00:00
```
2018-06-06 11:32:38 +00:00
1. **Using a button link.** Useful in places where text would be out of context
with the rest of the page layout:
2019-07-31 08:28:51 +00:00
```haml
= link_to 'Help page', help_page_path('user/permissions'), class: 'btn btn-info'
```
2018-06-06 11:32:38 +00:00
1. **Using links inline of some text.**
2019-07-31 08:28:51 +00:00
```haml
Description to #{link_to 'Help page', help_page_path('user/permissions')}.
```
2018-06-06 11:32:38 +00:00
1. **Adding a period at the end of the sentence.** Useful when you don't want
the period to be part of the link:
2019-07-31 08:28:51 +00:00
```haml
= succeed '.' do
Learn more in the
= link_to 'Help page', help_page_path('user/permissions')
```
2018-06-06 11:32:38 +00:00
2018-12-07 05:27:09 +00:00
### GitLab `/help` tests
2020-04-21 15:21:10 +00:00
Several [RSpec tests ](https://gitlab.com/gitlab-org/gitlab/blob/master/spec/features/help_pages_spec.rb )
2018-12-07 05:27:09 +00:00
are run to ensure GitLab documentation renders and works correctly. In particular, that [main docs landing page ](../../README.md ) will work correctly from `/help` .
For example, [GitLab.com's `/help` ](https://gitlab.com/help ).
2018-12-11 13:39:37 +00:00
## Docs site architecture
2018-12-29 00:29:59 +00:00
See the [Docs site architecture ](site_architecture/index.md ) page to learn
2019-10-11 06:06:27 +00:00
how we build and deploy the site at < https: / / docs . gitlab . com > and
2018-12-29 00:29:59 +00:00
to review all the assets and libraries in use.
2018-12-11 13:39:37 +00:00
### Global navigation
2018-12-29 00:29:59 +00:00
See the [Global navigation ](site_architecture/global_nav.md ) doc for information
on how the left-side navigation menu is built and updated.
2018-06-06 11:32:38 +00:00
2018-11-12 13:30:41 +00:00
## Previewing the changes live
NOTE: **Note:**
To preview your changes to documentation locally, follow this
2019-07-11 11:58:49 +00:00
[development guide ](https://gitlab.com/gitlab-org/gitlab-docs/blob/master/README.md#development-when-contributing-to-gitlab-documentation ) or [these instructions for GDK ](https://gitlab.com/gitlab-org/gitlab-development-kit/blob/master/doc/howto/gitlab_docs.md ).
2018-11-12 13:30:41 +00:00
The live preview is currently enabled for the following projects:
2020-05-19 18:08:11 +00:00
- [`gitlab` ](https://gitlab.com/gitlab-org/gitlab )
- [`gitlab-runner` ](https://gitlab.com/gitlab-org/gitlab-runner )
2018-11-12 13:30:41 +00:00
2019-09-17 14:16:34 +00:00
If your merge request has docs changes, you can use the manual `review-docs-deploy` job
to deploy the docs review app for your merge request.
You will need at least Maintainer permissions to be able to run it.
2018-11-12 13:30:41 +00:00
![Manual trigger a docs build ](img/manual_build_docs.png )
2020-10-14 00:08:48 +00:00
You must push a branch to those repositories, as it doesn't work for forks.
2018-11-12 13:30:41 +00:00
The `review-docs-deploy*` job will:
2019-10-11 06:06:27 +00:00
1. Create a new branch in the [`gitlab-docs` ](https://gitlab.com/gitlab-org/gitlab-docs )
2019-10-14 09:07:54 +00:00
project named after the scheme: `docs-preview-$DOCS_GITLAB_REPO_SUFFIX-$CI_MERGE_REQUEST_IID` ,
where `DOCS_GITLAB_REPO_SUFFIX` is the suffix for each product, e.g, `ee` for
EE, `omnibus` for Omnibus GitLab, etc, and `CI_MERGE_REQUEST_IID` is the ID
of the respective merge request.
1. Trigger a cross project pipeline and build the docs site with your changes.
In case the review app URL returns 404, this means that either the site is not
yet deployed, or something went wrong with the remote pipeline. Give it a few
minutes and it should appear online, otherwise you can check the status of the
remote pipeline from the link in the merge request's job output.
If the pipeline failed or got stuck, drop a line in the `#docs` chat channel.
2018-11-12 13:30:41 +00:00
Make sure that you always delete the branch of the merge request you were
working on. If you don't, the remote docs branch won't be removed either,
and the server where the Review Apps are hosted will eventually be out of
disk space.
2020-10-14 00:08:48 +00:00
TIP: **Tip:**
Someone with no merge rights to the GitLab projects (think of forks from
contributors) cannot run the manual job. In that case, you can
ask someone from the GitLab team who has the permissions to do that for you.
2018-11-12 13:30:41 +00:00
### Troubleshooting review apps
In case the review app URL returns 404, follow these steps to debug:
1. **Did you follow the URL from the merge request widget?** If yes, then check if
the link is the same as the one in the job output.
1. **Did you follow the URL from the job output?** If yes, then it means that
either the site is not yet deployed or something went wrong with the remote
pipeline. Give it a few minutes and it should appear online, otherwise you
can check the status of the remote pipeline from the link in the job output.
If the pipeline failed or got stuck, drop a line in the `#docs` chat channel.
### Technical aspects
If you want to know the in-depth details, here's what's really happening:
2019-09-17 09:06:11 +00:00
1. You manually run the `review-docs-deploy` job in a merge request.
2020-07-23 03:09:42 +00:00
1. The job runs the [`scripts/trigger-build` ](https://gitlab.com/gitlab-org/gitlab/blob/master/scripts/trigger-build )
script with the `docs deploy` flag, which in turn:
2018-11-12 13:30:41 +00:00
1. Takes your branch name and applies the following:
2019-10-14 09:07:54 +00:00
- The `docs-preview-` prefix is added.
- The product slug is used to know the project the review app originated
from.
- The number of the merge request is added so that you can know by the
`gitlab-docs` branch name the merge request it originated from.
2018-11-12 13:30:41 +00:00
1. The remote branch is then created if it doesn't exist (meaning you can
re-run the manual job as many times as you want and this step will be skipped).
1. A new cross-project pipeline is triggered in the docs project.
1. The preview URL is shown both at the job output and in the merge request
widget. You also get the link to the remote pipeline.
1. In the docs project, the pipeline is created and it
2019-07-11 11:58:49 +00:00
[skips the test jobs ](https://gitlab.com/gitlab-org/gitlab-docs/blob/8d5d5c750c602a835614b02f9db42ead1c4b2f5e/.gitlab-ci.yml#L50-55 )
2018-11-12 13:30:41 +00:00
to lower the build time.
1. Once the docs site is built, the HTML files are uploaded as artifacts.
2020-09-15 06:09:32 +00:00
1. A specific runner tied only to the docs project, runs the Review App job
2018-11-12 13:30:41 +00:00
that downloads the artifacts and uses `rsync` to transfer the files over
to a location where NGINX serves them.
The following GitLab features are used among others:
2019-02-06 04:14:23 +00:00
- [Manual actions ](../../ci/yaml/README.md#whenmanual )
2020-09-28 06:09:56 +00:00
- [Multi project pipelines ](../../ci/multi_project_pipelines.md )
2018-11-12 13:30:41 +00:00
- [Review Apps ](../../ci/review_apps/index.md )
- [Artifacts ](../../ci/yaml/README.md#artifacts )
2020-09-15 06:09:32 +00:00
- [Specific runner ](../../ci/runners/README.md#prevent-a-specific-runner-from-being-enabled-for-other-projects )
2019-10-14 09:07:54 +00:00
- [Pipelines for merge requests ](../../ci/merge_request_pipelines/index.md )
2018-11-12 13:30:41 +00:00
## Testing
2019-10-11 18:06:15 +00:00
We treat documentation as code, and so use tests in our CI pipeline to maintain the
standards and quality of the docs. The current tests, which run in CI jobs when a
merge request with new or changed docs is submitted, are:
2020-07-31 12:10:02 +00:00
- [`docs lint` ](https://gitlab.com/gitlab-org/gitlab/-/blob/0b562014f7b71f98540e682c8d662275f0011f2f/.gitlab/ci/docs.gitlab-ci.yml#L41 ):
2019-10-11 18:06:15 +00:00
Runs several tests on the content of the docs themselves:
- [`lint-doc.sh` script ](https://gitlab.com/gitlab-org/gitlab/blob/master/scripts/lint-doc.sh )
2020-03-05 12:07:48 +00:00
runs the following checks and linters:
2019-10-11 18:06:15 +00:00
- All cURL examples use the long flags (ex: `--header` , not `-H` ).
- The `CHANGELOG.md` does not contain duplicate versions.
- No files in `doc/` are executable.
- No new `README.md` was added.
2020-03-05 12:07:48 +00:00
- [markdownlint ](#markdownlint ).
- [Vale ](#vale ).
- Nanoc tests:
2020-07-31 12:10:02 +00:00
- [`internal_links` ](https://gitlab.com/gitlab-org/gitlab/-/blob/0b562014f7b71f98540e682c8d662275f0011f2f/.gitlab/ci/docs.gitlab-ci.yml#L58 )
2019-10-11 18:06:15 +00:00
checks that all internal links (ex: `[link](../index.md)` ) are valid.
2020-07-31 12:10:02 +00:00
- [`internal_anchors` ](https://gitlab.com/gitlab-org/gitlab/-/blob/0b562014f7b71f98540e682c8d662275f0011f2f/.gitlab/ci/docs.gitlab-ci.yml#L60 )
2019-10-11 18:06:15 +00:00
checks that all internal anchors (ex: `[link](../index.md#internal_anchor)` )
are valid.
2020-07-31 12:10:02 +00:00
- [`ui-docs-links lint` ](https://gitlab.com/gitlab-org/gitlab/-/blob/0b562014f7b71f98540e682c8d662275f0011f2f/.gitlab/ci/docs.gitlab-ci.yml#L62 )
checks that all links to docs from UI elements (`app/views` files, for example)
are linking to valid docs and anchors.
2018-11-12 13:30:41 +00:00
2020-07-31 12:10:02 +00:00
### Run tests locally
2020-03-05 12:07:48 +00:00
Apart from [previewing your changes locally ](#previewing-the-changes-live ), you can also run all lint checks
and Nanoc tests locally.
#### Lint checks
Lint checks are performed by the [`lint-doc.sh` ](https://gitlab.com/gitlab-org/gitlab/blob/master/scripts/lint-doc.sh )
script and can be executed as follows:
1. Navigate to the `gitlab` directory.
1. Run:
```shell
MD_DOC_PATH=path/to/my_doc.md scripts/lint-doc.sh
```
Where `MD_DOC_PATH` points to the file or directory you would like to run lint checks for.
If you omit it completely, it will default to the `doc/` directory.
The output should be similar to:
2020-03-25 06:07:58 +00:00
```plaintext
2020-03-05 12:07:48 +00:00
=> 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
```
Note that this requires you to either have the required lint tools installed on your machine,
or a working Docker installation, in which case an image with these tools pre-installed will be used.
2020-07-31 12:10:02 +00:00
#### Nanoc tests
To execute Nanoc tests locally:
1. Navigate to the [`gitlab-docs` ](https://gitlab.com/gitlab-org/gitlab-docs ) directory.
1. Run:
```shell
# 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-docs-links` test
The `ui-docs-links lint` job uses `haml-lint` to test that all links to docs from
UI elements (`app/views` files, for example) are linking to valid docs and anchors.
To run the `ui-docs-links` test locally:
1. Open the `gitlab` directory in a terminal window.
1. Run:
```shell
bundle exec haml-lint -i DocumentationLinks
```
If you receive an error the first time you run this test, run `bundle install` , which
installs GitLab's dependencies, and try again.
If you don't want to install all of GitLab's dependencies to test the links, you can:
1. Open the `gitlab` directory in a terminal window.
1. Install `haml-lint` :
```shell
gem install haml_lint
```
1. Run:
```shell
haml-lint -i DocumentationLinks
```
If you manually install `haml-lint` with this process, it will not update automatically
and you should make sure your version matches the version used by GitLab.
2020-06-23 03:09:26 +00:00
### Local linters
2018-11-12 13:30:41 +00:00
2019-09-02 13:25:40 +00:00
To help adhere to the [documentation style guidelines ](styleguide.md ), and improve the content
2020-06-23 03:09:26 +00:00
added to documentation, [install documentation linters ](#install-linters ) and
[integrate them with your code editor ](#configure-editors ).
2018-11-12 13:30:41 +00:00
2020-06-23 03:09:26 +00:00
At GitLab, we mostly use:
2018-11-12 13:30:41 +00:00
2020-06-23 03:09:26 +00:00
- [markdownlint ](#markdownlint )
- [Vale ](#vale )
2018-11-12 13:30:41 +00:00
2019-12-11 03:07:31 +00:00
#### markdownlint
2018-11-12 13:30:41 +00:00
2020-06-23 03:09:26 +00:00
[markdownlint ](https://github.com/DavidAnson/markdownlint ) checks that Markdown syntax follows
[certain rules ](https://github.com/DavidAnson/markdownlint/blob/master/doc/Rules.md#rules ), and is
used by the [`docs-lint` test ](#testing ).
2018-11-12 13:30:41 +00:00
2020-06-23 03:09:26 +00:00
Our [Documentation Style Guide ](styleguide.md#markdown ) and
[Markdown Guide ](https://about.gitlab.com/handbook/markdown-guide/ ) elaborate on which choices must
be made when selecting Markdown syntax for GitLab documentation. This tool helps catch deviations
from those guidelines.
2019-09-05 13:56:15 +00:00
2020-06-23 03:09:26 +00:00
markdownlint configuration is found in the following projects:
2019-09-05 13:56:15 +00:00
2020-06-23 03:09:26 +00:00
- [`gitlab` ](https://gitlab.com/gitlab-org/gitlab/blob/master/.markdownlint.json )
- [`gitlab-runner` ](https://gitlab.com/gitlab-org/gitlab-runner/blob/master/.markdownlint.json )
- [`omnibus-gitlab` ](https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/.markdownlint.json )
- [`charts` ](https://gitlab.com/gitlab-org/charts/gitlab/-/blob/master/.markdownlint.json )
- [`gitlab-development-kit` ](https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/master/.markdownlint.json )
2020-06-01 09:08:28 +00:00
2020-06-23 03:09:26 +00:00
This configuration is also used within build pipelines.
2018-11-12 13:30:41 +00:00
2020-06-23 03:09:26 +00:00
You can use markdownlint:
2018-11-12 13:30:41 +00:00
2020-06-23 03:09:26 +00:00
- [On the command line ](https://github.com/igorshubovych/markdownlint-cli#markdownlint-cli-- ).
- [Within a code editor ](#configure-editors ).
2020-08-05 09:10:01 +00:00
- [In a `pre-commit` hook ](#configure-pre-commit-hooks ).
2018-11-12 13:30:41 +00:00
2020-06-23 03:09:26 +00:00
#### Vale
2018-11-12 13:30:41 +00:00
2020-06-23 03:09:26 +00:00
[Vale ](https://errata-ai.gitbook.io/vale/ ) is a grammar, style, and word usage linter for the
English language. Vale's configuration is stored in the
[`.vale.ini` ](https://gitlab.com/gitlab-org/gitlab/blob/master/.vale.ini ) file located in the root
directory of projects.
2018-11-12 13:30:41 +00:00
2020-06-23 03:09:26 +00:00
Vale supports creating [custom tests ](https://errata-ai.github.io/vale/styles/ ) that extend any of
several types of checks, which we store in the `.linting/vale/styles/gitlab` directory within the
documentation directory of projects.
2018-11-12 13:30:41 +00:00
2020-06-23 03:09:26 +00:00
Vale configuration is found in the following projects:
2018-11-12 13:30:41 +00:00
2020-06-23 03:09:26 +00:00
- [`gitlab` ](https://gitlab.com/gitlab-org/gitlab/-/tree/master/doc/.vale/gitlab )
- [`gitlab-runner` ](https://gitlab.com/gitlab-org/gitlab-runner/-/tree/master/docs/.vale/gitlab )
- [`omnibus-gitlab` ](https://gitlab.com/gitlab-org/omnibus-gitlab/-/tree/master/doc/.vale/gitlab )
- [`charts` ](https://gitlab.com/gitlab-org/charts/gitlab/-/tree/master/doc/.vale/gitlab )
- [`gitlab-development-kit` ](https://gitlab.com/gitlab-org/gitlab-development-kit/-/tree/master/doc/.vale/gitlab )
2020-01-27 06:08:57 +00:00
2020-06-23 03:09:26 +00:00
This configuration is also used within build pipelines.
2020-01-27 06:08:57 +00:00
2020-06-23 03:09:26 +00:00
You can use Vale:
2020-01-27 06:08:57 +00:00
2020-06-23 03:09:26 +00:00
- [On the command line ](https://errata-ai.gitbook.io/vale/getting-started/usage ).
- [Within a code editor ](#configure-editors ).
2020-08-05 09:10:01 +00:00
- [In a `pre-commit` hook ](#configure-pre-commit-hooks ). Vale only reports errors in the
`pre-commit` hook (the same configuration as the CI/CD pipelines), and does not report suggestions
or warnings.
2020-02-05 03:08:49 +00:00
2020-06-23 03:09:26 +00:00
#### Install linters
At a minimum, install [markdownlint ](#markdownlint ) and [Vale ](#vale ) to match the checks run in
build pipelines:
2020-02-05 03:08:49 +00:00
2020-06-23 03:09:26 +00:00
1. Install `markdownlint-cli` , using either:
2020-05-18 21:08:42 +00:00
2020-06-23 03:09:26 +00:00
- `npm` :
```shell
npm install -g markdownlint-cli
```
- `yarn` :
```shell
yarn global add markdownlint-cli
```
We recommend installing the version of `markdownlint-cli` currently used in the documentation
2020-10-13 15:08:53 +00:00
linting [Docker image ](https://gitlab.com/gitlab-org/gitlab-docs/-/blob/master/.gitlab-ci.yml#L420 ).
2020-06-23 03:09:26 +00:00
1. Install [`vale` ](https://github.com/errata-ai/vale/releases ). For example, to install using
`brew` for macOS, run:
```shell
brew install vale
```
We recommend installing the version of Vale currently used in the documentation linting
2020-10-13 15:08:53 +00:00
[Docker image ](https://gitlab.com/gitlab-org/gitlab-docs/-/blob/master/.gitlab-ci.yml#L419 ).
2020-06-23 03:09:26 +00:00
In addition to using markdownlint and Vale at the command line, these tools can be
[integrated with your code editor ](#configure-editors ).
#### Configure editors
To configure markdownlint within your editor, install one of the following as appropriate:
- [Sublime Text ](https://packagecontrol.io/packages/SublimeLinter-contrib-markdownlint )
- [Visual Studio Code ](https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint )
- [Atom ](https://atom.io/packages/linter-node-markdownlint )
2020-08-04 06:10:16 +00:00
- [Vim ](https://github.com/dense-analysis/ale )
2020-06-01 09:08:28 +00:00
2020-06-23 03:09:26 +00:00
To configure Vale within your editor, install one of the following as appropriate:
2020-06-01 09:08:28 +00:00
2020-09-02 03:10:30 +00:00
- The Sublime Text [`SublimeLinter-contrib-vale` plugin ](https://packagecontrol.io/packages/SublimeLinter-contrib-vale ).
- The Visual Studio Code [`errata-ai.vale-server` extension ](https://marketplace.visualstudio.com/items?itemName=errata-ai.vale-server ). You don't need Vale Server to use the plugin.
- [Vim ](https://github.com/dense-analysis/ale ).
2020-06-01 09:08:28 +00:00
We don't use [Vale Server ](https://errata-ai.github.io/vale/#using-vale-with-a-text-editor-or-another-third-party-application ).
2020-08-05 09:10:01 +00:00
#### Configure pre-commit hooks
Git [pre-commit hooks ](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks ) allow Git users to
run tests or other processes before committing to a branch, with the ability to not commit to the branch if
failures occur with these tests.
[`overcommit` ](https://github.com/sds/overcommit ) is a Git hooks manager, making configuring,
installing, and removing Git hooks easy.
Sample configuration for `overcommit` is available in the
[`.overcommit.yml.example` ](https://gitlab.com/gitlab-org/gitlab/-/blob/master/.overcommit.yml.example )
file for the [`gitlab` ](https://gitlab.com/gitlab-org/gitlab ) project.
To set up `overcommit` for documentation linting, see
2020-10-30 06:08:54 +00:00
[Pre-commit static analysis ](../contributing/style_guides.md#pre-push-static-analysis ).
2020-08-05 09:10:01 +00:00
2020-06-23 03:09:26 +00:00
#### Disable Vale tests
2020-05-18 21:08:42 +00:00
2020-06-23 03:09:26 +00:00
You can disable a specific Vale linting rule or all Vale linting rules for any portion of a
document:
2020-05-18 21:08:42 +00:00
2020-06-23 03:09:26 +00:00
- 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 `rulename` with the filename
of a test in the
[GitLab styles ](https://gitlab.com/gitlab-org/gitlab/-/tree/master/doc/.linting/vale/styles/gitlab )
directory.
- To disable all Vale linting rules, add a `<!-- vale off -->` tag before the text, and a
`<!-- vale on -->` tag after the text.
2020-05-18 21:08:42 +00:00
2020-09-02 03:10:30 +00:00
Whenever possible, exclude only the problematic rule and line(s).
2020-05-18 21:08:42 +00:00
2020-06-23 03:09:26 +00:00
For more information, see
[Vale's documentation ](https://errata-ai.gitbook.io/vale/getting-started/markup#markup-based-configuration ).
2020-05-18 21:08:42 +00:00
2018-12-29 00:29:59 +00:00
## Danger Bot
2018-11-12 13:30:41 +00:00
2018-12-29 00:29:59 +00:00
GitLab uses [Danger ](https://github.com/danger/danger ) for some elements in
code review. For docs changes in merge requests, whenever a change to files under `/doc`
is made, Danger Bot leaves a comment with further instructions about the documentation
2020-05-19 18:08:11 +00:00
process. This is configured in the `Dangerfile` in the GitLab repository under
2019-09-17 09:06:11 +00:00
[/danger/documentation/ ](https://gitlab.com/gitlab-org/gitlab/tree/master/danger/documentation ).
2020-08-31 15:10:41 +00:00
## Automatic screenshot generator
You can now set up an automatic screenshot generator to take and compress screenshots, with the
help of a configuration file known as **screenshot generator** .
### Use the tool
To run the tool on an existing screenshot generator, take the following steps:
1. Set up the [GitLab Development Kit (GDK) ](https://gitlab.com/gitlab-org/gitlab-development-kit/blob/master/doc/howto/gitlab_docs.md ).
1. Navigate to the subdirectory with your cloned GitLab repository, typically `gdk/gitlab` .
1. Make sure that your GDK database is fully migrated: `bin/rake db:migrate RAILS_ENV=development` .
1. Install pngquant, see the tool website for more info: [`pngquant` ](https://pngquant.org/ )
1. Run `scripts/docs_screenshots.rb spec/docs_screenshots/<name_of_screenshot_generator>.rb <milestone-version>` .
1. Identify the location of the screenshots, based on the `gitlab/doc` location defined by the `it` parameter in your script.
1. Commit the newly created screenshots.
### Extending the tool
To add an additional **screenshot generator** , take the following steps:
- Locate the `spec/docs_screenshots` directory.
- Add a new file with a `_docs.rb` extension.
- Be sure to include the following bits in the file:
```ruby
require 'spec_helper'
RSpec.describe '< What I am taking screenshots of > ', :js do
include DocsScreenshotHelpers # Helper that enables the screenshots taking mechanism
before do
page.driver.browser.manage.window.resize_to(1366, 1024) # length and width of the page
end
```
- In addition, every `it` block must include the path where the screenshot is saved
```ruby
it 'user/packages/container_registry/img/project_image_repositories_list'
```
#### Full page screenshots
To take a full page screenshot simply `visit the page` and perform any expectation on real content (to have capybara wait till the page is ready and not take a white screenshot).
#### Element screenshot
To have the screenshot focuses few more steps are needed:
- **find the area**: `screenshot_area = find('#js-registry-policies')`
- **scroll the area in focus**: `scroll_to screenshot_area`
- **wait for the content**: `expect(screenshot_area).to have_content 'Expiration interval'`
- **set the crop area**: `set_crop_data(screenshot_area, 20)`
In particular `set_crop_data` accepts as arguments: a `DOM` element and a padding, the padding will be added around the element enlarging the screenshot area.
#### Live example
Please use `spec/docs_screenshots/container_registry_docs.rb` as a guide and as an example to create your own scripts.