Skip to content

Commit 44de08a

Browse files
authored
chore: Update docs for AI agents (#1506)
* Codex: Fix API drifts in README * Add MCP config and AGENTS.md * Add copilot-setup-steps.yml
1 parent 0d64779 commit 44de08a

File tree

5 files changed

+100
-6
lines changed

5 files changed

+100
-6
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: "Copilot Setup Steps"
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- .github/workflows/copilot-setup-steps.yml
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
copilot-setup-steps:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
18+
19+
- name: Setup Flutter
20+
uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e # v2.21.0
21+
with:
22+
cache: true
23+
24+
- run: ./tool/pub-get.sh

.vscode/mcp.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"servers": {
3+
"context7": {
4+
"type": "http",
5+
"url": "https://mcp.context7.com/mcp"
6+
}
7+
}
8+
}

AGENTS.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Repository Guidelines
2+
3+
## Project Structure & Module Organization
4+
5+
- `packages/`: Dart/Flutter packages. Core at `packages/core`, public wrapper at `packages/enhanced`, and feature add‑ons under `packages/fwfh_*`.
6+
- `demo_app/`: Example Flutter app for manual testing and screenshots.
7+
- `tool/`: Helper scripts (notably `tool/test.sh`).
8+
- `docs/`, `.github/`: Documentation and CI.
9+
- Use `context7CompatibleLibraryID=/flutter/website` with `context7.get-library-docs` tool for latest Flutter documentation.
10+
- Tests live in each package’s `test/` and in `demo_app/test/`. Golden assets are under `test/images/`.
11+
12+
## Build, Test, and Development Commands
13+
14+
- Install latest deps: `./tool/pub-get.sh`.
15+
- Analyze all + run tests: `./tool/test.sh` (accepts extra flags like `--coverage` or `--update-goldens`).
16+
- Format code: `dart format .`.
17+
- Per‑package checks: `flutter analyze` and `flutter test` from each package dir.
18+
19+
## Coding Style & Naming Conventions
20+
21+
- Dart style with 2‑space indentation; keep lines focused and readable.
22+
- Lints: `package:lint` plus repo rules (see each `analysis_options.yaml`). Prefer relative imports, avoid relative `lib/` imports.
23+
- Names: classes `PascalCase`, members `camelCase`, constants `SCREAMING_SNAKE_CASE`, private with leading `_`.
24+
25+
## Testing Guidelines
26+
27+
- Frameworks: `flutter_test`, `test`, and `golden_toolkit` for widget/golden tests.
28+
- Location: place tests next to code in `package/test/*.dart` with `_test.dart` suffix.
29+
- Goldens: store expected images under `test/images/`; regenerate with `--update-goldens` and review diffs.
30+
- Web interop (when applicable): see `packages/fwfh_webview` integration tests; ensure Chrome/driver available if running locally.

packages/core/README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,23 @@ HtmlWidget(
6363
// render a custom widget that inlines with surrounding text
6464
return InlineCustomWidget(
6565
child: FizzBuzzWidget(),
66-
)
66+
);
6767
}
6868
6969
return null;
7070
},
7171
7272
// this callback will be triggered when user taps a link
73-
onTapUrl: (url) => print('tapped $url'),
73+
// return true to indicate the tap has been handled
74+
onTapUrl: (url) {
75+
debugPrint('tapped $url');
76+
return true;
77+
},
78+
79+
// this callback will be triggered when user taps an image
80+
onTapImage: (image) {
81+
debugPrint('image tapped: \'${image.sources.first.url}\'');
82+
},
7483
7584
// select the render mode for HTML body
7685
// by default, a simple `Column` is rendered
@@ -82,6 +91,13 @@ HtmlWidget(
8291
),
8392
```
8493

94+
## Callbacks
95+
96+
- onTapUrl: return `true` to indicate the URL tap was handled; when not handled and the URL is an in-page anchor (e.g. `#id` or `${baseUrl}#id`), it scrolls to the anchor automatically.
97+
- onTapImage: receives `ImageMetadata`; access the first source via `image.sources.first.url`.
98+
- onLoadingBuilder: shown while the widget/image is loading; receives `loadingProgress` (0.0–1.0 or null).
99+
- onErrorBuilder: shown when a complex element fails to render; receives the thrown `error`.
100+
85101
## Features
86102

87103
### HTML tags
@@ -192,6 +208,6 @@ The [enhanced](https://pub.dev/packages/flutter_widget_from_html) package uses a
192208
- [fwfh_url_launcher](https://pub.dev/packages/fwfh_url_launcher) to launch URLs
193209
- [fwfh_webview](https://pub.dev/packages/fwfh_webview) for IFRAME support
194210

195-
See [the extensibility document](https://github.com/daohoangson/flutter_widget_from_html/blob/v0.14.2/docs/extensibility.md) for detailed information.
211+
See [the extensibility document](https://github.com/daohoangson/flutter_widget_from_html/blob/master/docs/extensibility.md) for detailed information.
196212

197213
<a href="https://www.buymeacoffee.com/daohoangson" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>

packages/enhanced/README.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,23 @@ HtmlWidget(
8484
// render a custom widget inline with surrounding text
8585
return InlineCustomWidget(
8686
child: FizzBuzzWidget(),
87-
)
87+
);
8888
}
8989

9090
return null;
9191
},
9292

9393
// this callback will be triggered when user taps a link
94-
onTapUrl: (url) => print('tapped $url'),
94+
// return true to indicate the tap has been handled
95+
onTapUrl: (url) {
96+
debugPrint('tapped $url');
97+
return true;
98+
},
99+
100+
// this callback will be triggered when user taps an image
101+
onTapImage: (image) {
102+
debugPrint('image tapped: \'${image.sources.first.url}\'');
103+
},
95104

96105
// select the render mode for HTML body
97106
// by default, a simple `Column` is rendered
@@ -103,6 +112,13 @@ HtmlWidget(
103112
),
104113
```
105114

115+
## Callbacks
116+
117+
- onTapUrl: return `true` to indicate the URL tap was handled; when not handled and the URL is an in-page anchor (e.g. `#id` or `${baseUrl}#id`), it scrolls to the anchor automatically.
118+
- onTapImage: receives `ImageMetadata`; access the first source via `image.sources.first.url`.
119+
- onLoadingBuilder: shown while the widget/image is loading; receives `loadingProgress` (0.0–1.0 or null).
120+
- onErrorBuilder: shown when a complex element fails to render; receives the thrown `error`.
121+
106122
## Features
107123

108124
### HTML tags
@@ -203,6 +219,6 @@ These tags and their contents will be ignored:
203219

204220
The [core](https://pub.dev/packages/flutter_widget_from_html_core) package implements widget building logic with high testing coverage to ensure correctness. It tries to render an optimal tree by using `RichText` with specific `TextStyle`, merging text spans together, showing images in sized box, etc. The idea is to build a solid foundation for apps to customize.
205221

206-
See [the extensibility document](https://github.com/daohoangson/flutter_widget_from_html/blob/v0.14.2/docs/extensibility.md) for detailed information.
222+
See [the extensibility document](https://github.com/daohoangson/flutter_widget_from_html/blob/master/docs/extensibility.md) for detailed information.
207223

208224
<a href="https://www.buymeacoffee.com/daohoangson" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>

0 commit comments

Comments
 (0)