Skip to content

Commit 9f854c6

Browse files
authored
Add a tool to check if a site variable can be used (#5704)
Check if text can be replaced with site variables. Used to solve problems like this: PR flutter/website#9894 . ### Tool YAML Variable Scanner: [AmosHuKe/yaml_variable_scanner](https://github.com/AmosHuKe/yaml_variable_scanner) Tool Configuration: [/tool/config/site_variable_scanner.yaml](https://github.com/dart-lang/site-www/blob/aa74188529d8af652914929e27243a2ef00cdf94/tool/config/site_variable_scanner.yaml) ### Run ```bash # Run $ dart run dart_site check-site-variable # Help $ dart run dart_site check-site-variable --help Scan multiple files for text that can use site variables. Usage: dart_site check-site-variable [arguments] -h, --help Print this usage information. --print-mode Console Print Mode. [detail] (default) Detail to file lines and columns. [detailAndStats] detail & stats. [none] No content. [stats] Total statistics. ``` ### Output #### Replaceable content https://github.com/dart-lang/site-www/actions/runs/8611203920/job/23597985552?pr=5704#step:5:1 ![replaceable-content](https://github.com/dart-lang/site-www/assets/32262985/ea4c350c-8c7e-4441-bd3b-3c2be9344047) #### No replaceable content https://github.com/dart-lang/site-www/actions/runs/8611314772/job/23598283785?pr=5704#step:5:1 ![no-replacement content](https://github.com/dart-lang/site-www/assets/32262985/5f125105-efcb-48db-8507-13075c85b51a)
1 parent 30bc997 commit 9f854c6

Some content is hidden

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

79 files changed

+465
-333
lines changed

.github/workflows/test.yml

+15
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,21 @@ jobs:
9595
- name: Check internal site links are functional
9696
run: dart run dart_site check-links
9797

98+
site-variable-scanner:
99+
name: Check if text can be replaced with site variables
100+
runs-on: ubuntu-latest
101+
steps:
102+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
103+
with:
104+
submodules: recursive
105+
- uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
106+
with:
107+
sdk: stable
108+
- name: Fetch Dart packages
109+
run: dart pub get
110+
- name: Check if text can be replaced with site variables
111+
run: dart run dart_site check-site-variable
112+
98113
firebase-validate:
99114
name: Validate Firebase configuration
100115
runs-on: ubuntu-latest

AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ Michael Haubenwallner <michael.haubenwallner@gmail.com>
1414
Victor Berchet <victor.berchet@gmail.com>
1515
Pradumna Saraf <pradumnasaraf@gmail.com>
1616
Parker Lougheed <parlough@gmail.com>
17+
Amos Hu <amoshuke@gmail.com>

src/_data/site.yml

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ title: Dart
55
description: >-
66
Dart is a client-optimized language for developing fast apps on any platform.
77
url: https://dart.dev
8+
redirect:
9+
go: https://dart.dev/go
810
repo:
911
this: https://github.com/dart-lang/site-www
1012
shared: https://github.com/dart-lang/site-shared

src/_includes/known-issues/compile-ki.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ No support for `dart:mirrors` and `dart:developer`
1212

1313
[Multi-platform]: /libraries#multi-platform-libraries
1414
[Native platform]: /libraries#native-platform-libraries
15-
[issue 28617]: https://github.com/dart-lang/sdk/issues/28617
15+
[issue 28617]: {{site.repo.dart.sdk}}/issues/28617
1616

1717
:::tip
1818
If one of these issues is important to you,

src/_includes/tools/dart-compile-js-options.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Some other handy options include:
7777
`--version`
7878
: Displays version information for `dart`.
7979

80-
[Dart package configuration file]: https://github.com/dart-lang/language/blob/main/accepted/2.8/language-versioning/package-config-file-v2.md
80+
[Dart package configuration file]: {{site.repo.dart.lang}}/blob/main/accepted/2.8/language-versioning/package-config-file-v2.md
8181
[`String.fromEnvironment`]: {{site.dart-api}}/{{site.sdkInfo.channel}}/dart-core/String/String.fromEnvironment.html
8282
[`int.fromEnvironment`]: {{site.dart-api}}/{{site.sdkInfo.channel}}/dart-core/int/int.fromEnvironment.html
8383
[`bool.fromEnvironment`]: {{site.dart-api}}/{{site.sdkInfo.channel}}/dart-core/bool/bool.fromEnvironment.html

src/_includes/tools/debug-prod-js-code.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ To debug in Firefox:
5959
To debug in Safari:
6060

6161
1. Turn on the **Develop** menu,
62-
as described in the [Safari Web Inspector Tutorial.](https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/Web_Inspector_Tutorial/EnableWebInspector/EnableWebInspector.html)
62+
as described in the [Safari Web Inspector Tutorial.]({{site.apple-dev}}/library/archive/documentation/NetworkingInternetWeb/Conceptual/Web_Inspector_Tutorial/EnableWebInspector/EnableWebInspector.html)
6363
2. Enable breaks, either on all exceptions or only on uncaught exceptions.
6464
See [Add a JavaScript breakpoint](https://support.apple.com/en-ca/guide/safari-developer/add-a-javascript-breakpoint-dev5e4caf347/mac) under [Safari Developer Help.](https://support.apple.com/en-ca/guide/safari-developer/welcome/mac)
6565
3. Reload your app.

src/content/articles/archive/zones.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Java's _thread-local storage_
7474
also has some similarities.
7575
Closest of all is Brian Ford's JavaScript port of Dart zones,
7676
[zone.js](https://github.com/btford/zone.js/), which he describes in
77-
[this video](https://www.youtube.com/watch?v=3IqtmUscE_U).
77+
[this video]({{yt.watch}}?v=3IqtmUscE_U).
7878

7979

8080
## Zone basics
@@ -589,7 +589,7 @@ lets you specify the code that the zone executes.
589589
In the future, zones might provide a simpler alternative
590590
for the common case of sandwiching zone code:
591591
an onEnter/onLeave API.
592-
See [issue 17532](https://github.com/dart-lang/sdk/issues/17532)
592+
See [issue 17532]({{site.repo.dart.sdk}}/issues/17532)
593593
for details.
594594
:::
595595

@@ -790,15 +790,15 @@ The source code for the stack_trace package
790790
for debugging asynchronous code.
791791
Zone features used include error handling, zone-local values, and callbacks.
792792
You can find the stack_trace source code in the
793-
[stack_trace GitHub project](https://github.com/dart-lang/stack_trace).
793+
[stack_trace GitHub project]({{site.repo.dart.org}}/stack_trace).
794794

795795
The source code for dart:html and dart:async
796796
: These two SDK libraries implement APIs featuring asynchronous callbacks,
797797
and thus they deal with zones.
798798
You can browse or download their source code under the
799-
[sdk/lib directory](https://github.com/dart-lang/sdk/tree/main/sdk/lib)
799+
[sdk/lib directory]({{site.repo.dart.sdk}}/tree/main/sdk/lib)
800800
of the
801-
[Dart GitHub project](https://github.com/dart-lang/sdk).
801+
[Dart GitHub project]({{site.repo.dart.sdk}}).
802802

803803

804804
_Thanks to Anders Johnsen and Lasse Reichstein Nielsen

src/content/articles/libraries/creating-streams.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ This code creates a stream to return,
232232
and then feeds data into it based on timer events,
233233
which are neither futures nor stream events.
234234

235-
[stream_controller_bad.dart]: https://github.com/dart-lang/site-www/blob/main/examples/misc/lib/articles/creating-streams/stream_controller_bad.dart
235+
[stream_controller_bad.dart]: {{site.repo.this}}/blob/main/examples/misc/lib/articles/creating-streams/stream_controller_bad.dart
236236

237237
<?code-excerpt "misc/lib/articles/creating-streams/stream_controller_bad.dart (flawed-stream)"?>
238238
```dart tag=bad
@@ -366,7 +366,7 @@ implements pause by using the
366366
`onListen`, `onPause`, `onResume`, and `onCancel` callbacks
367367
on the `StreamController`.
368368

369-
[stream_controller.dart]: https://github.com/dart-lang/site-www/blob/main/examples/misc/lib/articles/creating-streams/stream_controller.dart
369+
[stream_controller.dart]: {{site.repo.this}}/blob/main/examples/misc/lib/articles/creating-streams/stream_controller.dart
370370

371371
<?code-excerpt "misc/lib/articles/creating-streams/stream_controller.dart (better-stream)"?>
372372
```dart

src/content/codelabs/async-await.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ are some suggestions for where to go next:
10941094
Watch one or more of the videos about asynchronous coding.
10951095
- Get the [Dart SDK](/get-dart)!
10961096

1097-
[Dart videos]: https://www.youtube.com/playlist?list=PLjxrf2q8roU0Net_g1NT5_vOO3s_FR02J
1097+
[Dart videos]: {{yt.playlist}}PLjxrf2q8roU0Net_g1NT5_vOO3s_FR02J
10981098
[Future]: {{site.dart-api}}/{{site.sdkInfo.channel}}/dart-async/Future-class.html
10991099
[style guide]: /effective-dart/style
11001100
[documentation guide]: /effective-dart/documentation

src/content/community/index.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,16 @@ Get answers and connect with Dart developers.
5353

5454
Dart is open source.
5555
Learn how to
56-
[contribute to the core SDK.](https://github.com/dart-lang/sdk/blob/main/CONTRIBUTING.md)
56+
[contribute to the core SDK.]({{site.repo.dart.sdk}}/blob/main/CONTRIBUTING.md)
5757

58-
[Dart GitHub repositories](https://github.com/dart-lang/)
58+
[Dart GitHub repositories]({{site.repo.dart.org}}/)
5959
: Track new changes and contribute to various Dart projects.
60-
* [Core SDK](https://github.com/dart-lang/sdk/)
61-
([issue tracker](https://github.com/dart-lang/sdk/issues/))
62-
* [The Dart Language](https://github.com/dart-lang/language)
63-
([issue tracker](https://github.com/dart-lang/language/issues))
64-
* [This site](https://github.com/dart-lang/site-www/)
65-
([issue tracker](https://github.com/dart-lang/site-www/issues/))
60+
* [Core SDK]({{site.repo.dart.sdk}}/)
61+
([issue tracker]({{site.repo.dart.sdk}}/issues/))
62+
* [The Dart Language]({{site.repo.dart.lang}})
63+
([issue tracker]({{site.repo.dart.lang}}/issues))
64+
* [This site]({{site.repo.this}}/)
65+
([issue tracker]({{site.repo.this}}/issues/))
6666

6767
[Dart reviews]({{group}}/d/forum/reviews)
6868
: High-traffic list of all core SDK code reviews.

src/content/effective-dart/_readme.md

-16
This file was deleted.

src/content/effective-dart/style.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ The remaining formatting guidelines are for the few things `dart format` cannot
417417
for you.
418418

419419
[`dart format`]: /tools/dart-format
420-
[dart format docs]: https://github.com/dart-lang/dart_style/wiki/Formatting-Rules
420+
[dart format docs]: {{site.repo.dart.org}}/dart_style/wiki/Formatting-Rules
421421

422422
### CONSIDER changing your code to make it more formatter-friendly
423423

src/content/get-dart/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ follow the [instructions on this page](#install).
150150

151151
{% endfor -%}
152152

153-
[build-source]: https://github.com/dart-lang/sdk/wiki/Building
153+
[build-source]: {{site.repo.dart.sdk}}/wiki/Building
154154
[dart-docker]: https://hub.docker.com/_/dart
155155
[dl-sdk]: /get-dart/archive
156156
[install-flutter]: {{site.flutter-docs}}/get-started/install

src/content/guides/environment-declarations.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ To track standardization of this handling,
119119
reference [SDK issue 44995][].
120120
:::
121121

122-
[SDK issue 44995]: https://github.com/dart-lang/sdk/issues/44995
122+
[SDK issue 44995]: {{site.repo.dart.sdk}}/issues/44995
123123

124124
### Dart CLI
125125

src/content/guides/google-apis.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ To find wrapper packages for Google client APIs, search for
5454
[`gsheets` package]: {{site.pub-pkg}}/gsheets
5555
[gsheets-api-docs]: {{site.pub-api}}/gsheets/latest/gsheets/gsheets-library.html
5656
[gsheets-api-docs-gapi]: {{site.pub-api}}/googleapis/latest/sheets_v4/sheets_v4-library.html
57-
[flutter-google-apis]: https://flutter.dev/docs/development/data-and-backend/google-apis
58-
[server-sample]: https://github.com/dart-lang/samples/tree/main/server/google_apis
57+
[flutter-google-apis]: {{site.flutter-docs}}/development/data-and-backend/google-apis
58+
[server-sample]: {{site.repo.dart.org}}/samples/tree/main/server/google_apis

src/content/guides/language/coming-from/swift-to-dart.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ can be returned that contains these values.
682682
More on this can be found in the sections on
683683
[collections](#collections) and [classes](#classes).
684684

685-
[several tuple packages]: {{site.pub}}/packages?q=tuples
685+
[several tuple packages]: {{site.pub-pkg}}?q=tuples
686686

687687
### Exception and error handling
688688

src/content/guides/language/evolution.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ _Released 5 November 2019_
355355
| [Dart 2.6 announcement](https://medium.com/dartlang/dart2native-a76c815e6baf)
356356

357357
Dart 2.6 introduced a
358-
[breaking change (dart-lang/sdk#37985)](https://github.com/dart-lang/sdk/issues/37985).
358+
[breaking change (dart-lang/sdk#37985)]({{site.repo.dart.sdk}}/issues/37985).
359359
Constraints where `Null` serves as a subtype of `FutureOr<T>`
360360
now yield `Null` as the solution for `T`.
361361

@@ -384,7 +384,7 @@ _Released 27 June 2019_
384384

385385

386386
Dart 2.4 introduces a breaking change
387-
[dart-lang/sdk#35097](https://github.com/dart-lang/sdk/issues/35097).
387+
[dart-lang/sdk#35097]({{site.repo.dart.sdk}}/issues/35097).
388388

389389
Dart now enforces covariance of type variables used in super-interfaces.
390390
For example: Prior to this release Dart accepted, but now rejects,
@@ -586,21 +586,21 @@ other comments can appear before the `@dart` comment.
586586
To learn how and why the Dart team developed this versioning method,
587587
check out the [language versioning specification][].
588588

589-
[2.8 breaking changes]: https://github.com/dart-lang/sdk/issues/40686
589+
[2.8 breaking changes]: {{site.repo.dart.sdk}}/issues/40686
590590
[calling native C code]: /interop/c-interop
591591
[collection for]: /language/collections#control-flow-operators
592592
[collection if]: /language/collections#control-flow-operators
593593
[Dart library]: /guides/libraries/create-packages#organizing-a-package
594594
[Dart FFI]: /interop/c-interop
595595
[extension methods]: /language/extension-methods
596596
[Extension types]: /language/extension-types
597-
[language funnel]: https://github.com/dart-lang/language/projects/1
597+
[language funnel]: {{site.repo.dart.lang}}/projects/1
598598
[language specification]: /guides/language/spec
599599
[language documentation]: /language
600-
[language versioning specification]: https://github.com/dart-lang/language/blob/main/accepted/2.8/language-versioning/feature-specification.md#dart-language-versioning
600+
[language versioning specification]: {{site.repo.dart.lang}}/blob/main/accepted/2.8/language-versioning/feature-specification.md#dart-language-versioning
601601
[null safety]: /null-safety
602602
[private final field promotion]: /tools/non-promotion-reasons
603-
[SDK changelog]: https://github.com/dart-lang/sdk/blob/main/CHANGELOG.md
603+
[SDK changelog]: {{site.repo.dart.sdk}}/blob/main/CHANGELOG.md
604604
[set literals]: /language/collections#sets
605605
[sound null safety]: /null-safety
606606
[sound type system]: /language/type-system

src/content/guides/language/spec.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ You can find the in-progress specification in PDF format:
1717
(produced from a [LaTeX file][])
1818

1919
[latest draft]: https://spec.dart.dev/DartLangSpecDraft.pdf
20-
[LaTeX file]: https://github.com/dart-lang/language/blob/main/specification/dartLangSpec.tex
20+
[LaTeX file]: {{site.repo.dart.lang}}/blob/main/specification/dartLangSpec.tex
2121

2222
New language features are typically described using
2323
informal language feature specifications in the [dart-lang/language][] repo:
2424

2525
* [Accepted informal proposals][]
2626
* [Drafts of potential features][]
2727

28-
[dart-lang/language]: https://github.com/dart-lang/language
29-
[Accepted informal proposals]: https://github.com/dart-lang/language/tree/main/accepted
30-
[Drafts of potential features]: https://github.com/dart-lang/language/tree/main/working
28+
[dart-lang/language]: {{site.repo.dart.lang}}
29+
[Accepted informal proposals]: {{site.repo.dart.lang}}/tree/main/accepted
30+
[Drafts of potential features]: {{site.repo.dart.lang}}/tree/main/working
3131

3232
:::version-note
3333
Dart 3 changed the Dart language in a few ways,

src/content/guides/libraries/create-packages.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Some packages have separate libraries that are meant to be imported
7777
with a prefix, when the main library is not.
7878

7979
Let's look at the organization of a real-world package: shelf. The
80-
[shelf](https://github.com/dart-lang/shelf)
80+
[shelf]({{site.repo.dart.org}}/shelf)
8181
package provides an easy way to create web servers using Dart,
8282
and is laid out in a structure that is commonly used for Dart packages:
8383

@@ -219,7 +219,7 @@ void main() {
219219

220220
A well-designed package is easy to test.
221221
We recommend that you write tests using the
222-
[test](https://github.com/dart-lang/test) package,
222+
[test]({{site.repo.dart.org}}/test) package,
223223
placing the test code in the `test` directory at the
224224
top of the package.
225225

@@ -308,12 +308,12 @@ Use the following resources to learn more about packages:
308308
* [What not to commit](private-files)
309309
covers what should not be checked into a source code repository.
310310
* The newer packages under the
311-
[dart-lang](https://github.com/dart-lang) organization tend
311+
[dart-lang]({{site.repo.dart.org}}) organization tend
312312
to show best practices. Consider studying these examples:
313-
[dart_style,](https://github.com/dart-lang/dart_style)
314-
[path,](https://github.com/dart-lang/path)
315-
[shelf,](https://github.com/dart-lang/shelf)
316-
[source_gen,](https://github.com/dart-lang/source_gen) and
317-
[test.](https://github.com/dart-lang/test)
313+
[dart_style,]({{site.repo.dart.org}}/dart_style)
314+
[path,]({{site.repo.dart.org}}/path)
315+
[shelf,]({{site.repo.dart.org}}/shelf)
316+
[source_gen,]({{site.repo.dart.org}}/source_gen) and
317+
[test.]({{site.repo.dart.org}}/test)
318318

319319
[`dart doc`]: /tools/dart-doc

src/content/guides/libraries/writing-package-pages.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ in the following screenshot:
3232
For details about other parts of the package page,
3333
follow these links:
3434

35-
1. [Package layout ](https://dart.dev/tools/pub/package-layout)
36-
2. [Flutter Favorite](https://flutter.dev/docs/development/packages-and-plugins/favorites)
35+
1. [Package layout ](/tools/pub/package-layout)
36+
2. [Flutter Favorite]({{site.flutter-docs}}/development/packages-and-plugins/favorites)
3737
3. [Package scoring]({{site.pub}}/help/scoring)
38-
4. [Verified publishers](https://dart.dev/tools/pub/verified-publishers)
39-
5. [Pubspec file](https://dart.dev/tools/pub/pubspec)
38+
4. [Verified publishers](/tools/pub/verified-publishers)
39+
5. [Pubspec file](/tools/pub/pubspec)
4040

4141

4242
## Writing a good README is important

src/content/guides/testing.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ following packages are useful across Dart platforms:
7575
expected ways.
7676
For an example that uses both package:test and package:mockito,
7777
see the [International Space Station API library and its unit
78-
tests](https://github.com/dart-lang/mockito/tree/master/example/iss)
79-
in the [mockito package](https://github.com/dart-lang/mockito).
78+
tests]({{site.repo.dart.org}}/mockito/tree/master/example/iss)
79+
in the [mockito package]({{site.repo.dart.org}}/mockito).
8080

8181
## Flutter testing
8282

@@ -127,8 +127,8 @@ Learn more about GitHub Actions:
127127
For an example, see
128128
[`test-package.yml`][markdown-ci] in the markdown package's repo.
129129
To see how that repo migrated from Travis CI to GitHub Actions,
130-
look at [PR #353](https://github.com/dart-lang/markdown/pull/353).
130+
look at [PR #353]({{site.repo.dart.org}}/markdown/pull/353).
131131

132132
[gha-article]: https://poetryincode.dev/testing-dart-packages-with-github-actions
133-
[markdown-ci]: https://github.com/dart-lang/markdown/blob/master/.github/workflows/test-package.yml
133+
[markdown-ci]: {{site.repo.dart.org}}/markdown/blob/master/.github/workflows/test-package.yml
134134

0 commit comments

Comments
 (0)