-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[v6.1] Merge style guide into docs (#6571)
* docs: best practices * docs: requested changes * docs: slight rewording * docs: make changes
- Loading branch information
1 parent
f0d3067
commit a39bfef
Showing
2 changed files
with
162 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,44 @@ | ||
--- | ||
title: Docs Best Practices | ||
description: Best practices for documentation | ||
--- | ||
|
||
## Content | ||
# Documentation Best Practices | ||
|
||
**Keep it simple** | ||
This article serves to define [documentation](../docs) best practices. | ||
|
||
Read the book [On Writing Well](https://www.amazon.com/Writing-Well-Classic-Guide-Nonfiction/dp/0060891548). | ||
## Work Flow | ||
|
||
**Write for the target audience** | ||
This section describes the general workflow for writing documentation: | ||
|
||
Do not overload getting started guides with content and complex terminology, focus | ||
on benefits to the user. Do not add architecture diagrams in getting started guides. | ||
Likewise, do not do demos in architecture articles. | ||
1. Select a branch from [github.com/gravitational/teleport](https://github.com/gravitational/teleport/) corresponding to the version of the documentation/product you'd like to work on. | ||
2. Use `$ git submodule update --init --recursive` when you `git switch` to or `git checkout` a new branch. | ||
3. Make changes locally using [Next](https://github.com/gravitational/next), our primary documentation tool. | ||
4. Validate your changes locally using the provided [linters](https://github.com/gravitational/next#development-related-commands). | ||
5. Commit your changes and create a PR. | ||
6. Get approved and merge your changes in. | ||
|
||
**Keep guides self-contained** | ||
Typically if you make changes to some version `6.1`, you'll also want to port those changes to `master/main`, and any version following `6.1`. | ||
|
||
All guides should have everything that is needed for a reader | ||
to accomplish their goal. This sometimes leads to duplication. | ||
Use include directives for repeated content. Remove backslash before the exclamation marks for it to work: | ||
In other words, making changes to `6.1` usually entails making changes to `6.2` and `7.0 (master/main)`. This isn't universally the case (if some document or change is specific to a single version) but generally applies. Eventually most of this will be automated since it can be a bit cumbersome. | ||
|
||
```bash | ||
(\!CHANGELOG.md\!) | ||
``` | ||
To see the current submodule and version mappings review [the mappings](https://github.com/gravitational/next/blob/main/.gitmodules). | ||
|
||
## Tooling | ||
|
||
Filepath should be relative to the repository root folder. | ||
Our documentation is primarily built with [Next](https://github.com/gravitational/next) which has the following features: | ||
|
||
## Diagrams | ||
1. It compiles React and specifically, React within Markdown. This gives us the ability to create uniform UI/UX markers (the resuable UI/UX components React is known for) that engage and help the reader. | ||
2. Lints and checks both React and native language *within* Markdown as part of the CI/CD and PR process. | ||
3. Several pre-compilation plugins, processors, and hooks that we can extend as needed. This gives us a lot of power and flexibility to automate some of the more tedious tasks. | ||
|
||
Use [Teleport's lucidchart library](https://app.lucidchart.com/lucidchart/dfcf1f4a-5cf0-4758-8ebb-f6ea86900aba/edit) | ||
to create diagrams with a consistent design language. | ||
**Diagrams:** | ||
|
||
## Videos | ||
- Use [Teleport's lucidchart library](https://app.lucidchart.com/lucidchart/dfcf1f4a-5cf0-4758-8ebb-f6ea86900aba/edit) to create diagrams with a consistent design language. | ||
|
||
Mac users should use Quicktime's `Cmd-Shift-5` to record a small part of the screen: | ||
**Videos:** | ||
|
||
- Mac users should use Quicktime's `Cmd-Shift-5` to record a small part of the screen: | ||
|
||
 | ||
|
||
|
@@ -70,26 +75,69 @@ Your browser does not support the video tag. | |
</video> | ||
``` | ||
|
||
## Custom syntax used in the docs | ||
## Style guide | ||
|
||
Some standards are presently codified in the [Next](https://github.com/gravitational/next) repository by way of MDX linters. Make sure to use these. | ||
|
||
The following standards are already in use. Please follow them (although these are non-blocking, do read the comments below): | ||
|
||
1. `tsh`, `tctl`, and other core commands should be placed in tic marks. | ||
2. All ports or values should be enclosed in tic marks `443`. | ||
3. Footnotes should be ordered by appearance (chronological precedence). `2` should not come before `1`. | ||
4. Tend to write sparser one to two-sentence groupings rather than lengthier text block paragraphs. | ||
5. Use periods at the end of a line even in a list. | ||
6. Use lists aggressively. | ||
|
||
The rest are subject to final approval by the developer relations team. In general, it's still a good idea to adopt some of these when writing your next article: | ||
|
||
1. Consistent header casing (`I am an example header`, `I Am another Example header`, `I am a Third header`). | ||
2. Consistent acronyms and concept keyword use (`2-factor`, `two-factor`, `2fa`, `tfa`). | ||
3. We should avoid using scare-quotes `""` to refer to a sub-service/proper noun - these often have negative connotations associated with them. E.g. - "Trusted Cluster" vs *Trusted Cluster*. Use italics for concept keywords and tic marks for values. (Clarification: it's harmless to use quotes to approximate or indicate something but not to name or refer to a proper noun. It can be quite conversational and friendly in those other contexts.) | ||
4. Consistent use of contractions - many teams tend to favor an all or nothing approach here. Contractions keep the language sparse, concise, and conversational. For more formal language, we'd probably want to avoid them. | ||
5. Use numbered lists for any sequence of steps. | ||
6. Product proper nouns should be capitalized. `trusted cluster` -> `Trusted Cluster` | ||
7. Product proper nouns should be bolded. `Trusted Cluster` -> **Trusted Cluster** | ||
8. Acronyms should always be introduced following a concept keyword and then consistently used thereafter (no concept keyword used) in an article (saves space, typing, and reading - gaurantees the shorthanded term is available). | ||
|
||
**Pros:** | ||
|
||
- These are relatively minor improvements overall but help to set more uniform documentation standards. | ||
- Stylistically, this helps to ensure more more professional, neat, and tidy docs. | ||
- Helps set clear, baseline, guidelines we can expand as documentation needs expand. We can apply these uniformly for blogs, docs, etc. | ||
- May assist with any future localization efforts since setting a config file for a language is easier when words are one-to-one. | ||
- Assists with improving searches by content or keyword. | ||
- Acronyms are occasionally (but only very rarely) associated with multiple concepts. This reduces some potential ambiguities. (Especially for concepts that exist in a complex and particularly acronym-prone space.) | ||
- These are often helpful for new hires since they can simultaneously be reading and learning the material while performing basic editing. | ||
- Consistent and helpful styling has an impact on customer satisfaction. Small stylistic changes can improve the efficacy of docs. It's a lot easier to find that *one, crucial, config value* if it's bolded or highlighted. | ||
|
||
### Varibles | ||
## Testing | ||
|
||
To prevent updating links and code examples after each release, we can replace them with | ||
variables. This way, it will be enough to update them in one place. | ||
1. Make sure to manually test commands and steps. | ||
2. Make sure to run linting on your docs. | ||
|
||
Variables are stored in the `docs/config.json` file under the key `variables`. | ||
Variables can be nested inside the config. | ||
## MDX and UI/UX components | ||
|
||
To insert variabe to the page use `(\= path.to.variable \=)` syntax | ||
(remove backslashes in actual code). | ||
Next uses Markdown with React (hence, the `.mdx` filename suffix). | ||
|
||
Variables will be linted on CI. If the variable didn't exist in the config, it would cause an error. | ||
- MDX supports powerful templating features like variable interpolation. | ||
- This section briefly describes some of the features that're most relevant when writing documentation. | ||
|
||
### Variables, templating, and interpolation | ||
|
||
Many documentation teams struggle with maintaining the vast number of articles and resources that are eventually created and consumed. Links and images have to be rechecked for accuracy/relevance. | ||
|
||
To ease this burden, we can replace links and code examples with *variables* so we don't have to constantly update everything after each release. | ||
|
||
- Variables are stored in the `docs/config.json` file under the key `variables`. | ||
- Variables can be nested inside the config. | ||
- To insert variabe to the page use `(\= path.to.variable \=)` syntax (remove backslashes in actual code). | ||
- Variables will be linted when a PR is created as part of our CI/CD process. If the variable didn't exist in the config, it would throw an error which you must remedy in order to merge. | ||
|
||
### Includes | ||
|
||
To prevent content duplication, it may be useful to include code examples or other | ||
MDX files inside the current page. To do it use `(\! path-to-file.mdx \!)` syntax (remove | ||
backslashes in actual code). | ||
To prevent content duplication, it's very useful to include code examples or other MDX files inside the current page (akin to API or code-reuse). This allows documentation to reduce maintenance overhead and focus on writing new articles. | ||
|
||
Use `(\! path-to-file.mdx \!)` syntax (remove backslashes in actual code). | ||
|
||
Paths are resolved from the root of the repository. | ||
|
||
|
@@ -105,7 +153,7 @@ Includes will only work in these two cases: | |
Some other text. | ||
``` | ||
|
||
If the include is an `mdx` file, it will be parsed and rendered as a markdown. In other cases | ||
If the include is an `mdx` file, it will be parsed and rendered as a markdown. In other cases | ||
it will be included as-is. | ||
|
||
2. Include inside the code blocks. E. g.: | ||
|
@@ -121,26 +169,28 @@ Includes will only work in these two cases: | |
|
||
These will be inserted as-is, even in the case of the `mdx` files. | ||
|
||
Includes in any other places will not be resolved and will be left as is. | ||
|
||
Includes will be linted on CI. If the file didn't exist in the repository, | ||
it would cause an error. Wrong placement of includes will also cause errors. | ||
- Includes in any other places will not be resolved and will be left as is. | ||
- Includes will be linted when a PR is created as part of our CI/CD process. | ||
- If the file didn't exist in the repository, it will throw an error. Wrong placement of includes will also throw errors. | ||
|
||
### Image pixel density marker | ||
|
||
The browser can't distinguish between retina-ready and not retina-ready images. | ||
Because of this, screenshots made on the retina screens may look large on the page. | ||
|
||
To hint to the browser that the images are meant for retina display, we can add | ||
the suffix `@Nx` to the image's file name. For example, screenshots made on macOS | ||
should have the suffix `[email protected]`. It will tell the browser to scale images | ||
down twice to show them in their actual size. Different OSes may require different | ||
suffixes based on which logical and physical resolutions their screens have. | ||
- The browser can't distinguish between retina-ready and not retina-ready images. | ||
- Because of this, screenshots made on the retina screens may look large on the page. | ||
- To hint to the browser that the images are meant for retina display, we can add | ||
the suffix `@Nx` to the image's file name. For example, screenshots made on macOS | ||
should have the suffix `[email protected]`. | ||
- It will tell the browser to scale images | ||
down twice to show them in their actual size. | ||
- Different Operating Systems may require different suffixes based on which logical and physical resolutions their screens have. | ||
|
||
### Admonitons | ||
|
||
<Admonition title="Admontion title" type="tip"> | ||
Admontion content. | ||
<Admonition | ||
title="Admontion title" | ||
type="tip" | ||
> | ||
Admontion content. | ||
</Admonition> | ||
|
||
If you want to add admonition like the one above to the page use this syntax: | ||
|
@@ -151,7 +201,7 @@ If you want to add admonition like the one above to the page use this syntax: | |
</Admonition> | ||
``` | ||
|
||
`type` can be one of the following values: `warning`, `tip`, `note`, `danger`. | ||
`type` can be one of the following values: `warning`, `tip`, `note`, `danger`. | ||
Different types will result in different colors for the header. Omitting the type | ||
or using some other value will result in resetting it to the `tip`. | ||
|
||
|
@@ -163,6 +213,7 @@ If `title` is omitted, `type` will be used instead as the title value. | |
<TabItem label="First label"> | ||
First tab. | ||
</TabItem> | ||
|
||
<TabItem label="Second label"> | ||
Second tab. | ||
</TabItem> | ||
|