in packages/code_excerpt_updater/lib/src/excerpt_getter.dart [65:99]
String? _getExcerptAsStringFromYaml(String relativePath, String region) {
const ext = '.excerpt.yaml';
final excerptYamlPath =
p.join(fragmentDirPath, pathBase, relativePath + ext);
YamlMap? excerptsYaml;
try {
final contents = File(excerptYamlPath).readAsStringSync();
excerptsYaml =
loadYaml(contents, sourceUrl: Uri.file(excerptYamlPath)) as YamlMap;
_yamlExcerptLeftBorderChar =
(excerptsYaml[_yamlExcerptLeftBorderCharKey] ?? '') as String;
} on FileSystemException {
// Fall through
}
if (region.isEmpty && excerptsYaml == null) {
// Continue: search for source file.
} else if (excerptsYaml == null) {
_reporter.error('cannot read file "$excerptYamlPath"');
return null;
} else if (excerptsYaml[region] == null) {
_reporter.error('there is no "$region" region in "$excerptYamlPath"');
return null;
} else {
return (excerptsYaml[region] as String).trimRight();
}
// ...
final filePath = p.join(fragmentDirPath, pathBase, relativePath);
try {
return File(filePath).readAsStringSync();
} on FileSystemException {
_reporter.error('excerpt not found for "$relativePath"');
return null;
}
}