Skip to content

Make check_code_samples.dart‎ support the standard example directives, and migrate some @tool directives - #189670

Merged
auto-submit[bot] merged 15 commits into
flutter:masterfrom
dkwingsmt:migrate-affected-templates
Sep 24, 2026
Merged

auto-submit[bot] merged 15 commits into
flutter:masterfrom
dkwingsmt:migrate-affected-templates

Conversation

@dkwingsmt

@dkwingsmt dkwingsmt commented Jul 17, 2026 •

Copy link
Copy Markdown
Contributor

This PR consists of two parts of changes.

Migrate some @tool directives

As part of #189629, this PR migrates specific templates used by the material_ui and cupertino_ui packages from {@tool} directives to standard dartdoc to ensure they render correctly within these packages. This migration is limited to only these essential {@tool} instances, as Dartdoc does not currently provide native support for Dartpad.

Note that Dartpad notices ("To see it in action, copy and run this code snippet on Dartpad") are expanded, unlike in flutter/packages#12120 where they're macros. This is necessary because Dartdoc can't correctly handle nested templates and macros, preventing inner macros from expanding correctly.

This PR will be followed by reverting flutter/packages#12271, which constitutes the final step of #189629. I have verified that the package docs will render correctly after the revert.

Make check_code_samples.dart‎ support the standard example directives

Since the examples now consist of two styles, the legacy style "See code in" and the standard style @example,
check_code_samples.dart‎ needs to be updated to recognize the standard @example directives so that it won't incorrectly report that these examples files are not used by any docs.

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

@github-actions github-actions Bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. f: scrolling Viewports, list views, slivers, etc. d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: focus Focus traversal, gaining or losing focus labels Jul 17, 2026
@dkwingsmt
dkwingsmt marked this pull request as ready for review August 13, 2026 20:02
@dkwingsmt dkwingsmt added the CICD Run CI/CD label Aug 13, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the dartdoc version in dev/bots/docs.sh and replaces {@tool dartpad} directives with tags and {@example} references across several widget files, adding region tags to the corresponding API examples. The review feedback points out that using double-slash '//' comments for TODOs inside documentation blocks breaks the contiguous doc comments in Dart, and recommends replacing them with triple-slash '///' comments to ensure the API documentation is generated correctly.

Comment thread packages/flutter/lib/src/widgets/autocomplete.dart
Comment thread packages/flutter/lib/src/widgets/editable_text.dart
Comment thread packages/flutter/lib/src/widgets/editable_text.dart
Comment thread packages/flutter/lib/src/widgets/editable_text.dart
Comment thread packages/flutter/lib/src/widgets/editable_text.dart
Comment thread packages/flutter/lib/src/widgets/scrollbar.dart
Comment thread packages/flutter/lib/src/widgets/scrollbar.dart
Comment thread packages/flutter/lib/src/widgets/scrollbar.dart
Comment thread packages/flutter/lib/src/widgets/scrollbar.dart
Comment thread packages/flutter/lib/src/widgets/scrollbar.dart
@dkwingsmt

Copy link
Copy Markdown
Contributor Author

The analyzer still complains "doc_directive_unknown: Doc directive 'example' is unknown. - 237:9".

dart-lang/sdk@7c1ca3f may solve this, or we might need dart-lang/sdk#63646. Anyhow, let's wait until the analyzer fix is rolled into Flutter before landing this.

@dkwingsmt dkwingsmt changed the title Migrate templates with @tool and used by material_ui or cupertino_ui Make check_code_samples.dart‎ support the standard example directives, and migrate some @tool directives Aug 25, 2026
@dkwingsmt
dkwingsmt marked this pull request as ready for review August 25, 2026 21:33
@dkwingsmt
dkwingsmt requested a review from justinmc August 25, 2026 21:33

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request transitions API documentation examples from the legacy {@tool dartpad} format to the standard {@example} directive format wrapped in <callout-box> tags. It updates check_code_samples.dart and its tests to support and validate both legacy and standard style links, and updates the dartdoc version in docs.sh. The review feedback recommends replacing // comments with /// inside doc comment blocks to prevent block termination, improving the standardMalformedLinkRe regex to catch missing closing braces, and removing a misleading r prefix from the malformed link error message and its tests.

Comment thread packages/flutter/lib/src/widgets/autocomplete.dart
Comment thread packages/flutter/lib/src/widgets/scroll_view.dart
Comment thread packages/flutter/lib/src/widgets/scrollbar.dart
Comment thread dev/bots/check_code_samples.dart Outdated
Comment thread dev/bots/check_code_samples.dart Outdated
Comment thread dev/bots/test/check_code_samples_test.dart Outdated
@dkwingsmt dkwingsmt removed a: text input Entering text in a text field or keyboard related problems f: scrolling Viewports, list views, slivers, etc. f: focus Focus traversal, gaining or losing focus labels Aug 26, 2026
@github-actions github-actions Bot added a: text input Entering text in a text field or keyboard related problems f: scrolling Viewports, list views, slivers, etc. f: focus Focus traversal, gaining or losing focus labels Aug 31, 2026
justinmc
justinmc previously approved these changes Sep 3, 2026

@justinmc justinmc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 . Sorry for the delay, I had an old review here that I realized I never submitted.

Comment on lines +33 to +36
String? alternateLink,
required bool useStandardStyle,
// "region" is the "#body" segment at the end of standard style links.
String? region,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Move useStandardStyle up so that the required parameters are together?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread dev/bots/test/check_code_samples_test.dart Outdated

@justinmc justinmc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: text input Entering text in a text field or keyboard related problems CICD Run CI/CD d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: focus Focus traversal, gaining or losing focus f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants