Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document @docImport in README.md #3935

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,24 @@ dartdoc is currently documenting. This can lead to inconsistent behavior betwee
packages, especially if different command lines are used for dartdoc. It is recommended to use collision-resistant
naming for any macros by including the package name and/or library it is defined in within the name.

### Documentation imports (`/// @docImport`)

Libraries that are only referenced in documentation comments (`[Future]`) can be imported with a
`/// @docImport '<uri>'` comment on the `library` element, like:

```dart
/// @docImport 'dart:async';
/// @docImport 'package:flutter/element.dart' show Element;
/// @docImport '../path/to/somwhere.dart';
/// @docImport 'dart:html' as 'html';
library;

/// We can now reference [Future] from dart:async, [Element] from Flutter's element library,
/// and [html.Element] from dart:html, even if none of these libraries are actually imported
/// by this library.
class Foo {}
```

### Tools

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