writing_documentation.md 10,5 КБ
Newer Older
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
1
# Writing documentation
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
2
3

  - **General Documentation**: written by the developers responsible by creating features. 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.
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
4
  - **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/).
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
5
  - **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).
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
6

Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
7
## Distinction between General Documentation and Technical Articles
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
8

Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
9
### General documentation
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
10
11
12
13
14
15
16

General documentation is categorized by _User_, _Admin_, and _Contributor_, and describe what that feature is, what it does, and its available settings.

### Technical Articles

Technical articles replace technical content that once lived in the [GitLab Blog](https://about.gitlab.com/blog/), where they got out-of-date and weren't easily found.

Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
17
They are topic-related documentation, written with an user-friendly approach and language, aiming to provide the community with guidance on specific processes to achieve certain objectives.
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
18
19
20

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.

Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
21
They live under `doc/articles/article-title/index.md`, and their images should be placed under `doc/articles/article-title/img/`. Find a list of existing [technical articles](../articles/index.md) here.
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
22
23
24
25
26
27
28
29

#### Types of Technical Articles

- **User guides**: technical content to guide regular users from point A to point B
- **Admin guides**: technical content to guide administrators of GitLab instances from point A to point B
- **Technical Overviews**: technical content describing features, solutions, and third-party integrations
- **Tutorials**: technical content provided step-by-step on how to do things, or how to reach very specific objectives

Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
30
#### Understanding guides, tutorials, and technical overviews
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
31

Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
32
Suppose there's a process to go from point A to point B in 5 steps: `(A) 1 > 2 > 3 > 4 > 5 (B)`.
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
33

Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
34
A **guide** can be understood as a description of certain processes to achieve a particular objective. A guide brings you from A to B describing the characteristics of that process, but not necessarily going over each step. It can mention, for example, steps 2 and 3, but does not necessarily explain how to accomplish them.
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
35

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
36
- Live example: "GitLab Pages from A to Z - [Part 1](../user/project/pages/getting_started_part_one.md) to [Part 4](../user/project/pages/getting_started_part_four.md)"
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
37

Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
38
39
A **tutorial** requires a clear **step-by-step** guidance to achieve a singular objective. It brings you from A to B, describing precisely all the necessary steps involved in that process, showing each of the 5 steps to go from A to B.
It does not only describes steps 2 and 3, but also shows you how to accomplish them.
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
40

Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
41
42
- Live example (on the blog): [Hosting on GitLab.com with GitLab Pages](https://about.gitlab.com/2016/04/07/gitlab-pages-setup/)

Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
43
A **technical overview** is a description of what a certain feature is, and what it does, but does not walk
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
44
45
46
47
through the process of how to use it systematically.

- Live example (on the blog): [GitLab Workflow, an overview](https://about.gitlab.com/2016/10/25/gitlab-workflow-an-overview/)

Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
48
#### Special format
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
49

Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
50
Every **Technical Article** contains, in the very beginning, a blockquote with the following information:
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
51
52
53
54

- A reference to the **type of article** (user guide, admin guide, tech overview, tutorial)
- A reference to the **knowledge level** expected from the reader to be able to follow through (beginner, intermediate, advanced)
- A reference to the **author's name** and **GitLab.com handle**
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
55
- A reference of the **publication date**
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
56
57

```md
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
58
> **Article [Type](../../development/writing_documentation.html#types-of-technical-articles):** tutorial ||
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
59
> **Level:** intermediary ||
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
60
61
> **Author:** [Name Surname](https://gitlab.com/username) ||
> **Publication date:** AAAA/MM/DD
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
62
63
```

Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
64
#### Technical Articles - Writing Method
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
65

Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
66
Use the [writing method](https://about.gitlab.com/handbook/product/technical-writing/#writing-method) defined by the Technical Writing team.
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
67

Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
68
## Documentation style guidelines
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
69

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
70
All the docs follow the same [styleguide](doc_styleguide.md).
Marcia Ramos's avatar
Marcia Ramos включено в состав коммита
71
72
73

### Markdown

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
74
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.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
75
76
77
78
79
80

## Testing

We try to treat documentation as code, thus have implemented some testing.
Currently, the following tests are in place:

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
81
82
1. `docs lint`: Check that all internal (relative) links work correctly and
   that all cURL examples in API docs use the full switches.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
83
84

If your contribution contains **only** documentation changes, you can speed up
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
85
86
87
88
89
90
91
92
93
94
95
the CI process by following some branch naming conventions. You have three
choices:

| 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` |

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).
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
96
97
98
99
100
101
102
103
104
105

---

When you submit a merge request to GitLab Community Edition (CE), there is an
additional job called `rake ee_compat_check` that runs against Enterprise
Edition (EE) and checks if your changes can apply cleanly to the EE codebase.
If that job fails, read the instructions in the job log for what to do next.
Contributors do not need to submit their changes to EE, GitLab Inc. employees
on the other hand need to make sure that their changes apply cleanly to both
CE and EE.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
106
107
108

## Previewing the changes live

Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
109
110
111
112
113
114
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.

TIP: **Tip:**
If your branch contains only documentation changes, you can use
[special branch names](#testing) to avoid long running pipelines.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
115
116
117
118
119
120

![Manual trigger a docs build](img/manual_build_docs.png)

This job will:

1. Create a new branch in the [gitlab-docs](https://gitlab.com/gitlab-com/gitlab-docs)
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
   project named after the scheme: `preview-<branch-slug>`
1. Trigger a cross project pipeline and build the docs site with your changes

After a few minutes, the Review App will be deployed and you will be able to
preview the changes. The docs URL can be found in two places:

- In the merge request widget
- In the output of the `review-docs-deploy` job, which also includes the
  triggered pipeline so that you can investigate whether something went wrong

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. It can happen that if the
   branch name slug is longer than 35 characters, it is automatically
   truncated. That means that the merge request widget will not show the proper
   URL due to a limitation of how `environment: url` works, but you can find the
   real URL from the output of the `review-docs-deploy` job.
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.

TIP: **Tip:**
Someone that has no merge rights to the CE/EE projects (think of forks from
contributors) will not be able to run the manual job. In that case, you can
ask someone from the GitLab team who has the permissions to do that for you.

NOTE: **Note:**
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
151
152
153
154
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.
Achilleas Pipinellis's avatar
Achilleas Pipinellis включено в состав коммита
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189

### Behind the scenes

If you want to know the hot details, here's what's really happening:

1. You manually run the `review-docs-deploy` job in a CE/EE merge request.
1. The job runs the [`scirpts/trigger-build-docs`](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/scripts/trigger-build-docs)
   script with the `deploy` flag, which in turn:
   1. Takes your branch name and applies the following:
      - The slug of the branch name is used to avoid special characters since
        ultimately this will be used by NGINX.
      - The `preview-` prefix is added to avoid conflicts if there's a remote branch
        with the same name that you created in the merge request.
      - The final branch name is truncated to 42 characters to avoid filesystem
        limitations with long branch names (> 63 chars).
   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
   [skips the test jobs](https://gitlab.com/gitlab-com/gitlab-docs/blob/8d5d5c750c602a835614b02f9db42ead1c4b2f5e/.gitlab-ci.yml#L50-55)
   to lower the build time.
1. Once the docs site is built, the HTML files are uploaded as artifacts.
1. A specific Runner tied only to the docs project, runs the Review App job
   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:

- [Manual actions](../ci/yaml/README.md#manual-actions)
- [Multi project pipelines](https://docs.gitlab.com/ee/ci/multi_project_pipeline_graphs.html)
- [Review Apps](../ci/review_apps/index.md)
- [Artifacts](../ci/yaml/README.md#artifacts)
- [Specific Runner](../ci/runners/README.md#locking-a-specific-runner-from-being-enabled-for-other-projects)