This document gives writing style guidance for Fuchsia.dev, and these guidelines build on the general guidance in the Google Developers Style Guide.
Note: This guide highlights some of the best practices for writing documentation for Fuchsia. Some of the topics may be covered more extensively in the resources in the following documents:
In the Fuchsia project, the maximum line length for documentation and code is 100 characters.
Use {:.external}
to mark any links that are not within fuchsia.dev
, fuchsia.googlesource.com
, or fuchsia-review.googlesource.com
:
This is an [external](http://example.com){:.external} link.
Notice the external link icon: This is an external{:.external} link.
In general, Fuchsia recommends using reference-style links in Markdown files. Reference style links use a reference identifier associated with the link, and then refers to that identifier whenever you use the link in the doc. This makes links easy to update in the document.
Recommended: Create an identifer where you want the link.
In this example, the link identifier is called fuchsia-home
:
Welcome to the [Fuchsia home page][fuchsia-home].
And then define it at the bottom of the document:
Not recommended: Writing an in-line link like the following:
Welcome to the [Fuchsia home page](www.fuchsia.dev).
You can read more about reference style links in the external Markdown Guide.
In the Fuchsia documentation you can link to three types of contents:
/docs/
- Link to documents that are in the /docs/
directory of the Fuchsia source tree. These links must link to a file with an .md
extension. For example, /docs/concepts/README.md
./src/sys/sysmgr/main.cc
.https://fuchsia.dev/reference/fidl/fuchsia.io
./docs/reference/
and are published in the https://fuchsia.dev/fuchsia-src/reference/
section. These links must link to a file with an .md
extension. For example, /docs/reference/syscalls/bti_create.md
.Once you have created a valid markdown document, you should run doc-checker
to ensure that your document uses valid links. When you try to submit a change that includes a .md
file, Gerrit runs doc-checker
and blocks submission if you have broken links.
To run doc-checker
locally, use the fx format-code
tool:
fx format code
Recommended: Using sentence case.
# This title is an example of sentence case
Not recommended: Using title case:
# This Title is an Example of Title Case
By default, fuchsia.dev
creates anchors using underscores (_
) in place of spaces. When referencing a section in a page, create a custom anchor using dashes (-
) instead, using {#section-title}
. Also, use dashes for file names.
Recommended: Using dashes for anchors
## This is a section header {#this-is-a-section-header}
Recommended: Allow readers to easily copy the content in a code block by adding posix-terminal
after ``` for a shell command.
This code block is rendered with $
in the front of the command:
fx ota
Not recommended: Don't hardcode a $
character in the command.
$ fx ota
Recommended: Add none {:.devsite-disable-click-to-copy}
after ``` for code or output examples that do not require readers to copy the content.
This code block is rendered without the copy icon in the top right corner:
$ my_command It won't be necessary to copy and paste this code block.
Not recommended: Enable the copy feature for view-only content. If you don't specify anything after ```, the copy feature is enabled by default.
This code block is rendered as below:
$ my_command It won't be necessary to copy and paste this code block.
Recommended: Any links that refer to source code should be referred to by path only. You will get a static error check otherwise.