Skip to content

Commit 3fd9215

Browse files
committed
Update README.md
1 parent af62757 commit 3fd9215

File tree

1 file changed

+56
-2
lines changed

1 file changed

+56
-2
lines changed

README.md

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,15 +221,15 @@ You can specify links to videos inline that will be handled with a simple HTML5
221221
You can specify "macros", i.e. reusable pieces of documentation. For that, first specify a template
222222
anywhere in the comments, like:
223223

224-
```
224+
```dart
225225
/// {@template template_name}
226226
/// Some shared docs
227227
/// {@endtemplate}
228228
```
229229

230230
and then you can insert it via `{@macro template_name}`, like
231231

232-
```
232+
```dart
233233
/// Some comment
234234
/// {@macro template_name}
235235
/// More comments
@@ -240,6 +240,60 @@ dartdoc is currently documenting. This can lead to inconsistent behavior betwee
240240
packages, especially if different command lines are used for dartdoc. It is recommended to use collision-resistant
241241
naming for any macros by including the package name and/or library it is defined in within the name.
242242

243+
### Tools
244+
245+
Dartdoc allows you to filter parts of the documentation through an external tool
246+
and then include the output of that tool in place of the given input.
247+
248+
First, you have to configure the tools that will be used in the `dartdoc_options.yaml` file:
249+
250+
```yaml
251+
dartdoc:
252+
tools:
253+
drill:
254+
command: ["bin/drill.dart"]
255+
description: "Puts holes in things."
256+
echo:
257+
macos: ['/bin/sh', '-c', 'echo']
258+
linux: ['/bin/sh', '-c', 'echo']
259+
windows: ['C:\\Windows\\System32\\cmd.exe', '/c', 'echo']
260+
description: 'Works on everything'
261+
```
262+
263+
The `command` tag is used to describe the command executable, and any options
264+
that are common among all executions. If the first element of this list is a
265+
filename that ends in `.dart`, then the dart executable will automatically be
266+
used to invoke that script. The `command` defined will be run on all platforms.
267+
268+
The `macos`, `linux`, and `windows` tags are used to describe the commands to
269+
be run on each of those platforms.
270+
271+
The `description` is just a short description of the tool for use as help text.
272+
273+
Only tools which are configured in the `dartdoc_options.yaml` file are able to
274+
be invoked.
275+
276+
To use the tools in comment documentation, use the `{@tool <name> [<options> ...] [$INPUT]}`
277+
directive to invoke the tool:
278+
279+
```dart
280+
/// {@tool drill --flag --option="value" $INPUT}
281+
/// This is the text that will be sent to the tool as input.
282+
/// {@end-tool}
283+
```
284+
285+
The `$INPUT` argument is a special token that will be replaced with the name of
286+
a temporary file that the tool needs to read from. It can appear anywhere in the
287+
options, and can appear multiple times.
288+
289+
If the example `drill` tool with those options is a tool that turns the content
290+
of its input file into a code-font heading, then the directive above would be
291+
the equivalent of having the following comment in the code:
292+
293+
```dart
294+
/// # `This is the text that will be sent to the tool as input.`
295+
```
296+
243297
### Auto including dependencies
244298

245299
If `--auto-include-dependencies` flag is provided, dartdoc tries to automatically add

0 commit comments

Comments
 (0)