Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds support for generating API documentation links to Flutter framework types in the documentation snippet generator. The changes enable the snippet generator to create proper links to api.flutter.dev for Flutter and dart:ui types, rather than treating them like regular pub.dev packages.
Changes:
- Added Flutter package to the tracked packages list with special handling
- Modified documentation URL generation to use api.flutter.dev for Flutter and dart:ui types
- Updated tooltip generation to exclude Flutter types (since Flutter has its own comprehensive documentation)
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| docs_snippets/tool/snippet_generator/main.dart | Adds the Flutter package (using material.dart as the library entry point) to the list of tracked packages with an empty version string |
| docs_snippets/tool/snippet_generator/dart_doc_linker.dart | Adds special URL generation for dart:ui types and Flutter package types to link to api.flutter.dev instead of pub.dev, and refactors the base URL construction logic |
| docs_snippets/tool/snippet_generator/tooltip_linker.dart | Modifies the _forui method to explicitly exclude Flutter types from tooltip generation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (package == 'flutter') { | ||
| base = 'https://api.flutter.dev/flutter/${p.basenameWithoutExtension(barrel.uri.pathSegments.last)}'; |
There was a problem hiding this comment.
Accessing barrel.uri.pathSegments.last could throw a StateError if the path segments list is empty. Consider adding a check to ensure the list is not empty before accessing .last, or handle the potential exception. For example, you could check if barrel.uri.pathSegments.isNotEmpty before accessing .last.
| if (package == 'flutter') { | |
| base = 'https://api.flutter.dev/flutter/${p.basenameWithoutExtension(barrel.uri.pathSegments.last)}'; | |
| final segments = barrel.uri.pathSegments; | |
| if (package == 'flutter') { | |
| if (segments.isEmpty) { | |
| // Avoid StateError from accessing segments.last on an empty list. | |
| continue; | |
| } | |
| base = 'https://api.flutter.dev/flutter/${p.basenameWithoutExtension(segments.last)}'; |
Documentation Preview
You're seeing this because the docs/samples were updated. |
1c9628a to
4645318
Compare
Describe the changes
Checklist