Skip to content

Commit df6d98d

Browse files
committed
Add font awesome version to collection dartdoc
1 parent 705b03c commit df6d98d

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

lib/font_awesome_flutter.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export 'package:font_awesome_flutter/src/icon_data.dart';
77

88
// THIS FILE IS AUTOMATICALLY GENERATED!
99

10+
/// Icons based on font awesome 5.15.0
1011
class FontAwesomeIcons {
1112
static const IconData fiveHundredPx = const IconDataBrands(0xf26e);
1213
static const IconData accessibleIcon = const IconDataBrands(0xf368);

pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ dev_dependencies:
1515
recase: ^3.0.0
1616
flutter_test:
1717
sdk: flutter
18+
version: ^1.2.0
1819

1920
flutter:
2021
fonts:

tool/generate_font.dart

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'dart:convert';
22
import 'dart:io';
33

44
import 'package:recase/recase.dart';
5+
import 'package:version/version.dart';
56

67
void main(List<String> arguments) {
78
var file = new File(arguments.first);
@@ -17,6 +18,9 @@ void main(List<String> arguments) {
1718

1819
bool hasDuotone = false;
1920

21+
// figure out current version
22+
Version highestVersion = Version.parse("0.0.0");
23+
2024
for (String iconName in icons.keys) {
2125
var icon = icons[iconName];
2226

@@ -25,6 +29,33 @@ void main(List<String> arguments) {
2529
if ((icon as Map<String, dynamic>).containsKey('private') &&
2630
icon['private']) continue;
2731

32+
// compute highest version
33+
var changes = (icon["changes"] as List) ?? List();
34+
35+
List<Version> versions = changes.map((v) {
36+
// since font awesome does not adhere to semver standards
37+
var partsCount = v.split(".").length;
38+
if (partsCount == 1) {
39+
return v + ".0.0";
40+
} else if (partsCount == 2) {
41+
return v + ".0";
42+
} else if (partsCount == 3) {
43+
return v;
44+
} else {
45+
return "0.0.0";
46+
}
47+
}).map((v) {
48+
try {
49+
return Version.parse(v);
50+
} on FormatException {
51+
return Version.parse("0.0.0");
52+
}
53+
}).toList(growable: true)
54+
..add(highestVersion)
55+
..sort();
56+
57+
highestVersion = versions.last;
58+
2859
var unicode = icon['unicode'];
2960
List<String> styles = (icon['styles'] as List).cast<String>();
3061

@@ -77,6 +108,7 @@ void main(List<String> arguments) {
77108
'',
78109
'// THIS FILE IS AUTOMATICALLY GENERATED!',
79110
'',
111+
'/// Icons based on font awesome $highestVersion',
80112
'class FontAwesomeIcons {',
81113
]);
82114

0 commit comments

Comments
 (0)