[Docs] [Material] Fix Icons api docs (#66508)
* [Docs] [Icons] Updating dart doc styles to recognize more styles of icons. All the 4 icon styles we support have to be pulled from 4 individual web fonts when we show the html page for api docs. * Better documentation and that special awful case. * Couple more places to remove.
This commit is contained in:
@@ -263,14 +263,40 @@ void _testIsMapSuperset(Map<String, String> newCodepoints, Map<String, String> o
|
||||
}
|
||||
|
||||
String _generateDeclaration(MapEntry<String, String> tokenPair) {
|
||||
final String identifier = _generateIdentifier(tokenPair.key);
|
||||
final String description = tokenPair.key.replaceAll('_', ' ');
|
||||
|
||||
String styleSuffix = '';
|
||||
String webFontKey = tokenPair.key;
|
||||
|
||||
// The first line of each generated declaration includes a comment of html.
|
||||
// DartDocs reads that to make the listings in our api docs that shows the
|
||||
// icon rendered next to its key name. Unfortunately, unlike Flutter, this
|
||||
// html needs to use a different web font for each style. We read the style's
|
||||
// suffix from the key for Flutter's icons font, add the corresponding style's
|
||||
// suffix to the class we pass into html, and then remove the suffix from the
|
||||
// icon key. The keys needed for the individual web fonts do not use a suffix
|
||||
// to denote style.
|
||||
if (webFontKey.endsWith('_outlined') && webFontKey!='insert_chart_outlined') {
|
||||
styleSuffix = '-outlined';
|
||||
webFontKey = webFontKey.replaceAll('_outlined', '');
|
||||
}
|
||||
if (webFontKey.endsWith('_rounded')) {
|
||||
styleSuffix = '-round';
|
||||
webFontKey = webFontKey.replaceAll('_rounded', '');
|
||||
}
|
||||
if (webFontKey.endsWith('_sharp')) {
|
||||
styleSuffix = '-sharp';
|
||||
webFontKey = webFontKey.replaceAll('_sharp', '');
|
||||
}
|
||||
|
||||
final String identifier = _generateIdentifier(tokenPair.key);
|
||||
final String rtl = _mirroredIcons.contains(tokenPair.key)
|
||||
? ', matchTextDirection: true'
|
||||
: '';
|
||||
|
||||
return '''
|
||||
|
||||
/// <i class="material-icons md-36">${tokenPair.key}</i> — material icon named "$description".
|
||||
/// <i class="material-icons$styleSuffix md-36">$webFontKey</i> — material icon named "$description".
|
||||
static const IconData $identifier = IconData(0x${tokenPair.value}, fontFamily: 'MaterialIcons'$rtl);
|
||||
''';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user