Skip to content

Commit 358a21b

Browse files
authored
Update README.md
Implemented in dart-lang/sdk#56186 Credits @srawlins
1 parent ced0209 commit 358a21b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,24 @@ dartdoc is currently documenting. This can lead to inconsistent behavior betwee
288288
packages, especially if different command lines are used for dartdoc. It is recommended to use collision-resistant
289289
naming for any macros by including the package name and/or library it is defined in within the name.
290290

291+
### Documentation imports (`/// @docImport`)
292+
293+
Libraries that are only referenced in documentation comments (`[Future]`) can be imported with a
294+
`/// @docImport '<uri>'` comment on the `library` element, like:
295+
296+
```dart
297+
/// @docImport 'dart:async';
298+
/// @docImport 'package:flutter/element.dart' show Element;
299+
/// @docImport '../path/to/somwhere.dart';
300+
/// @docImport 'dart:html' as 'html';
301+
library;
302+
303+
/// We can now reference [Future] from dart:async, [Element] from Flutter's element library,
304+
/// and [html.Element] from dart:html, even if none of these libraries are actually imported
305+
/// by this library.
306+
class Foo {}
307+
```
308+
291309
### Tools
292310

293311
Dartdoc allows you to filter parts of the documentation through an external tool

0 commit comments

Comments
 (0)