2018-06-06 07:32:38 -04:00
---
2020-09-29 14:09:52 -04:00
stage: none
group: Documentation Guidelines
2020-11-26 01:09:20 -05:00
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/#assignments
2018-06-06 07:32:38 -04:00
description: Learn how to contribute to GitLab Documentation.
---
# GitLab Documentation guidelines
2020-12-10 01:09:47 -05:00
The GitLab 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 13:29:36 -05:00
2020-04-29 14:09:56 -04:00
In addition to this page, the following resources can help you craft and contribute to documentation:
2018-12-31 13:29:36 -05:00
2020-11-12 16:09:19 -05:00
- [Style Guide ](styleguide/index.md ) - What belongs in the docs, language guidelines, Markdown standards to follow, links, and more.
2021-02-01 19:09:14 -05:00
- [Topic type template ](structure.md ) - Learn about the different types of topics.
2019-10-14 02:06:06 -04:00
- [Documentation process ](workflow.md ).
2019-10-13 23:06:12 -04: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 17:09:38 -04:00
- [Documentation for feature flags ](feature_flags.md ) - How to write and update documentation for GitLab features deployed behind feature flags.
2018-12-31 13:29:36 -05:00
2019-04-16 01:17:36 -04:00
## Source files and rendered web locations
2018-12-20 22:08:27 -05:00
2020-03-02 04:07:59 -05: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 02:06:27 -04: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-20 22:08:27 -05:00
2019-04-16 01:17:36 -04:00
The source of the documentation exists within the codebase of each GitLab application in the following repository locations:
2018-12-20 22:08:27 -05:00
| Project | Path |
| --- | --- |
2021-06-08 14:10:23 -04:00
| [GitLab ](https://gitlab.com/gitlab-org/gitlab/ ) | [`/doc` ](https://gitlab.com/gitlab-org/gitlab/-/tree/master/doc ) |
2021-06-03 11:10:01 -04:00
| [GitLab Runner ](https://gitlab.com/gitlab-org/gitlab-runner/ ) | [`/docs` ](https://gitlab.com/gitlab-org/gitlab-runner/-/tree/main/docs ) |
2020-06-29 11:08:56 -04:00
| [Omnibus GitLab ](https://gitlab.com/gitlab-org/omnibus-gitlab/ ) | [`/doc` ](https://gitlab.com/gitlab-org/omnibus-gitlab/tree/master/doc ) |
2019-10-11 02:06:27 -04:00
| [Charts ](https://gitlab.com/gitlab-org/charts/gitlab ) | [`/doc` ](https://gitlab.com/gitlab-org/charts/gitlab/tree/master/doc ) |
2018-12-20 22:08:27 -05:00
Documentation issues and merge requests are part of their respective repositories and all have the label `Documentation` .
2019-12-02 19:06:28 -05: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
2020-11-18 10:09:08 -05:00
**only** documentation changes, then only documentation-related jobs run, and
the pipeline completes much faster than a code contribution.
2019-12-02 19:06:28 -05:00
2021-08-04 14:09:57 -04:00
If you are submitting documentation-only changes to Omnibus or Charts,
2019-12-02 19:06:28 -05:00
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 07:32:38 -04:00
## Contributing to docs
2018-12-31 14:25:53 -05:00
[Contributions to GitLab docs ](workflow.md ) are welcome from the entire GitLab community.
2018-12-20 22:08:27 -05:00
2020-09-28 02:09:56 -04: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-20 22:08:27 -05:00
2020-09-28 02:09:56 -04: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-20 22:08:27 -05:00
2018-06-06 07:32:38 -04:00
## Markdown and styles
2019-07-11 07:58:49 -04:00
[GitLab docs ](https://gitlab.com/gitlab-org/gitlab-docs ) uses [GitLab Kramdown ](https://gitlab.com/gitlab-org/gitlab_kramdown )
2020-05-28 23:08:11 -04: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 07:32:38 -04:00
2020-11-12 16:09:19 -05:00
Adhere to the [Documentation Style Guide ](styleguide/index.md ). If a style standard is missing, you are welcome to suggest one via a merge request.
2018-06-06 07:32:38 -04:00
2019-04-16 01:17:36 -04:00
## Folder structure and files
2022-01-26 22:14:06 -05:00
See the [Folder structure ](site_architecture/folder_structure.md ) page.
2019-04-16 01:17:36 -04:00
2020-05-27 14:08:14 -04:00
## Metadata
To provide additional directives or useful information, we add metadata in YAML
2020-06-24 23:08:52 -04: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-12-07 16:10:08 -05:00
- `stage` : The [Stage ](https://about.gitlab.com/handbook/product/categories/#devops-stages )
2020-06-24 23:08:52 -04: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
2020-11-26 01:09:20 -05:00
https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2020-06-24 23:08:52 -04:00
```
2020-05-27 14:08:14 -04:00
2021-02-08 16:09:25 -05:00
For example:
2020-05-27 14:08:14 -04:00
```yaml
---
2021-02-08 16:09:25 -05:00
stage: Example Stage
group: Example Group
2020-11-26 01:09:20 -05:00
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/#assignments
2020-05-27 14:08:14 -04:00
---
```
2021-02-08 16:09:25 -05:00
If you need help determining the correct stage, read [Ask for help ](workflow.md#ask-for-help ).
2020-06-24 23:08:52 -04:00
### Redirection metadata
The following metadata should be added when a page is moved to another location:
2020-05-27 14:08:14 -04: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.
2021-08-26 17:11:25 -04:00
[Learn more ](redirects.md ).
2020-05-27 14:08:14 -04:00
- `disqus_identifier` : Identifier for Disqus commenting system. Used to keep
comments with a page that's been moved to a new URL.
2021-08-26 17:11:25 -04:00
[Learn more ](redirects.md#redirections-for-pages-with-disqus-comments ).
2020-05-27 14:08:14 -04:00
2020-06-24 23:08:52 -04: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 17:08:44 -04:00
Each page can have additional, optional metadata (set in the
2020-06-24 23:08:52 -04:00
[default.html ](https://gitlab.com/gitlab-org/gitlab-docs/-/blob/fc3577921343173d589dfa43d837b4307e4e620f/layouts/default.html#L30-52 )
2021-07-30 05:10:05 -04:00
Nanoc layout), which is displayed at the top of the page if defined.
2020-06-24 23:08:52 -04:00
2021-09-21 08:11:06 -04:00
### Deprecated metadata
The `type` metadata parameter is deprecated but still exists in documentation
pages. You can safely remove the `type` metadata parameter and its values.
2021-09-23 18:34:10 -04:00
## Move, rename, or delete a page
2020-09-29 14:09:52 -04:00
2021-08-26 17:11:25 -04:00
See [redirects ](redirects.md ).
2018-06-06 07:32:38 -04: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 01:13:27 -05:00
[documentation workflow ](workflow.md ).
2018-06-06 07:32:38 -04:00
2021-06-08 14:10:23 -04: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 02:10:03 -04: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 07:32:38 -04:00
2020-11-18 10:09:08 -05:00
Documentation is merged if it is an improvement on existing content,
2018-12-31 14:02:55 -05:00
represents a good-faith effort to follow the template and style standards,
and is believed to be accurate.
2018-12-24 13:46:45 -05:00
2018-12-31 14:02:55 -05:00
Further needs for what would make the doc even better should be immediately addressed
2020-10-13 20:08:48 -04:00
in a follow-up merge request or issue.
2018-12-24 13:46:45 -05:00
2018-06-06 07:32:38 -04:00
If the release version you want to add the documentation to has already been
2020-05-18 14:08:22 -04:00
frozen or released, use the label `~"Pick into X.Y"` to get it merged into
2018-06-06 07:32:38 -04: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`
2021-11-02 17:11:52 -04:00
Every GitLab instance includes documentation at `/help` (`https://gitlab.example.com/help`)
that matches the version of the instance. For example, < https: / / gitlab . com / help > .
The documentation available online at < https: / / docs . gitlab . com > is deployed every
four hours from the default branch of [GitLab, Omnibus, Runner, and Charts ](#source-files-and-rendered-web-locations ).
After a merge request that updates documentation is merged, it is available online
in 4 hours or less.
However, it's only available at `/help` on self-managed instances in the next released
version. The date an update is merged can impact which self-managed release the update
is present in.
For example:
1. A merge request in `gitlab` updates documentation. It has a milestone of 14.4,
with an expected release date of 2021-10-22.
1. It is merged on 2021-10-19 and available online the same day at < https: // docs . gitlab . com > .
1. GitLab 14.4 is released on 2021-10-22, based on the `gitlab` codebase from 2021-10-18
(one day *before* the update was merged).
1. The change shows up in the 14.5 self-managed release, due to missing the release cutoff
for 14.4.
The exact cutoff date for each release is flexible, and can be earlier or later
than expected due to holidays, weekends, or other events. In general, MRs merged
by the 17th should be present in the release on the 22nd, though it is not guaranteed.
If it is important that a documentation update is present in that month's release,
merge it as early as possible.
2018-09-20 03:13:30 -04:00
### Linking to `/help`
2021-02-09 19:09:33 -05:00
When you're building a new feature, you may need to link to the documentation
from the GitLab application. This is normally done in files inside the
`app/views/` directory, with the help of the `help_page_path` helper method.
2018-06-06 07:32:38 -04:00
2021-02-09 19:09:33 -05:00
The `help_page_path` contains the path to the document you want to link to,
with the following conventions:
2018-06-06 07:32:38 -04:00
2021-02-09 19:09:33 -05:00
- It's relative to the `doc/` directory in the GitLab repository.
- It omits the `.md` extension.
- It doesn't end with a slash (`/`).
2018-06-06 07:32:38 -04:00
2021-02-09 19:09:33 -05:00
The help text follows the [Pajamas guidelines ](https://design.gitlab.com/usability/helping-users/#formatting-help-content ).
2018-06-06 07:32:38 -04:00
2021-10-07 20:11:52 -04:00
#### Linking to `/help` in HAML
Use the following special cases depending on the context, ensuring all link text
is inside `_()` so it can be translated:
2018-06-06 07:32:38 -04:00
2021-02-09 19:09:33 -05:00
- Linking to a doc page. In its most basic form, the HAML code to generate a
link to the `/help` page is:
2018-06-06 07:32:38 -04:00
2021-02-09 19:09:33 -05:00
```haml
= link_to _('Learn more.'), help_page_path('user/permissions'), target: '_blank', rel: 'noopener noreferrer'
```
2018-06-06 07:32:38 -04:00
2021-02-09 19:09:33 -05:00
- Linking to an anchor link. Use `anchor` as part of the `help_page_path`
method:
2018-06-06 07:32:38 -04:00
2021-02-09 19:09:33 -05:00
```haml
= link_to _('Learn more.'), help_page_path('user/permissions', anchor: 'anchor-link'), target: '_blank', rel: 'noopener noreferrer'
```
2018-06-06 07:32:38 -04:00
2021-02-09 19:09:33 -05:00
- Using links inline of some text. First, define the link, and then use it. In
this example, `link_start` is the name of the variable that contains the
link:
2018-06-06 07:32:38 -04:00
2021-02-09 19:09:33 -05:00
```haml
- link_start = '< a href = "%{url}" target = "_blank" rel = "noopener noreferrer" > '.html_safe % { url: help_page_path('user/permissions') }
%p= _("This is a text describing the option/feature in a sentence. %{link_start}Learn more.%{link_end}").html_safe % { link_start: link_start, link_end: '< / a > '.html_safe }
```
2018-06-06 07:32:38 -04:00
2021-02-09 19:09:33 -05:00
- Using a button link. Useful in places where text would be out of context with
the rest of the page layout:
2018-06-06 07:32:38 -04:00
2021-02-09 19:09:33 -05:00
```haml
= link_to _('Learn more.'), help_page_path('user/permissions'), class: 'btn btn-info', target: '_blank', rel: 'noopener noreferrer'
```
2018-06-06 07:32:38 -04:00
2021-01-13 16:11:00 -05:00
#### Linking to `/help` in JavaScript
To link to the documentation from a JavaScript or a Vue component, use the `helpPagePath` function from [`help_page_helper.js` ](https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/assets/javascripts/helpers/help_page_helper.js ):
```javascript
import { helpPagePath } from '~/helpers/help_page_helper';
helpPagePath('user/permissions', { anchor: 'anchor-link' })
// evaluates to '/help/user/permissions#anchor-link' for GitLab.com
```
This is preferred over static paths, as the helper also works on instances installed under a [relative URL ](../../install/relative_url.md ).
2021-10-07 20:11:52 -04:00
#### Linking to `/help` in Ruby
To link to the documentation from within Ruby code, use the following code block as a guide, ensuring all link text is inside `_()` so it can
be translated:
```ruby
docs_link = link_to _('Learn more.'), help_page_url('user/permissions', anchor: 'anchor-link'), target: '_blank', rel: 'noopener noreferrer'
_('This is a text describing the option/feature in a sentence. %{docs_link}').html_safe % { docs_link: docs_link.html_safe }
```
In cases where you need to generate a link from outside of views/helpers, where the `link_to` and `help_page_url` methods are not available, use the following code block
as a guide where the methods are fully qualified:
```ruby
docs_link = ActionController::Base.helpers.link_to _('Learn more.'), Rails.application.routes.url_helpers.help_page_url('user/permissions', anchor: 'anchor-link'), target: '_blank', rel: 'noopener noreferrer'
_('This is a text describing the option/feature in a sentence. %{docs_link}').html_safe % { docs_link: docs_link.html_safe }
```
Do not use `include ActionView::Helpers::UrlHelper` just to make the `link_to` method available as you might see in some existing code. Read more in
[issue 340567 ](https://gitlab.com/gitlab-org/gitlab/-/issues/340567 ).
2018-12-07 00:27:09 -05:00
### GitLab `/help` tests
2021-06-08 14:10:23 -04:00
Several [RSpec tests ](https://gitlab.com/gitlab-org/gitlab/-/blob/master/spec/features/help_pages_spec.rb )
2021-06-28 08:38:12 -04:00
are run to ensure GitLab documentation renders and works correctly. In particular, that [main docs landing page ](../../index.md ) works correctly from `/help` .
2018-12-07 00:27:09 -05:00
For example, [GitLab.com's `/help` ](https://gitlab.com/help ).
2018-12-11 08:39:37 -05:00
## Docs site architecture
2022-02-02 19:18:25 -05:00
For information on how we build and deploy < https: // docs . gitlab . com > , see [Docs site architecture ](site_architecture/index.md ).
2018-12-11 08:39:37 -05:00
### Global navigation
2018-12-28 19:29:59 -05: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 07:32:38 -04:00
2018-11-12 08:30:41 -05:00
## Previewing the changes live
2021-08-23 23:10:40 -04:00
See how you can use review apps to [preview your changes live ](review_apps.md ).
2018-11-12 08:30:41 -05:00
## Testing
2021-03-29 14:09:37 -04:00
For more information about documentation testing, see the [Documentation testing ](testing.md )
guide.
2020-05-18 17:08:42 -04:00
2018-12-28 19:29:59 -05:00
## Danger Bot
2018-11-12 08:30:41 -05:00
2018-12-28 19:29:59 -05: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 14:08:11 -04:00
process. This is configured in the `Dangerfile` in the GitLab repository under
2021-06-08 14:10:23 -04:00
[/danger/documentation/ ](https://gitlab.com/gitlab-org/gitlab/-/tree/master/danger/documentation ).
2020-08-31 11:10:41 -04: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:
2021-04-26 17:10:25 -04:00
1. Set up the [GitLab Development Kit (GDK) ](https://gitlab.com/gitlab-org/gitlab-development-kit/blob/main/doc/howto/gitlab_docs.md ).
2020-08-31 11:10:41 -04:00
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` .
2021-01-29 16:09:34 -05:00
1. Install `pngquant` , see the tool website for more information: [`pngquant` ](https://pngquant.org/ )
2020-08-31 11:10:41 -04:00
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)`
2020-11-18 10:09:08 -05:00
In particular, `set_crop_data` accepts as arguments: a `DOM` element and a
padding. The padding is added around the element, enlarging the screenshot area.
2020-08-31 11:10:41 -04:00
#### Live example
Please use `spec/docs_screenshots/container_registry_docs.rb` as a guide and as an example to create your own scripts.