@@ -221,15 +221,15 @@ You can specify links to videos inline that will be handled with a simple HTML5
221
221
You can specify "macros", i.e. reusable pieces of documentation. For that, first specify a template
222
222
anywhere in the comments, like :
223
223
224
- ` ` `
224
+ ` ` ` dart
225
225
/// {@template template_name}
226
226
/// Some shared docs
227
227
/// {@endtemplate}
228
228
` ` `
229
229
230
230
and then you can insert it via `{@macro template_name}`, like
231
231
232
- ```
232
+ ` ` ` dart
233
233
/// Some comment
234
234
/// {@macro template_name}
235
235
/// More comments
@@ -240,6 +240,60 @@ dartdoc is currently documenting. This can lead to inconsistent behavior betwee
240
240
packages, especially if different command lines are used for dartdoc. It is recommended to use collision-resistant
241
241
naming for any macros by including the package name and/or library it is defined in within the name.
242
242
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
+
243
297
### Auto including dependencies
244
298
245
299
If ` --auto-include-dependencies ` flag is provided, dartdoc tries to automatically add
0 commit comments