Commit 40e9e440 authored by Achilleas Pipinellis's avatar Achilleas Pipinellis

Merge branch 'docs-refactor-dev-guides' into 'master'

Docs: refactor doc general guidelines and style guidelines

Closes #41281

See merge request gitlab-org/gitlab-ce!17378
parents f1542a90 536e57d5
# Documentation styleguide # Documentation style guidelines
This styleguide recommends best practices to improve documentation and to keep The documentation style guide defines the markup structure used in
it organized and easy to find. GitLab documentation. Check the
[documentation guidelines](writing_documentation.md) for general development instructions.
See also [writing documentation](writing_documentation.md). Check the GitLab hanbook for the [writing styles guidelines](https://about.gitlab.com/handbook/communication/#writing-style-guidelines).
## Location and naming of documents
>**Note:**
These guidelines derive from the discussion taken place in issue [#3349][ce-3349].
The documentation hierarchy can be vastly improved by providing a better layout
and organization of directories.
Having a structured document layout, we will be able to have meaningful URLs
like `docs.gitlab.com/user/project/merge_requests.html`. With this pattern,
you can immediately tell that you are navigating a user related documentation
and is about the project and its merge requests.
Do not create summaries of similar types of content (e.g. an index of all articles, videos, etc.),
rather organise content by its subject (e.g. everything related to CI goes together)
and cross-link between any related content.
The table below shows what kind of documentation goes where.
| Directory | What belongs here |
| --------- | -------------- |
| `doc/user/` | User related documentation. Anything that can be done within the GitLab UI goes here including `/admin`. |
| `doc/administration/` | Documentation that requires the user to have access to the server where GitLab is installed. The admin settings that can be accessed via GitLab's interface go under `doc/user/admin_area/`. |
| `doc/api/` | API related documentation. |
| `doc/development/` | Documentation related to the development of GitLab. Any styleguides should go here. |
| `doc/legal/` | Legal documents about contributing to GitLab. |
| `doc/install/`| Probably the most visited directory, since `installation.md` is there. Ideally this should go under `doc/administration/`, but it's best to leave it as-is in order to avoid confusion (still debated though). |
| `doc/update/` | Same with `doc/install/`. Should be under `administration/`, but this is a well known location, better leave as-is, at least for now. |
| `doc/topics/` | Indexes per Topic (`doc/topics/topic-name/index.md`): all resources for that topic (user and admin documentation, articles, and third-party docs) |
---
**General rules:**
1. The correct naming and location of a new document, is a combination
of the relative URL of the document in question and the GitLab Map design
that is used for UX purposes ([source][graffle], [image][gitlab-map]).
1. When creating a new document and it has more than one word in its name,
make sure to use underscores instead of spaces or dashes (`-`). For example,
a proper naming would be `import_projects_from_github.md`. The same rule
applies to images.
1. There are four main directories, `user`, `administration`, `api` and `development`.
1. The `doc/user/` directory has five main subdirectories: `project/`, `group/`,
`profile/`, `dashboard/` and `admin_area/`.
1. `doc/user/project/` should contain all project related documentation.
1. `doc/user/group/` should contain all group related documentation.
1. `doc/user/profile/` should contain all profile related documentation.
Every page you would navigate under `/profile` should have its own document,
i.e. `account.md`, `applications.md`, `emails.md`, etc.
1. `doc/user/dashboard/` should contain all dashboard related documentation.
1. `doc/user/admin_area/` should contain all admin related documentation
describing what can be achieved by accessing GitLab's admin interface
(_not to be confused with `doc/administration` where server access is
required_).
1. Every category under `/admin/application_settings` should have its
own document located at `doc/user/admin_area/settings/`. For example,
the **Visibility and Access Controls** category should have a document
located at `doc/user/admin_area/settings/visibility_and_access_controls.md`.
1. The `doc/topics/` directory holds topic-related technical content. Create
`doc/topics/topic-name/subtopic-name/index.md` when subtopics become necessary.
General user- and admin- related documentation, should be placed accordingly.
---
If you are unsure where a document should live, you can ping `@axil` or `@marcia` in your
merge request.
## Text ## Text
- Split up long lines, this makes it much easier to review and edit. Only - Split up long lines (wrap text), this makes it much easier to review and edit. Only
double line breaks are shown as a full line break in [GitLab markdown][gfm]. double line breaks are shown as a full line break in [GitLab markdown][gfm].
80-100 characters is a good line length 80-100 characters is a good line length
- Make sure that the documentation is added in the correct directory and that - Make sure that the documentation is added in the correct
[directory](writing_documentation.md#documentation-directory-structure) and that
there's a link to it somewhere useful there's a link to it somewhere useful
- Do not duplicate information - Do not duplicate information
- Be brief and clear - Be brief and clear
- Unless there's a logical reason not to, add documents in alphabetical order - Unless there's a logical reason not to, add documents in alphabetical order
- Write in US English - Write in US English
- Use [single spaces][] instead of double spaces - Use [single spaces][] instead of double spaces
- Jump a line between different markups (e.g., after every paragraph, hearder, list, etc)
- Capitalize "G" and "L" in GitLab
- Capitalize feature, products, and methods names. E.g.: GitLab Runner, Geo,
Issue Boards, Git, Prometheus, Continuous Integration.
## Formatting ## Formatting
...@@ -103,6 +42,8 @@ merge request. ...@@ -103,6 +42,8 @@ merge request.
links shift too, which eventually leads to dead links. If you think it is links shift too, which eventually leads to dead links. If you think it is
compelling to add numbers in headings, make sure to at least discuss it with compelling to add numbers in headings, make sure to at least discuss it with
someone in the Merge Request someone in the Merge Request
- [Avoid using symbols and special chars](https://gitlab.com/gitlab-com/gitlab-docs/issues/84)
in headers. Whenever possible, they should be plain and short text.
- Avoid adding things that show ephemeral statuses. For example, if a feature is - Avoid adding things that show ephemeral statuses. For example, if a feature is
considered beta or experimental, put this info in a note, not in the heading. considered beta or experimental, put this info in a note, not in the heading.
- When introducing a new document, be careful for the headings to be - When introducing a new document, be careful for the headings to be
...@@ -121,71 +62,18 @@ merge request. ...@@ -121,71 +62,18 @@ merge request.
you can use `[Text][identifier]` and at the bottom of the section or the you can use `[Text][identifier]` and at the bottom of the section or the
document add: `[identifier]: https://example.com`, in which case, we do document add: `[identifier]: https://example.com`, in which case, we do
encourage you to also add an alternative text: `[identifier]: https://example.com "Alternative text"` that appears when hovering your mouse on a link. encourage you to also add an alternative text: `[identifier]: https://example.com "Alternative text"` that appears when hovering your mouse on a link.
- To link to internal documentation, use relative links, not full URLs. Use `../` to
### Linking to inline docs navigate tp high-level directories, and always add the file name `file.md` at the
end of the link with the `.md` extension, not `.html`.
Sometimes it's needed to link to the built-in documentation that GitLab provides Example: instead of `[text](../../merge_requests/)`, use
under `/help`. This is normally done in files inside the `app/views/` directory `[text](../../merge_requests/index.md)` or, `[text](../../ci/README.md)`, or,
with the help of the `help_page_path` helper method. for anchor links, `[text](../../ci/README.md#examples)`.
Using the markdown extension is necessary for the [`/help`](writing_documentation.md#gitlab-help)
In its simplest form, the HAML code to generate a link to the `/help` page is: section of GitLab.
- To link from CE to EE-only documentation, use the EE-only doc full URL.
```haml - Use [meaningful anchor texts](https://www.futurehosting.com/blog/links-should-have-meaningful-anchor-text-heres-why/).
= link_to 'Help page', help_page_path('user/permissions') E.g., instead of writing something like `Read more about GitLab Issue Boards [here](LINK)`,
``` write `Read more about [GitLab Issue Boards](LINK)`.
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:
```haml
= link_to 'Help page', help_page_path('user/permissions', anchor: 'anchor-link')
```
1. **Opening links in a new tab.** This should be the default behavior:
```haml
= link_to 'Help page', help_page_path('user/permissions'), target: '_blank'
```
1. **Linking to a circle icon.** Usually used in settings where a long
description cannot be used, like near checkboxes. You can basically use
any font awesome icon, but prefer the `question-circle`:
```haml
= link_to icon('question-circle'), help_page_path('user/permissions')
```
1. **Using a button link.** Useful in places where text would be out of context
with the rest of the page layout:
```haml
= link_to 'Help page', help_page_path('user/permissions'), class: 'btn btn-info'
```
1. **Using links inline of some text.**
```haml
Description to #{link_to 'Help page', help_page_path('user/permissions')}.
```
1. **Adding a period at the end of the sentence.** Useful when you don't want
the period to be part of the link:
```haml
= succeed '.' do
Learn more in the
= link_to 'Help page', help_page_path('user/permissions')
```
## Images ## Images
...@@ -222,7 +110,7 @@ Inside the document: ...@@ -222,7 +110,7 @@ Inside the document:
- Notes should be quoted with the word `Note:` being bold. Use this form: - Notes should be quoted with the word `Note:` being bold. Use this form:
``` ```md
>**Note:** >**Note:**
This is something to note. This is something to note.
``` ```
...@@ -234,25 +122,25 @@ Inside the document: ...@@ -234,25 +122,25 @@ Inside the document:
If the note spans across multiple lines it's OK to split the line. If the note spans across multiple lines it's OK to split the line.
## New features ## Specific sections and terms
New features must be shipped with its accompanying documentation and the doc To mention and/or reference specific terms in GitLab, please follow the styles
reviewed by a technical writer. below.
### Mentioning GitLab versions and tiers ### GitLab versions and tiers
- Every piece of documentation that comes with a new feature should declare the - Every piece of documentation that comes with a new feature should declare the
GitLab version that feature got introduced. Right below the heading add a GitLab version that feature got introduced. Right below the heading add a
note: note:
``` ```md
> Introduced in GitLab 8.3. > Introduced in GitLab 8.3.
``` ```
- If possible every feature should have a link to the MR, issue, or epic that introduced it. - If possible every feature should have a link to the MR, issue, or epic that introduced it.
The above note would be then transformed to: The above note would be then transformed to:
``` ```md
> [Introduced][ce-1242] in GitLab 8.3. > [Introduced][ce-1242] in GitLab 8.3.
``` ```
...@@ -263,121 +151,41 @@ reviewed by a technical writer. ...@@ -263,121 +151,41 @@ reviewed by a technical writer.
the [paid tier](https://about.gitlab.com/handbook/marketing/product-marketing/#tiers) the [paid tier](https://about.gitlab.com/handbook/marketing/product-marketing/#tiers)
the feature is available in: the feature is available in:
``` ```md
> [Introduced][ee-1234] in [GitLab Starter](https://about.gitlab.com/products/) 8.3. > [Introduced][ee-1234] in [GitLab Starter](https://about.gitlab.com/products/) 8.3.
``` ```
Otherwise, leave this mention out. Otherwise, leave this mention out.
## References ### GitLab Restart
- **GitLab Restart:**
There are many cases that a restart/reconfigure of GitLab is required. To
avoid duplication, link to the special document that can be found in
[`doc/administration/restart_gitlab.md`][doc-restart]. Usually the text will
read like:
```
Save the file and [reconfigure GitLab](../administration/restart_gitlab.md)
for the changes to take effect.
```
If the document you are editing resides in a place other than the GitLab CE/EE
`doc/` directory, instead of the relative link, use the full path:
`http://docs.gitlab.com/ce/administration/restart_gitlab.html`.
Replace `reconfigure` with `restart` where appropriate.
## Installation guide
- **Ruby:**
In [step 2 of the installation guide](../install/installation.md#2-ruby),
we install Ruby from source. Whenever there is a new version that needs to
be updated, remember to change it throughout the codeblock and also replace
the sha256sum (it can be found in the [downloads page][ruby-dl] of the Ruby
website).
[ruby-dl]: https://www.ruby-lang.org/en/downloads/ "Ruby download website" There are many cases that a restart/reconfigure of GitLab is required. To
avoid duplication, link to the special document that can be found in
## Changing document location [`doc/administration/restart_gitlab.md`][doc-restart]. Usually the text will
read like:
Changing a document's location is not to be taken lightly. Remember that the
documentation is available to all installations under `help/` and not only to
GitLab.com or http://docs.gitlab.com. Make sure this is discussed with the
Documentation team beforehand.
If you indeed need to change a document's location, do NOT remove the old
document, but rather replace all of its contents with a new line:
```
This document was moved to [another location](path/to/new_doc.md).
```
where `path/to/new_doc.md` is the relative path to the root directory `doc/`. ```
Save the file and [reconfigure GitLab](../administration/restart_gitlab.md)
for the changes to take effect.
```
--- If the document you are editing resides in a place other than the GitLab CE/EE
`doc/` directory, instead of the relative link, use the full path:
`http://docs.gitlab.com/ce/administration/restart_gitlab.html`.
Replace `reconfigure` with `restart` where appropriate.
For example, if you were to move `doc/workflow/lfs/lfs_administration.md` to ### Installation guide
`doc/administration/lfs.md`, then the steps would be:
1. Copy `doc/workflow/lfs/lfs_administration.md` to `doc/administration/lfs.md` **Ruby:**
1. Replace the contents of `doc/workflow/lfs/lfs_administration.md` with: In [step 2 of the installation guide](../install/installation.md#2-ruby),
we install Ruby from source. Whenever there is a new version that needs to
be updated, remember to change it throughout the codeblock and also replace
the sha256sum (it can be found in the [downloads page][ruby-dl] of the Ruby
website).
``` [ruby-dl]: https://www.ruby-lang.org/en/downloads/ "Ruby download website"
This document was moved to [another location](../../administration/lfs.md).
```
1. Find and replace any occurrences of the old location with the new one.
A quick way to find them is to use `git grep`. First go to the root directory
where you cloned the `gitlab-ce` repository and then do:
```
git grep -n "workflow/lfs/lfs_administration"
git grep -n "lfs/lfs_administration"
```
NOTE: **Note:**
If the document being moved has any Disqus comments on it, there are extra steps
to follow documented just [below](#redirections-for-pages-with-disqus-comments).
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/`).
- 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.
You may ask why the two greps. Since we use relative paths to link to
documentation, sometimes it might be useful to search a path deeper.
- The `*.md` extension is not used when a document is linked to GitLab's
built-in help page, that's why we omit it in `git grep`.
- Use the checklist on the documentation MR description template.
### Redirections for pages with Disqus comments
If the documentation page being relocated already has any Disqus comments,
we need to preserve the Disqus thread.
Disqus uses an identifier per page, and for docs.gitlab.com, the page identifier
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.
To do that, add to the frontmatter the variable `redirect_from`,
using the old URL as value. For example, let's say I moved the document
available under `https://docs.gitlab.com/my-old-location/README.html` to a new location,
`https://docs.gitlab.com/my-new-location/index.html`.
Into the **new document** frontmatter add the following:
```yaml
---
redirect_from: 'https://docs.gitlab.com/my-old-location/README.html'
---
```
Note: it is necessary to include the file name in the `redirect_from` URL,
even if it's `index.html` or `README.html`.
## Configuration documentation for source and Omnibus installations ### Configuration documentation for source and Omnibus installations
GitLab currently officially supports two installation methods: installations GitLab currently officially supports two installation methods: installations
from source and Omnibus packages installations. from source and Omnibus packages installations.
...@@ -394,7 +202,7 @@ When there is a list of steps to perform, usually that entails editing the ...@@ -394,7 +202,7 @@ When there is a list of steps to perform, usually that entails editing the
configuration file and reconfiguring/restarting GitLab. In such case, follow configuration file and reconfiguring/restarting GitLab. In such case, follow
the style below as a guide: the style below as a guide:
```` ```md
**For Omnibus installations** **For Omnibus installations**
1. Edit `/etc/gitlab/gitlab.rb`: 1. Edit `/etc/gitlab/gitlab.rb`:
...@@ -421,7 +229,7 @@ the style below as a guide: ...@@ -421,7 +229,7 @@ the style below as a guide:
[reconfigure]: path/to/administration/restart_gitlab.md#omnibus-gitlab-reconfigure [reconfigure]: path/to/administration/restart_gitlab.md#omnibus-gitlab-reconfigure
[restart]: path/to/administration/restart_gitlab.md#installations-from-source [restart]: path/to/administration/restart_gitlab.md#installations-from-source
```` ```
In this case: In this case:
...@@ -433,7 +241,7 @@ In this case: ...@@ -433,7 +241,7 @@ In this case:
- different highlighting languages are used for each config in the code block - different highlighting languages are used for each config in the code block
- the [references](#references) guide is used for reconfigure/restart - the [references](#references) guide is used for reconfigure/restart
## Fake tokens ### Fake tokens
There may be times where a token is needed to demonstrate an API call using There may be times where a token is needed to demonstrate an API call using
cURL or a secret variable used in CI. It is strongly advised not to use real cURL or a secret variable used in CI. It is strongly advised not to use real
...@@ -456,7 +264,7 @@ You can use the following fake tokens as examples. ...@@ -456,7 +264,7 @@ You can use the following fake tokens as examples.
| Health check token | `Tu7BgjR9qeZTEyRzGG2P` | | Health check token | `Tu7BgjR9qeZTEyRzGG2P` |
| Request profile token | `7VgpS4Ax5utVD2esNstz` | | Request profile token | `7VgpS4Ax5utVD2esNstz` |
## API ### API
Here is a list of must-have items. Use them in the exact order that appears Here is a list of must-have items. Use them in the exact order that appears
on this document. Further explanation is given below. on this document. Further explanation is given below.
...@@ -472,10 +280,10 @@ on this document. Further explanation is given below. ...@@ -472,10 +280,10 @@ on this document. Further explanation is given below.
- Every method must have a cURL example. - Every method must have a cURL example.
- Every method must have a response body (in JSON format). - Every method must have a response body (in JSON format).
### Method description #### Method description
Use the following table headers to describe the methods. Attributes should Use the following table headers to describe the methods. Attributes should
always be in code blocks using backticks (`). always be in code blocks using backticks (``` ` ```).
``` ```
| Attribute | Type | Required | Description | | Attribute | Type | Required | Description |
...@@ -488,7 +296,7 @@ Rendered example: ...@@ -488,7 +296,7 @@ Rendered example:
| --------- | ---- | -------- | ----------- | | --------- | ---- | -------- | ----------- |
| `user` | string | yes | The GitLab username | | `user` | string | yes | The GitLab username |
### cURL commands #### cURL commands
- Use `https://gitlab.example.com/api/v4/` as an endpoint. - Use `https://gitlab.example.com/api/v4/` as an endpoint.
- Wherever needed use this personal access token: `9koXpg98eAheJpvBs5tK`. - Wherever needed use this personal access token: `9koXpg98eAheJpvBs5tK`.
...@@ -505,11 +313,11 @@ Rendered example: ...@@ -505,11 +313,11 @@ Rendered example:
| `-X PUT` | Use this method when updating existing objects | | `-X PUT` | Use this method when updating existing objects |
| `-X DELETE` | Use this method when removing existing objects | | `-X DELETE` | Use this method when removing existing objects |
### cURL Examples #### cURL Examples
Below is a set of [cURL][] examples that you can use in the API documentation. Below is a set of [cURL][] examples that you can use in the API documentation.
#### Simple cURL command ##### Simple cURL command
Get the details of a group: Get the details of a group:
...@@ -517,7 +325,7 @@ Get the details of a group: ...@@ -517,7 +325,7 @@ Get the details of a group:
curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/gitlab-org curl --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v4/groups/gitlab-org
``` ```
#### cURL example with parameters passed in the URL ##### cURL example with parameters passed in the URL
Create a new project under the authenticated user's namespace: Create a new project under the authenticated user's namespace:
...@@ -525,7 +333,7 @@ Create a new project under the authenticated user's namespace: ...@@ -525,7 +333,7 @@ Create a new project under the authenticated user's namespace:
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects?name=foo" curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects?name=foo"
``` ```
#### Post data using cURL's --data ##### Post data using cURL's --data
Instead of using `-X POST` and appending the parameters to the URI, you can use Instead of using `-X POST` and appending the parameters to the URI, you can use
cURL's `--data` option. The example below will create a new project `foo` under cURL's `--data` option. The example below will create a new project `foo` under
...@@ -535,7 +343,7 @@ the authenticated user's namespace. ...@@ -535,7 +343,7 @@ the authenticated user's namespace.
curl --data "name=foo" --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects" curl --data "name=foo" --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v4/projects"
``` ```
#### Post data using JSON content ##### Post data using JSON content
> **Note:** In this example we create a new group. Watch carefully the single > **Note:** In this example we create a new group. Watch carefully the single
and double quotes. and double quotes.
...@@ -544,7 +352,7 @@ and double quotes. ...@@ -544,7 +352,7 @@ and double quotes.
curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --header "Content-Type: application/json" --data '{"path": "my-group", "name": "My group"}' https://gitlab.example.com/api/v4/groups curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --header "Content-Type: application/json" --data '{"path": "my-group", "name": "My group"}' https://gitlab.example.com/api/v4/groups
``` ```
#### Post data using form-data ##### Post data using form-data
Instead of using JSON or urlencode you can use multipart/form-data which Instead of using JSON or urlencode you can use multipart/form-data which
properly handles data encoding: properly handles data encoding:
...@@ -556,7 +364,7 @@ curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form "title ...@@ -556,7 +364,7 @@ curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --form "title
The above example is run by and administrator and will add an SSH public key The above example is run by and administrator and will add an SSH public key
titled ssh-key to user's account which has an id of 25. titled ssh-key to user's account which has an id of 25.
#### Escape special characters ##### Escape special characters
Spaces or slashes (`/`) may sometimes result to errors, thus it is recommended Spaces or slashes (`/`) may sometimes result to errors, thus it is recommended
to escape them when possible. In the example below we create a new issue which to escape them when possible. In the example below we create a new issue which
...@@ -569,7 +377,7 @@ curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitl ...@@ -569,7 +377,7 @@ curl --request POST --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitl
Use `%2F` for slashes (`/`). Use `%2F` for slashes (`/`).
#### Pass arrays to API calls ##### Pass arrays to API calls
The GitLab API sometimes accepts arrays of strings or integers. For example, to The GitLab API sometimes accepts arrays of strings or integers. For example, to
restrict the sign-up e-mail domains of a GitLab instance to `*.example.com` and restrict the sign-up e-mail domains of a GitLab instance to `*.example.com` and
...@@ -584,6 +392,3 @@ curl --request PUT --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --data "domain ...@@ -584,6 +392,3 @@ curl --request PUT --header "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" --data "domain
[gfm]: http://docs.gitlab.com/ce/user/markdown.html#newlines "GitLab flavored markdown documentation" [gfm]: http://docs.gitlab.com/ce/user/markdown.html#newlines "GitLab flavored markdown documentation"
[ce-1242]: https://gitlab.com/gitlab-org/gitlab-ce/issues/1242 [ce-1242]: https://gitlab.com/gitlab-org/gitlab-ce/issues/1242
[doc-restart]: ../administration/restart_gitlab.md "GitLab restart documentation" [doc-restart]: ../administration/restart_gitlab.md "GitLab restart documentation"
[ce-3349]: https://gitlab.com/gitlab-org/gitlab-ce/issues/3349 "Documentation restructure"
[graffle]: https://gitlab.com/gitlab-org/gitlab-design/blob/d8d39f4a87b90fb9ae89ca12dc565347b4900d5e/production/resources/gitlab-map.graffle
[gitlab-map]: https://gitlab.com/gitlab-org/gitlab-design/raw/master/production/resources/gitlab-map.png
# Writing documentation # GitLab Documentation guidelines
- **General Documentation**: written by the [developers responsible by creating features](#contributing-to-docs). Should be submitted in the same merge request containing code. Feature proposals (by GitLab contributors) should also be accompanied by its respective documentation. They can be later improved by PMs and Technical Writers. - **General Documentation**: written by the [developers responsible by creating features](#contributing-to-docs). Should be submitted in the same merge request containing code. Feature proposals (by GitLab contributors) should also be accompanied by its respective documentation. They can be later improved by PMs and Technical Writers.
- **[Technical Articles](#technical-articles)**: written by any [GitLab Team](https://about.gitlab.com/team/) member, GitLab contributors, or [Community Writers](https://about.gitlab.com/handbook/product/technical-writing/community-writers/). - **[Technical Articles](#technical-articles)**: written by any [GitLab Team](https://about.gitlab.com/team/) member, GitLab contributors, or [Community Writers](https://about.gitlab.com/handbook/product/technical-writing/community-writers/).
- **Indexes per topic**: initially prepared by the Technical Writing Team, and kept up-to-date by developers and PMs in the same merge request containing code. They gather all resources for that topic in a single page (user and admin documentation, articles, and third-party docs). - **Indexes per topic**: initially prepared by the Technical Writing Team, and kept up-to-date by developers and PMs in the same merge request containing code. They gather all resources for that topic in a single page (user and admin documentation, articles, and third-party docs).
## Documentation style guidelines
All the docs follow the same [styleguide](doc_styleguide.md).
## Contributing to docs ## Contributing to docs
Whenever a feature is changed, updated, introduced, or deprecated, the merge Whenever a feature is changed, updated, introduced, or deprecated, the merge
...@@ -29,23 +25,16 @@ Whenever you submit a merge request for the documentation, use the documentation ...@@ -29,23 +25,16 @@ Whenever you submit a merge request for the documentation, use the documentation
Please check the [documentation workflow](https://about.gitlab.com/handbook/product/technical-writing/workflow/) before getting started. Please check the [documentation workflow](https://about.gitlab.com/handbook/product/technical-writing/workflow/) before getting started.
### Documentation directory structure ## Documentation structure
The documentation is structured based on the GitLab UI structure itself,
separated by [`user`](https://gitlab.com/gitlab-org/gitlab-ce/tree/master/doc/user),
[`administrator`](https://gitlab.com/gitlab-org/gitlab-ce/tree/master/doc/administration), and [`contributor`](https://gitlab.com/gitlab-org/gitlab-ce/tree/master/doc/development).
To learn where to place a new document, check the [documentation style guide](doc_styleguide.md#location-and-naming-of-documents).
In order to have a [solid site structure](https://searchengineland.com/seo-benefits-developing-solid-site-structure-277456) for our documentation, - Overview and use cases: what it is, why it is necessary, why one would use it
all docs should be linked. Every new document should be cross-linked to its related documentation, and linked from its topic-related index, when existent. - Requirements: what do we need to get started
- Tutorial: how to set it up, how to use it
The directories `/workflow/`, `/gitlab-basics/`, `/university/`, and `/articles/` have Always link a new document from its topic-related index, otherwise, it will
been deprecated and the majority their docs have been moved to their correct location not be included it in the documentation site search.
in small iterations. Don't create new docs in these folders.
To move a document from its location to another directory, read the section _Note: to be extended._
[changing document location](doc_styleguide.md#changing-document-location) of the doc style guide.
### Feature overview and use cases ### Feature overview and use cases
...@@ -75,16 +64,169 @@ overview there. ...@@ -75,16 +64,169 @@ overview there.
> **Overview** and **use cases** are required to **every** Enterprise Edition feature, > **Overview** and **use cases** are required to **every** Enterprise Edition feature,
and for every **major** feature present in Community Edition. and for every **major** feature present in Community Edition.
### Markdown ## Markdown and styles
Currently GitLab docs use Redcarpet as [markdown](../user/markdown.md) engine, but there's an [open discussion](https://gitlab.com/gitlab-com/gitlab-docs/issues/50) for implementing Kramdown in the near future. Currently GitLab docs use Redcarpet as [markdown](../user/markdown.md) engine, but there's an [open discussion](https://gitlab.com/gitlab-com/gitlab-docs/issues/50) for implementing Kramdown in the near future.
### Previewing locally All the docs follow the [documentation style guidelines](doc_styleguide.md).
To preview your changes to documentation locally, please follow ## Documentation directory structure
this [development guide](https://gitlab.com/gitlab-com/gitlab-docs/blob/master/README.md#development).
The documentation is structured based on the GitLab UI structure itself,
separated by [`user`](https://gitlab.com/gitlab-org/gitlab-ce/tree/master/doc/user),
[`administrator`](https://gitlab.com/gitlab-org/gitlab-ce/tree/master/doc/administration), and [`contributor`](https://gitlab.com/gitlab-org/gitlab-ce/tree/master/doc/development).
In order to have a [solid site structure](https://searchengineland.com/seo-benefits-developing-solid-site-structure-277456) for our documentation,
all docs should be linked. Every new document should be cross-linked to its related documentation, and linked from its topic-related index, when existent.
The directories `/workflow/`, `/gitlab-basics/`, `/university/`, and `/articles/` have
been deprecated and the majority their docs have been moved to their correct location
in small iterations. Please don't create new docs in these folders.
### Location and naming documents
The documentation hierarchy can be vastly improved by providing a better layout
and organization of directories.
Having a structured document layout, we will be able to have meaningful URLs
like `docs.gitlab.com/user/project/merge_requests/index.html`. With this pattern,
you can immediately tell that you are navigating a user related documentation
and is about the project and its merge requests.
Do not create summaries of similar types of content (e.g. an index of all articles, videos, etc.),
rather organize content by its subject (e.g. everything related to CI goes together)
and cross-link between any related content.
The table below shows what kind of documentation goes where.
| Directory | What belongs here |
| --------- | -------------- |
| `doc/user/` | User related documentation. Anything that can be done within the GitLab UI goes here including `/admin`. |
| `doc/administration/` | Documentation that requires the user to have access to the server where GitLab is installed. The admin settings that can be accessed via GitLab's interface go under `doc/user/admin_area/`. |
| `doc/api/` | API related documentation. |
| `doc/development/` | Documentation related to the development of GitLab. Any styleguides should go here. |
| `doc/legal/` | Legal documents about contributing to GitLab. |
| `doc/install/`| Probably the most visited directory, since `installation.md` is there. Ideally this should go under `doc/administration/`, but it's best to leave it as-is in order to avoid confusion (still debated though). |
| `doc/update/` | Same with `doc/install/`. Should be under `administration/`, but this is a well known location, better leave as-is, at least for now. |
| `doc/topics/` | Indexes per Topic (`doc/topics/topic-name/index.md`): all resources for that topic (user and admin documentation, articles, and third-party docs) |
---
**General rules:**
1. The correct naming and location of a new document, is a combination
of the relative URL of the document in question and the GitLab Map design
that is used for UX purposes ([source][graffle], [image][gitlab-map]).
1. When creating a new document and it has more than one word in its name,
make sure to use underscores instead of spaces or dashes (`-`). For example,
a proper naming would be `import_projects_from_github.md`. The same rule
applies to images.
1. Start a new directory with an `index.md` file.
1. There are four main directories, `user`, `administration`, `api` and `development`.
1. The `doc/user/` directory has five main subdirectories: `project/`, `group/`,
`profile/`, `dashboard/` and `admin_area/`.
1. `doc/user/project/` should contain all project related documentation.
1. `doc/user/group/` should contain all group related documentation.
1. `doc/user/profile/` should contain all profile related documentation.
Every page you would navigate under `/profile` should have its own document,
i.e. `account.md`, `applications.md`, `emails.md`, etc.
1. `doc/user/dashboard/` should contain all dashboard related documentation.
1. `doc/user/admin_area/` should contain all admin related documentation
describing what can be achieved by accessing GitLab's admin interface
(_not to be confused with `doc/administration` where server access is
required_).
1. Every category under `/admin/application_settings` should have its
own document located at `doc/user/admin_area/settings/`. For example,
the **Visibility and Access Controls** category should have a document
located at `doc/user/admin_area/settings/visibility_and_access_controls.md`.
1. The `doc/topics/` directory holds topic-related technical content. Create
`doc/topics/topic-name/subtopic-name/index.md` when subtopics become necessary.
General user- and admin- related documentation, should be placed accordingly.
If you are unsure where a document should live, you can ping `@axil` or `@marcia` in your
merge request.
### Changing document location
Changing a document's location is not to be taken lightly. Remember that the
documentation is available to all installations under `help/` and not only to
GitLab.com or http://docs.gitlab.com. Make sure this is discussed with the
Documentation team beforehand.
If you indeed need to change a document's location, do NOT remove the old
document, but rather replace all of its contents with a new line:
```
This document was moved to [another location](path/to/new_doc.md).
```
where `path/to/new_doc.md` is the relative path to the root directory `doc/`.
---
For example, if you were to move `doc/workflow/lfs/lfs_administration.md` to
`doc/administration/lfs.md`, then the steps would be:
1. Copy `doc/workflow/lfs/lfs_administration.md` to `doc/administration/lfs.md`
1. Replace the contents of `doc/workflow/lfs/lfs_administration.md` with:
```
This document was moved to [another location](../../administration/lfs.md).
```
1. Find and replace any occurrences of the old location with the new one.
A quick way to find them is to use `git grep`. First go to the root directory
where you cloned the `gitlab-ce` repository and then do:
### Testing ```
git grep -n "workflow/lfs/lfs_administration"
git grep -n "lfs/lfs_administration"
```
NOTE: **Note:**
If the document being moved has any Disqus comments on it, there are extra steps
to follow documented just [below](#redirections-for-pages-with-disqus-comments).
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/`).
- 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.
You may ask why the two greps. Since we use relative paths to link to
documentation, sometimes it might be useful to search a path deeper.
- The `*.md` extension is not used when a document is linked to GitLab's
built-in help page, that's why we omit it in `git grep`.
- Use the checklist on the documentation MR description template.
### Redirections for pages with Disqus comments
If the documentation page being relocated already has any Disqus comments,
we need to preserve the Disqus thread.
Disqus uses an identifier per page, and for docs.gitlab.com, the page identifier
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.
To do that, add to the frontmatter the variable `redirect_from`,
using the old URL as value. For example, let's say I moved the document
available under `https://docs.gitlab.com/my-old-location/README.html` to a new location,
`https://docs.gitlab.com/my-new-location/index.html`.
Into the **new document** frontmatter add the following:
```yaml
---
redirect_from: 'https://docs.gitlab.com/my-old-location/README.html'
---
```
Note: it is necessary to include the file name in the `redirect_from` URL,
even if it's `index.html` or `README.html`.
## Testing
We treat documentation as code, thus have implemented some testing. We treat documentation as code, thus have implemented some testing.
Currently, the following tests are in place: Currently, the following tests are in place:
...@@ -103,7 +245,7 @@ Currently, the following tests are in place: ...@@ -103,7 +245,7 @@ Currently, the following tests are in place:
Submitting an EE-equivalent merge request cherry-picking all commits from CE to EE is Submitting an EE-equivalent merge request cherry-picking all commits from CE to EE is
essential to avoid them. essential to avoid them.
### Branch naming ## Branch naming
If your contribution contains **only** documentation changes, you can speed up If your contribution contains **only** documentation changes, you can speed up
the CI process by following some branch naming conventions. You have three the CI process by following some branch naming conventions. You have three
...@@ -118,7 +260,7 @@ choices: ...@@ -118,7 +260,7 @@ choices:
If your branch name matches any of the above, it will run only the docs If your branch name matches any of the above, it will run only the docs
tests. If it doesn't, the whole test suite will run (including docs). tests. If it doesn't, the whole test suite will run (including docs).
### Merge requests for GitLab documentation ## Merge requests for GitLab documentation
Before getting started, make sure you read the introductory section Before getting started, make sure you read the introductory section
"[contributing to docs](#contributing-to-docs)" above and the "[contributing to docs](#contributing-to-docs)" above and the
...@@ -137,7 +279,7 @@ frozen or released, use the label `Pick into X.Y` to get it merged into ...@@ -137,7 +279,7 @@ frozen or released, use the label `Pick into X.Y` to get it merged into
the correct release. Avoid picking into a past release as much as you can, as the correct release. Avoid picking into a past release as much as you can, as
it increases the work of the release managers. it increases the work of the release managers.
#### Cherry-picking from CE to EE ### Cherry-picking from CE to EE
As we have the `master` branch of CE merged into EE once a day, it's common to As we have the `master` branch of CE merged into EE once a day, it's common to
run into merge conflicts. To avoid them, we [test for merge conflicts against EE](#testing) run into merge conflicts. To avoid them, we [test for merge conflicts against EE](#testing)
...@@ -161,7 +303,10 @@ a couple more commits to the EE branch, but ask the reviewer to review the EE me ...@@ -161,7 +303,10 @@ a couple more commits to the EE branch, but ask the reviewer to review the EE me
additionally to the CE MR. If there are many EE-only changes though, start a new MR additionally to the CE MR. If there are many EE-only changes though, start a new MR
to EE only. to EE only.
### Previewing the changes live ## Previewing the changes live
To preview your changes to documentation locally, please follow
this [development guide](https://gitlab.com/gitlab-com/gitlab-docs/blob/master/README.md#development).
If you want to preview the doc changes of your merge request live, you can use If you want to preview the doc changes of your merge request live, you can use
the manual `review-docs-deploy` job in your merge request. You will need at the manual `review-docs-deploy` job in your merge request. You will need at
...@@ -221,7 +366,7 @@ working on. If you don't, the remote docs branch won't be removed either, ...@@ -221,7 +366,7 @@ 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 and the server where the Review Apps are hosted will eventually be out of
disk space. disk space.
#### Technical aspects ### Technical aspects
If you want to know the hot details, here's what's really happening: If you want to know the hot details, here's what's really happening:
...@@ -256,6 +401,74 @@ The following GitLab features are used among others: ...@@ -256,6 +401,74 @@ The following GitLab features are used among others:
- [Artifacts](../ci/yaml/README.md#artifacts) - [Artifacts](../ci/yaml/README.md#artifacts)
- [Specific Runner](../ci/runners/README.md#locking-a-specific-runner-from-being-enabled-for-other-projects) - [Specific Runner](../ci/runners/README.md#locking-a-specific-runner-from-being-enabled-for-other-projects)
## GitLab `/help`
Every GitLab instance includes the documentation, which is available from `/help`
(`http://my-instance.com/help`), e.g., <https://gitlab.com/help>.
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:
```haml
= link_to 'Help page', help_page_path('user/permissions', anchor: 'anchor-link')
```
1. **Opening links in a new tab.** This should be the default behavior:
```haml
= link_to 'Help page', help_page_path('user/permissions'), target: '_blank'
```
1. **Linking to a circle icon.** Usually used in settings where a long
description cannot be used, like near checkboxes. You can basically use
any font awesome icon, but prefer the `question-circle`:
```haml
= link_to icon('question-circle'), help_page_path('user/permissions')
```
1. **Using a button link.** Useful in places where text would be out of context
with the rest of the page layout:
```haml
= link_to 'Help page', help_page_path('user/permissions'), class: 'btn btn-info'
```
1. **Using links inline of some text.**
```haml
Description to #{link_to 'Help page', help_page_path('user/permissions')}.
```
1. **Adding a period at the end of the sentence.** Useful when you don't want
the period to be part of the link:
```haml
= succeed '.' do
Learn more in the
= link_to 'Help page', help_page_path('user/permissions')
```
## General Documentation vs Technical Articles ## General Documentation vs Technical Articles
### General documentation ### General documentation
...@@ -270,7 +483,7 @@ They are topic-related documentation, written with an user-friendly approach and ...@@ -270,7 +483,7 @@ They are topic-related documentation, written with an user-friendly approach and
A technical article guides users and/or admins to achieve certain objectives (within guides and tutorials), or provide an overview of that particular topic or feature (within technical overviews). It can also describe the use, implementation, or integration of third-party tools with GitLab. A technical article guides users and/or admins to achieve certain objectives (within guides and tutorials), or provide an overview of that particular topic or feature (within technical overviews). It can also describe the use, implementation, or integration of third-party tools with GitLab.
They should be placed in a new directory named `/article-title/index.md` under a topic-related folder, and their images should be placed in `/article-title/img/`. For example, a new article on GitLab Pages should be placed in `doc/user/project/pages/article-title/` and a new article on GitLab CI/CD should be placed in `doc/ci/article-title/`. They should be placed in a new directory named `/article-title/index.md` under a topic-related folder, and their images should be placed in `/article-title/img/`. For example, a new article on GitLab Pages should be placed in `doc/user/project/pages/article-title/` and a new article on GitLab CI/CD should be placed in `doc/ci/examples/article-title/`.
#### Types of Technical Articles #### Types of Technical Articles
...@@ -324,3 +537,5 @@ date: 2017-02-01 ...@@ -324,3 +537,5 @@ date: 2017-02-01
Use the [writing method](https://about.gitlab.com/handbook/product/technical-writing/#writing-method) defined by the Technical Writing team. Use the [writing method](https://about.gitlab.com/handbook/product/technical-writing/#writing-method) defined by the Technical Writing team.
[gitlab-map]: https://gitlab.com/gitlab-org/gitlab-design/raw/master/production/resources/gitlab-map.png
[graffle]: https://gitlab.com/gitlab-org/gitlab-design/blob/d8d39f4a87b90fb9ae89ca12dc565347b4900d5e/production/resources/gitlab-map.graffle
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment