-
Notifications
You must be signed in to change notification settings - Fork 733
Documentation guide
This is a work in progress.
Follow the Google Developer Documentation Style Guide.
You can use the following variables in the Dart documentation.
Variable | Result |
---|---|
{{site.dart_api}} |
https://api.dartlang.org |
{{site.data.pkg-vers.SDK.channel}} |
stable or dev
|
{{site.repo.dart.sdk}} |
https://api.dart.dev |
{{site.dart-api}} |
https://api.dart.dev |
See Semantic line breaks (<=80 chars).
The default way to add an image is to use an image tag. For example:

For additional ways to serve images, see Images
See URLs
If you need to add an anchor to a page, but not attach it to a heading use this format:
<a id="control-flow-operators" aria-hidden="true"></a>
Every time you change a heading, the link for that heading changes. This means that you need to go through all of the Dart docs and update the links to point to the renamed section and also add a redirect to the new link. To avoid this, you can add a static link to a heading that never changes:
## How to complete a long task {: #long-task }
To hide a heading from the TOC, use this format:
## My heading {: .no_toc}
---
title: Dart SDK Archive
description: Download a specific version of the Dart SDK.
---
There are more fields that you can add. For details, see Top matter (YAML)
:::note
Note text goes here.
:::
See Asides (notes, tips, warnings, ...)
:::tip
Tip text goes here.
:::
See Asides (notes, tips, warnings, ...)
:::warning
Warning text goes here.
:::
See Asides (notes, tips, warnings, ...)
{% tabs "device-type-tabs" %}
{% tab "Android" %}
Android content here.
{% endtab %}
{% tab "iOS" %}
iOS content here.
{% endtab %}
{% endtabs %}
Most code samples in the docs need to be generated from code excerpts. If you see a tag that looks like the following in the docs, the code sample is being generated from a code excerpt:
<?code-excerpt "examples/main.dart (optional-region-name)" arg0="value0" ...?>
```dart
void main() {}
```
Don't attempt to change the code sample directly in the Markdown file. If you do, your PR will fail when you try and post it for review.
- Create a source file (or use an existing one) for your code sample.
- Define the excerpt region. For detailed instructions, see Defining excerpt regions.
- Use injection instructions to inject the code sample from a source file into your desired Markdown file. See Inject instructions.
- Immediately after the injection instructions, you must denote an empty Markdown code block with the language of the code sample.
```dart
```
- Run the
refresh-excerpts
command in your terminal.
dart run dash_site refresh-excerpts
You must run this same command any time you make updates to your source code sample to ensure your documentation remains current.
```kotlin title="MainActivity.kt"
put code here
```
To highlight specific lines in a code sample:
- On the same line as the opening backticks for the code block, insert the argument
highlightLines=
. - Count the line numbers within the code block itself, not based on the surrounding file.
- List the line numbers you want to highlight, separated by commas. Use a hyphen (-) to indicate a line range. Do not include spaces between commas or hyphens.
```yaml highlightLines=1,4-5
dependencies:
kittens:
git:
url: [email protected]:munificent/kittens.git
tag_pattern: v{{version}} # Find version-tag prefixed by 'v'.
version: ^2.0.1
```
Code results should be styled with the plaintext
keyword.
```plaintext
i = 1, j = 1
i = 1, j = 2
i = 1, j = 3
i = 2, j = 1
i = 2, j = 2
outerLoop exited
```
```dart tag=fails-sa
// put failing code here
```
If you are using code excerpts to generate code samples and you want to suppress an intended error or warning, you can add a comment in your code excerpt for this. To learn more, see https://dart.dev/tools/analysis
Look at this PR: https://github.com/dart-lang/site-www/pull/6576
To run tests against the beta branch of Dart, use the following command to switch to the beta branch:
flutter channel beta && flutter upgrade
To run tests against the stable branch of Dart, use the following command to switch to the stable branch:
flutter channel stable && flutter upgrade
Some parts of the documentation are created in source files elsewhere and need to be generated for the Dart documentation.
Update the linter rules here: https://dart.dev/tools/linter-rules
dart run dash_site generate-lints
Update diagnostic messages here: https://dart.dev/tools/diagnostics
dart run dash_site generate-diagnostics
The macOS versions listed on the Get the Dart SDK page are sourced from the macOS json file. To add a new macOS version or update an existing one, you must modify this file. When adding a new macOS version, create an entry on the top of the json list.
A technical writer should review diagnostic messages that go into the Dart or Dart package codebase. Messages are usually stored in messages.yaml
files.
A technical writer should review changelogs as needed. The changelog is usually the CHANGELOG.md
file and should follow the Google Developer Documentation Style Guide.
Terms and definitions should follow this formatting style:
Term a
: Definition a.
Term b
: Definition b.
Example: https://dart.dev/tools/dart-compile#prod-compile-options