Skip to content

Commit bd5d191

Browse files
authored
[flutter_plugin_tools] Reimplements the excerpt system inline in the tool, rather than relying on a separate package. (#4417)
* Allows excerpts to come from any package, not just examples. * Fixes a bug in the excerpting logic that was causing a stray `}` to appear in one example. * Removes the need for `build.excerpt.yaml` files. * Remove the dependency on build_runner for excerpts. * Reduces the time to generate the excerpts from about 10 minutes to about 5 seconds. * Almost certainly fixes flutter/flutter#107180 (untested). The new logic is not quite backwards compatible; the `path-base` feature now specifies a real path to the actual source directories, rather than a path into the invisible generated `excerpts/` directory with its special structure. Also, a number of features from the previous package that were not actually used in this repository are no longer supported (such as having multiple section names per `#docregion` pragma).
1 parent e479ca5 commit bd5d191

File tree

45 files changed

+747
-1078
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+747
-1078
lines changed

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

packages/camera/camera/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Camera Plugin
22

3-
<?code-excerpt path-base="excerpts/packages/camera_example"?>
3+
<?code-excerpt path-base="example/lib"?>
44

55
[![pub package](https://img.shields.io/pub/v/camera.svg)](https://pub.dev/packages/camera)
66

packages/camera/camera/example/build.excerpt.yaml

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/file_selector/file_selector/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# file_selector
22

3-
<?code-excerpt path-base="excerpts/packages/file_selector_example"?>
3+
<?code-excerpt path-base="example/lib"?>
44

55
[![pub package](https://img.shields.io/pub/v/file_selector.svg)](https://pub.dartlang.org/packages/file_selector)
66

@@ -36,7 +36,7 @@ Please also take a look at our [example][example] app.
3636
#### Open a single file
3737

3838
<?code-excerpt "open_image_page.dart (SingleOpen)"?>
39-
``` dart
39+
```dart
4040
const XTypeGroup typeGroup = XTypeGroup(
4141
label: 'images',
4242
extensions: <String>['jpg', 'png'],
@@ -48,7 +48,7 @@ final XFile? file =
4848
#### Open multiple files at once
4949

5050
<?code-excerpt "open_multiple_images_page.dart (MultiOpen)"?>
51-
``` dart
51+
```dart
5252
const XTypeGroup jpgsTypeGroup = XTypeGroup(
5353
label: 'JPEGs',
5454
extensions: <String>['jpg', 'jpeg'],

packages/file_selector/file_selector/example/build.excerpt.yaml

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/flutter_adaptive_scaffold/README.md

Lines changed: 66 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?code-excerpt path-base="excerpts/packages/flutter_adaptive_scaffold_example"?>
1+
<?code-excerpt path-base="example/lib"?>
22

33
# Adaptive Scaffold
44

@@ -35,75 +35,74 @@ animation should use AdaptiveLayout.
3535

3636
<?code-excerpt "adaptive_scaffold_demo.dart (Example)"?>
3737
```dart
38-
@override
39-
Widget build(BuildContext context) {
40-
// Define the children to display within the body at different breakpoints.
41-
final List<Widget> children = <Widget>[
42-
for (int i = 0; i < 10; i++)
43-
Padding(
44-
padding: const EdgeInsets.all(8.0),
45-
child: Container(
46-
color: const Color.fromARGB(255, 255, 201, 197),
47-
height: 400,
48-
),
49-
)
50-
];
51-
52-
return AdaptiveScaffold(
53-
// An option to override the default breakpoints used for small, medium,
54-
// and large.
55-
smallBreakpoint: const WidthPlatformBreakpoint(end: 700),
56-
mediumBreakpoint: const WidthPlatformBreakpoint(begin: 700, end: 1000),
57-
largeBreakpoint: const WidthPlatformBreakpoint(begin: 1000),
58-
useDrawer: false,
59-
selectedIndex: _selectedTab,
60-
onSelectedIndexChange: (int index) {
61-
setState(() {
62-
_selectedTab = index;
63-
});
64-
},
65-
destinations: const <NavigationDestination>[
66-
NavigationDestination(
67-
icon: Icon(Icons.inbox_outlined),
68-
selectedIcon: Icon(Icons.inbox),
69-
label: 'Inbox',
70-
),
71-
NavigationDestination(
72-
icon: Icon(Icons.article_outlined),
73-
selectedIcon: Icon(Icons.article),
74-
label: 'Articles',
75-
),
76-
NavigationDestination(
77-
icon: Icon(Icons.chat_outlined),
78-
selectedIcon: Icon(Icons.chat),
79-
label: 'Chat',
80-
),
81-
NavigationDestination(
82-
icon: Icon(Icons.video_call_outlined),
83-
selectedIcon: Icon(Icons.video_call),
84-
label: 'Video',
85-
),
86-
NavigationDestination(
87-
icon: Icon(Icons.home_outlined),
88-
selectedIcon: Icon(Icons.home),
89-
label: 'Inbox',
38+
@override
39+
Widget build(BuildContext context) {
40+
// Define the children to display within the body at different breakpoints.
41+
final List<Widget> children = <Widget>[
42+
for (int i = 0; i < 10; i++)
43+
Padding(
44+
padding: const EdgeInsets.all(8.0),
45+
child: Container(
46+
color: const Color.fromARGB(255, 255, 201, 197),
47+
height: 400,
9048
),
91-
],
92-
body: (_) => GridView.count(crossAxisCount: 2, children: children),
93-
smallBody: (_) => ListView.builder(
94-
itemCount: children.length,
95-
itemBuilder: (_, int idx) => children[idx],
49+
)
50+
];
51+
52+
return AdaptiveScaffold(
53+
// An option to override the default breakpoints used for small, medium,
54+
// and large.
55+
smallBreakpoint: const WidthPlatformBreakpoint(end: 700),
56+
mediumBreakpoint: const WidthPlatformBreakpoint(begin: 700, end: 1000),
57+
largeBreakpoint: const WidthPlatformBreakpoint(begin: 1000),
58+
useDrawer: false,
59+
selectedIndex: _selectedTab,
60+
onSelectedIndexChange: (int index) {
61+
setState(() {
62+
_selectedTab = index;
63+
});
64+
},
65+
destinations: const <NavigationDestination>[
66+
NavigationDestination(
67+
icon: Icon(Icons.inbox_outlined),
68+
selectedIcon: Icon(Icons.inbox),
69+
label: 'Inbox',
70+
),
71+
NavigationDestination(
72+
icon: Icon(Icons.article_outlined),
73+
selectedIcon: Icon(Icons.article),
74+
label: 'Articles',
75+
),
76+
NavigationDestination(
77+
icon: Icon(Icons.chat_outlined),
78+
selectedIcon: Icon(Icons.chat),
79+
label: 'Chat',
80+
),
81+
NavigationDestination(
82+
icon: Icon(Icons.video_call_outlined),
83+
selectedIcon: Icon(Icons.video_call),
84+
label: 'Video',
9685
),
97-
// Define a default secondaryBody.
98-
secondaryBody: (_) => Container(
99-
color: const Color.fromARGB(255, 234, 158, 192),
86+
NavigationDestination(
87+
icon: Icon(Icons.home_outlined),
88+
selectedIcon: Icon(Icons.home),
89+
label: 'Inbox',
10090
),
101-
// Override the default secondaryBody during the smallBreakpoint to be
102-
// empty. Must use AdaptiveScaffold.emptyBuilder to ensure it is properly
103-
// overridden.
104-
smallSecondaryBody: AdaptiveScaffold.emptyBuilder,
105-
);
106-
}
91+
],
92+
body: (_) => GridView.count(crossAxisCount: 2, children: children),
93+
smallBody: (_) => ListView.builder(
94+
itemCount: children.length,
95+
itemBuilder: (_, int idx) => children[idx],
96+
),
97+
// Define a default secondaryBody.
98+
secondaryBody: (_) => Container(
99+
color: const Color.fromARGB(255, 234, 158, 192),
100+
),
101+
// Override the default secondaryBody during the smallBreakpoint to be
102+
// empty. Must use AdaptiveScaffold.emptyBuilder to ensure it is properly
103+
// overridden.
104+
smallSecondaryBody: AdaptiveScaffold.emptyBuilder,
105+
);
107106
}
108107
```
109108

packages/flutter_adaptive_scaffold/example/build.excerpt.yaml

Lines changed: 0 additions & 16 deletions
This file was deleted.

packages/flutter_adaptive_scaffold/example/lib/adaptive_scaffold_demo.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,5 +124,5 @@ class _MyHomePageState extends State<MyHomePage> {
124124
smallSecondaryBody: AdaptiveScaffold.emptyBuilder,
125125
);
126126
}
127-
// #enddocregion
127+
// #enddocregion Example
128128
}

packages/flutter_markdown/example/lib/demos/markdown_body_shrink_wrap_demo.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,16 @@ const String _data = '''
1717
''';
1818

1919
const String _notes = '''
20-
# Shrink wrap demo
20+
# Shrink wrap demo
2121
---
2222
2323
## Overview
2424
2525
This example demonstrates how `MarkdownBody`'s `shrinkWrap` property works.
2626
27-
- If `shrinkWrap` is `true`, `MarkdownBody` will take the minimum height that
27+
- If `shrinkWrap` is `true`, `MarkdownBody` will take the minimum height that
2828
wraps its content.
29-
- If `shrinkWrap` is `false`, `MarkdownBody` will expand to the maximum allowed
29+
- If `shrinkWrap` is `false`, `MarkdownBody` will expand to the maximum allowed
3030
height.
3131
''';
3232

packages/google_identity_services_web/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
<?code-excerpt path-base="excerpts/packages/google_identity_services_web_example"?>
2-
31
# google_identity_services_web
42

53
A JS-interop layer for Google Identity's Sign In With Google SDK.
@@ -29,7 +27,7 @@ script tag [as recommended](https://developers.google.com/identity/gsi/web/guide
2927
Place the `script` tag in the `<head>` of your site, next to the script tag that
3028
loads `flutter.js`, so the browser can downloaded both in parallel:
3129

32-
<?code-excerpt "../../web/index-with-script-tag.html (script-tag)"?>
30+
<?code-excerpt "example/web/index-with-script-tag.html (script-tag)"?>
3331
```html
3432
<head>
3533
<!-- ··· -->
@@ -46,7 +44,7 @@ An alternative way, that downloads the SDK on demand, is to use the
4644
**`loadWebSdk`** function provided by the library. A simple location to embed
4745
this in a Flutter Web only app can be the `main.dart`:
4846

49-
<?code-excerpt "main.dart (use-loader)"?>
47+
<?code-excerpt "example/lib/main.dart (use-loader)"?>
5048
```dart
5149
import 'package:google_identity_services_web/loader.dart' as gis;
5250
// ···

0 commit comments

Comments
 (0)