- ...
- */
-
- var diffText = (r.stdout as String).trim();
- final fromArg = args['from'];
- final toArg = args['to'];
- if (fromArg != null || toArg != null) {
- final from = fromArg == null ? null : patternArgToMatcher(fromArg);
- final to = toArg == null ? null : patternArgToMatcher(toArg);
- final diff = Diff(diffText);
- if (diff.keepLines(from: from, to: to)) diffText = diff.toString();
- }
- final result = diffText.split(eol);
-
- // Fix file id lines by removing:
- // - [pathPrefix] from the start of the file path so that paths are relative
- // - timestamp (because file timestamps are not relevant in the git world)
- result[0] = _adjustDiffFileIdLine(
- relativeSrcPath1 + (region.isEmpty ? '' : ' ($region)'), result[0]);
- result[1] = _adjustDiffFileIdLine(
- relativeSrcPath2 + (region.isEmpty ? '' : ' ($region)'), result[1]);
- _log.fine('>> diff result:\n${result.join("\n")}');
- return result;
- }
-
- /// Read the file at [filePath], strip out any docregion tags (lines matching
- /// [docregionRe]), write the result to a temporary file and return the
- /// corresponding [File] object.
- ///
- /// Lets [FileSystemException]s through.
- File filteredFile(String filePath) {
- final file = File(filePath);
- final src = file.readAsStringSync();
- final lines = src.split(eol);
- lines.removeWhere(docregionRe.hasMatch);
-
- return _writeTmp(filePath, lines.join(eol));
- }
-
- /// Write the named region of [filePath] to a temporary file whose filename
- /// is derived from [filePath]. Returns the [File] instance of the temp file.
- File _writeExcerpt(
- String filePath, String region, Map
args) {
- var excerpt = _excerptFetcher(filePath, region)?.join(eol) ?? '';
-
- final removeArg = args['remove'];
- if (removeArg != null) {
- final removed = removeCodeTransformer(removeArg);
- excerpt = removed(excerpt);
- }
-
- // To avoid "No newline at end of file" messages from the diff tool,
- // ensure that the excerpt ends with an EOL (since all trailing blank lines
- // are usually stripped out).
- if (excerpt.isNotEmpty) excerpt += eol;
-
- return _writeTmp(filePath, excerpt);
- }
-
- /// Write [content] to a temporary file whose filename is derived
- /// from [filePath]. Returns the temporary [File] instance.
- File _writeTmp(String filePath, String content) {
- final ext = p.extension(filePath);
- final tmpFilePath =
- p.join(tempDirectory.path, 'differ_src_${filePath.hashCode}$ext');
- final tmpFile = File(tmpFilePath);
- tmpFile.writeAsStringSync(content);
- return tmpFile;
- }
-
- // int _indexOfFirstMatch(List a, int startingIdx, RegExp re) {
- // var i = startingIdx;
- // while (i < a.length && !re.hasMatch(a[i])) i++;
- // return i;
- // }
-
- final RegExp _diffFileIdRegEx = RegExp(r'^(---|\+\+\+) ([^\t]+)\t(.*)$');
-
- String _adjustDiffFileIdLine(String relativePath, String diffFileIdLine) {
- final line = diffFileIdLine;
- final match = _diffFileIdRegEx.firstMatch(line);
- if (match == null) {
- _log.warning('Warning: unexpected file Id line: $diffFileIdLine');
- return diffFileIdLine;
- }
- return '${match[1]} $relativePath';
- }
-
- Directory get tempDirectory => _tmpDir;
-}
diff --git a/packages/code_excerpt_updater/lib/src/excerpt_getter.dart b/packages/code_excerpt_updater/lib/src/excerpt_getter.dart
deleted file mode 100644
index e9e1191..0000000
--- a/packages/code_excerpt_updater/lib/src/excerpt_getter.dart
+++ /dev/null
@@ -1,135 +0,0 @@
-import 'dart:io';
-
-import 'package:path/path.dart' as p;
-import 'package:yaml/yaml.dart';
-
-import 'code_transformer/core.dart';
-import 'constants.dart';
-import 'issue_reporter.dart';
-import 'logger.dart';
-import 'util.dart';
-
-const _defaultYamlExcerptLeftBorderChar = ''; // I.e., no char by default
-const _yamlExcerptLeftBorderCharKey = '#border';
-
-class ExcerptGetter {
- ExcerptGetter(
- this.excerptsYaml, this.fragmentDirPath, this.srcDirPath, this._reporter);
-
- final bool excerptsYaml;
- final String fragmentDirPath;
- final String srcDirPath;
- final IssueReporter _reporter;
-
- String pathBase = '';
- String _yamlExcerptLeftBorderChar = _defaultYamlExcerptLeftBorderChar;
-
- Iterable? getExcerpt(
- // String pathBase,
- String relativePath,
- String region,
- [CodeTransformer? t]) {
- _yamlExcerptLeftBorderChar = _defaultYamlExcerptLeftBorderChar;
- var excerpt = _getExcerptAsString(relativePath, region);
- if (excerpt == null) return null; // Errors have been reported
- log.fine('>> excerpt before xform: "$excerpt"');
- if (_yamlExcerptLeftBorderChar.isNotEmpty) {
- excerpt = _removeLineBorderPrefix(_yamlExcerptLeftBorderChar, excerpt);
- }
- if (t != null) excerpt = t(excerpt);
- final lines = excerpt.split(eol);
- // All excerpts are [eol] terminated, so drop trailing blank lines
- while (lines.isNotEmpty && lines.last == '') {
- lines.removeLast();
- }
- return trimMinLeadingSpace(lines);
- }
-
- String _removeLineBorderPrefix(String borderChar, String excerpt) => excerpt
- .split(eol)
- .map((line) => line.startsWith(_yamlExcerptLeftBorderChar)
- ? line.substring(1)
- : line)
- .join(eol);
-
- /// Look for a fragment file under [fragmentDirPath], failing that look for a
- /// source file under [srcDirPath]. If a file is found return its content as
- /// a string. Otherwise, report an error and return null.
- String? _getExcerptAsString(String relativePath, String region) =>
- excerptsYaml
- ? _getExcerptAsStringFromYaml(relativePath, region)
- : _getExcerptAsStringLegacy(relativePath, region);
-
- /// Potentially assigns to _yamlExcerptLeftBorderChar the
- /// value of the YAML [_yamlExcerptLeftBorderCharKey] key.
- 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;
- }
- }
-
- String? _getExcerptAsStringLegacy(String relativePath, String region) {
- const fragExtension = '.txt';
- final String file;
- if (region.isNotEmpty) {
- final dir = p.dirname(relativePath);
- final basename = p.basenameWithoutExtension(relativePath);
- final ext = p.extension(relativePath);
- file = p.join(dir, '$basename-$region$ext$fragExtension');
- } else {
- file = relativePath + fragExtension;
- }
-
- // First look for a matching fragment
- final fragPath = p.join(fragmentDirPath, pathBase, file);
- try {
- return File(fragPath).readAsStringSync();
- } on FileSystemException {
- if (region != '') {
- _reporter.error('cannot read fragment file "$fragPath"');
- return null;
- }
- // Fall through
- }
-
- // No fragment file file. Look for a source file with a matching file name.
- final srcFilePath = p.join(srcDirPath, pathBase, relativePath);
- try {
- return File(srcFilePath).readAsStringSync();
- } on FileSystemException {
- _reporter.error('cannot find a source file "$srcFilePath", '
- 'nor fragment file "$fragPath"');
- return null;
- }
- }
-}
diff --git a/packages/code_excerpt_updater/lib/src/instr_info.dart b/packages/code_excerpt_updater/lib/src/instr_info.dart
deleted file mode 100644
index fca20d6..0000000
--- a/packages/code_excerpt_updater/lib/src/instr_info.dart
+++ /dev/null
@@ -1,28 +0,0 @@
-/// Representation of an XML processing instruction
-class InstrInfo {
- final String? instruction;
- String linePrefix = '';
-
- InstrInfo(this.instruction);
-
- /// Optional. Currently represents a path + optional region
- String? unnamedArg;
-
- String? _path;
- String get path => _path ?? args['path'] ?? '';
- set path(String p) {
- _path = p;
- }
-
- String? _region;
- set region(String? r) {
- _region = r;
- }
-
- String get region => args['region'] ?? _region ?? '';
-
- final Map args = {};
-
- @override
- String toString() => 'InstrInfo: $linePrefix$instruction; args=$args';
-}
diff --git a/packages/code_excerpt_updater/lib/src/issue_reporter.dart b/packages/code_excerpt_updater/lib/src/issue_reporter.dart
deleted file mode 100644
index dad768a..0000000
--- a/packages/code_excerpt_updater/lib/src/issue_reporter.dart
+++ /dev/null
@@ -1,34 +0,0 @@
-import 'dart:io';
-
-class IssueReporter {
- final IssueContext _ctx;
- final Stdout _stderr;
-
- int numWarnings = 0;
- int numErrors = 0;
-
- IssueReporter(this._ctx, [Stdout? err]) : _stderr = err ?? stderr;
-
- void warn(String msg) {
- numWarnings++;
- return _report('Warning', msg);
- }
-
- void error(String msg) {
- numErrors++;
- return _report('Error', msg);
- }
-
- void _report(String prefix, String msg) =>
- _stderr.writeln('$prefix: ${_ctx.filePath}:${_ctx.lineNum} $msg');
-}
-
-class IssueContext {
- final String Function() _filePath;
- final int Function() _lineNum;
-
- const IssueContext(this._filePath, this._lineNum);
-
- String get filePath => _filePath();
- int get lineNum => _lineNum();
-}
diff --git a/packages/code_excerpt_updater/lib/src/logger.dart b/packages/code_excerpt_updater/lib/src/logger.dart
deleted file mode 100644
index a051bd3..0000000
--- a/packages/code_excerpt_updater/lib/src/logger.dart
+++ /dev/null
@@ -1,14 +0,0 @@
-import 'package:logging/logging.dart';
-
-final Logger log = Logger('CEU');
-
-bool _loggerInitialized = false;
-
-void initLogger([Level? logLevel]) {
- if (_loggerInitialized) return;
- Logger.root.level = logLevel ?? Level.WARNING;
- Logger.root.onRecord.listen((LogRecord rec) {
- print('${rec.level.name}: ${rec.time}: ${rec.message}');
- });
- _loggerInitialized = true;
-}
diff --git a/packages/code_excerpt_updater/lib/src/matcher.dart b/packages/code_excerpt_updater/lib/src/matcher.dart
deleted file mode 100644
index 2092bb0..0000000
--- a/packages/code_excerpt_updater/lib/src/matcher.dart
+++ /dev/null
@@ -1,24 +0,0 @@
-import 'package:logging/logging.dart';
-
-final Logger _log = Logger('CEU.CT');
-
-typedef Matcher = bool Function(String t);
-// typedef Predicate = bool Function(T t);
-
-Matcher not(Matcher p) => (String s) => !p(s);
-
-Matcher patternArgToMatcher(String arg, [String cmd = '']) {
- final Matcher matcher;
- if (arg.startsWith('/') && arg.endsWith('/')) {
- final re = RegExp(arg.substring(1, arg.length - 1));
- _log.finest(' >> $cmd arg: "$arg" used as regexp $re');
- matcher = re.hasMatch;
- } else {
- final stringToMatch = arg.startsWith(r'\/')
- ? arg.substring(1) // TODO: process other escaped characters
- : arg;
- _log.finest(' >> $cmd arg: "$stringToMatch" is used as a string matcher');
- matcher = (s) => s.contains(stringToMatch);
- }
- return matcher;
-}
diff --git a/packages/code_excerpt_updater/lib/src/util.dart b/packages/code_excerpt_updater/lib/src/util.dart
deleted file mode 100644
index 4f80141..0000000
--- a/packages/code_excerpt_updater/lib/src/util.dart
+++ /dev/null
@@ -1,74 +0,0 @@
-import 'dart:math';
-
-import 'constants.dart';
-
-/// String to int conversion
-int? toInt(String? s, {int radix = 10, int? errorValue}) {
- if (s == null) {
- return errorValue;
- }
- try {
- return int.parse(s, radix: radix);
- } on FormatException {
- return errorValue;
- }
-}
-
-//-----------------------------------------------------------------------------
-
-final _blankLineRegEx = RegExp(r'^\s*$');
-final _leadingWhitespaceRegEx = RegExp(r'^[ \t]*');
-
-Iterable trimMinLeadingSpace(Iterable lines) {
- final nonBlankLines = lines.where((s) => !_blankLineRegEx.hasMatch(s));
-
- // Length of leading spaces to be trimmed
- final lengths = nonBlankLines.map((s) {
- final matchLength = _leadingWhitespaceRegEx.firstMatch(s)?[0]?.length;
- return matchLength ?? 0;
- });
-
- if (lengths.isEmpty) {
- return lines;
- }
-
- final len = lengths.reduce(min);
- return len == 0
- ? lines
- : lines.map((line) => line.length < len ? line : line.substring(len));
-}
-
-//-----------------------------------------------------------------------------
-// TODO: consider writing the following conversions as a string transformer.
-
-final escapedSlashRE = RegExp(r'\\/');
-
-final _slashHexCharRE = RegExp(r'\\x(..)');
-final _slashLetterRE = RegExp(r'\\([\\nt])');
-
-/// Encode special characters: '\t', `\n`, and `\xHH` where `HH` are hex digits.
-String encodeSlashChar(String s) => s
- .replaceAllMapped(_slashLetterRE, (Match m) => _slashCharToChar(m[1]))
- // At this point, escaped `\` is encoded as [zeroChar].
- .replaceAllMapped(_slashHexCharRE,
- (Match m) => _hexToChar(m[1], errorValue: '\\x${m[1]}'))
- // Recover `\` characters.
- .replaceAll(zeroChar, backslash);
-
-String _hexToChar(String? hexDigits, {required String errorValue}) {
- final charCode = toInt(hexDigits, radix: 16);
- return charCode == null ? errorValue : String.fromCharCode(charCode);
-}
-
-String _slashCharToChar(String? char) {
- switch (char) {
- case 'n':
- return '\n';
- case 't':
- return '\t';
- case backslash:
- return zeroChar;
- default:
- return '\\$char';
- }
-}
diff --git a/packages/code_excerpt_updater/mono_pkg.yaml b/packages/code_excerpt_updater/mono_pkg.yaml
deleted file mode 100644
index d4e257b..0000000
--- a/packages/code_excerpt_updater/mono_pkg.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-# See https://github.com/google/mono_repo.dart for details on this file
-sdk:
-- pubspec
-- dev
-
-stages:
-- analyzer_and_format:
- - group:
- - format
- - analyze: --fatal-infos .
-- unit_test:
- - test:
diff --git a/packages/code_excerpt_updater/pubspec.yaml b/packages/code_excerpt_updater/pubspec.yaml
deleted file mode 100644
index 6fc9b85..0000000
--- a/packages/code_excerpt_updater/pubspec.yaml
+++ /dev/null
@@ -1,18 +0,0 @@
-name: code_excerpt_updater
-publish_to: none
-
-environment:
- sdk: ^3.4.0
-
-dependencies:
- args: ^2.4.2
- collection: ^1.18.0
- logging: ^1.2.0
- path: ^1.9.0
- yaml: ^3.1.2
-
-dev_dependencies:
- analysis_defaults:
- path: ../analysis_defaults
- mockito: ^5.4.4
- test: ^1.25.2
diff --git a/packages/code_excerpt_updater/test/diff_test.dart b/packages/code_excerpt_updater/test/diff_test.dart
deleted file mode 100644
index 06c7a03..0000000
--- a/packages/code_excerpt_updater/test/diff_test.dart
+++ /dev/null
@@ -1,121 +0,0 @@
-import 'package:code_excerpt_updater/src/diff/diff.dart';
-import 'package:code_excerpt_updater/src/matcher.dart';
-import 'package:test/test.dart';
-
-import 'hunk_test.dart';
-
-final diff1head = '''
---- 1-base/lib/main.dart
-+++ 2-use-package/lib/main.dart
-'''
- .trim();
-
-final diff1 = '$diff1head\n$hunk1';
-
-final diff1TrimmedBefore = '$diff1head\n$hunk1TrimmedBefore';
-final diff1TrimmedBeforeAndAfter = '$diff1head\n$hunk1TrimmedBeforeAndAfter';
-
-/// A diff with two hunks
-final diff2 = '$diff1\n$hunk2';
-
-void main() {
- final matchClass = patternArgToMatcher('/^ class/');
- final matchReturn = patternArgToMatcher(r'/^\s+return/');
- final wontMatch = patternArgToMatcher('will not match');
-
- group('Idempotence on src', () {
- test('Empty diff', () {
- expect(Diff('').toString(), '');
- });
-
- test('Diff with one hunk', () {
- final d = Diff(diff1);
- expect(d.toString(), diff1);
- });
-
- test('Diff with more than one hunk', () {
- final d = Diff(diff2);
- expect(d.toString(), diff2);
- });
- });
-
- group('Diff with one hunk:', () {
- late Diff d;
-
- setUp(() => d = Diff(diff1));
-
- group('Skip before "class":', () {
- test('dropLinesUntil', () {
- expect(d.dropLinesUntil(matchClass), true);
- expect(d.toString(), diff1TrimmedBefore);
- });
-
- test('dropLines', () {
- expect(d.keepLines(from: matchClass), true);
- expect(d.toString(), diff1TrimmedBefore);
- });
- });
-
- group('Skip before "class" until "return":', () {
- test('dropLinesUntil/dropLinesAfter', () {
- expect(d.dropLinesUntil(matchClass), true);
- expect(d.dropLinesAfter(matchReturn), true);
- expect(d.toString(), diff1TrimmedBeforeAndAfter);
- });
-
- test('dropLines', () {
- expect(d.keepLines(from: matchClass, to: matchReturn), true);
- expect(d.toString(), diff1TrimmedBeforeAndAfter);
- });
- });
-
- group('Skip all:', () {
- test('dropLinesUntil', () {
- expect(d.dropLinesUntil(wontMatch), false);
- expect(d.toString(), diff1head);
- });
-
- test('dropLines', () {
- expect(d.keepLines(from: wontMatch), false);
- expect(d.toString(), diff1head);
- });
- });
- });
-
- group('Diff with 2 hunks:', () {
- final d = Diff(diff2);
-
- group('Skip before "class":', () {
- test('dropLinesUntil', () {
- expect(d.dropLinesUntil(matchClass), true);
- expect(d.toString(), '$diff1TrimmedBefore\n$hunk2');
- });
-
- test('dropLines', () {
- expect(d.keepLines(from: matchClass), true);
- expect(d.toString(), '$diff1TrimmedBefore\n$hunk2');
- });
- });
-
- test('Diff2: Skip before "class" until "return"', () {
- expect(d.keepLines(from: matchClass, to: matchReturn), true);
- expect(d.toString(), diff1TrimmedBeforeAndAfter);
- });
- });
-
- test('Diff using to regexp but no from regexp', () {
- final d = Diff('$diff1head\n$hunk2');
- expect(d.keepLines(to: patternArgToMatcher(r'/^\+\s+child:/')), true);
- expect(d.toString(), '$diff1head\n$hunk2Trimmed');
- });
-}
-
-final hunk2Trimmed = '''
-@@ -12,4 +14,4 @@
- title: Text('Welcome to Flutter'),
- ),
- body: Center(
-- child: Text('Hello World'),
-+ child: Text(wordPair.asPascalCase),
-'''
- .trim();
diff --git a/packages/code_excerpt_updater/test/excerpt_getter_test.dart b/packages/code_excerpt_updater/test/excerpt_getter_test.dart
deleted file mode 100644
index 511d1b4..0000000
--- a/packages/code_excerpt_updater/test/excerpt_getter_test.dart
+++ /dev/null
@@ -1,50 +0,0 @@
-import 'package:code_excerpt_updater/src/excerpt_getter.dart';
-import 'package:code_excerpt_updater/src/issue_reporter.dart';
-import 'package:test/test.dart';
-
-const _testDir = 'test_data';
-
-void main() {
- const excerptsYaml = true;
- const fragmentDirPath = '$_testDir/excerpt_yaml';
- const srcDirPath = fragmentDirPath;
- final issueReporter =
- IssueReporter(IssueContext(() => 'unused/path/to/file', () => 1));
-
- late ExcerptGetter eg;
-
- setUpAll(() {
- eg = ExcerptGetter(
- excerptsYaml,
- fragmentDirPath,
- srcDirPath,
- issueReporter,
- )..pathBase = '';
- });
-
- test('sanity', () {
- final excerpt = eg.getExcerpt('excerpt_getter.dart', 'main');
- final code = [r"void main() => print('$greeting $scope');"];
- expect(excerpt, code);
- });
-
- test('trim trailing blank lines', () {
- final excerpt =
- eg.getExcerpt('excerpt_getter.dart', 'trailing blank lines');
- final code = [r"var greeting = 'hello';"];
- expect(excerpt, code);
- });
-
- test('main with border', () {
- final excerpt = eg.getExcerpt('excerpt_getter_with_border.dart', 'main');
- final code = [r"void main() => print('$greeting $scope');"];
- expect(excerpt, code);
- });
-
- test('trailing blank lines with border', () {
- final excerpt = eg.getExcerpt(
- 'excerpt_getter_with_border.dart', 'trailing blank lines');
- final code = [r"var greeting = 'hello';"];
- expect(excerpt, code);
- });
-}
diff --git a/packages/code_excerpt_updater/test/hunk_test.dart b/packages/code_excerpt_updater/test/hunk_test.dart
deleted file mode 100644
index 3687055..0000000
--- a/packages/code_excerpt_updater/test/hunk_test.dart
+++ /dev/null
@@ -1,107 +0,0 @@
-import 'package:code_excerpt_updater/src/diff/hunk.dart';
-import 'package:code_excerpt_updater/src/matcher.dart';
-import 'package:test/test.dart';
-
-const hunk0 = '''
-@@ -1,10 +1,12 @@
- import 'package:flutter/material.dart';
-+import 'package:english_words/english_words.dart';
-
- void main() => runApp(MyApp());
-
-''';
-
-final hunk0ExtraBody1 = '''
- class MyApp extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
-+ final wordPair = WordPair.random();
- return MaterialApp(
-'''
- .trimRight();
-
-final hunk0ExtraBody2 = '''
- title: 'Welcome to Flutter',
- home: Scaffold(
-'''
- .trimRight();
-
-final hunk0ExtraBody = '$hunk0ExtraBody1\n$hunk0ExtraBody2';
-
-final hunk1 = '$hunk0$hunk0ExtraBody';
-
-final hunk1TrimmedBefore = '@@ -5,6 +6,7 @@\n$hunk0ExtraBody';
-final hunk1TrimmedBeforeAndAfter = '@@ -5,4 +6,5 @@\n$hunk0ExtraBody1';
-
-final hunk2 = '''
-@@ -12,7 +14,7 @@
- title: Text('Welcome to Flutter'),
- ),
- body: Center(
-- child: Text('Hello World'),
-+ child: Text(wordPair.asPascalCase),
- ),
- ),
- );
-'''
- .trim();
-
-void main() {
- group('basic hunk 1', () {
- late Hunk h;
-
- setUp(() {
- h = Hunk(hunk1);
- });
-
- test('Idempotence on src', () {
- expect(h.toString(), hunk1);
- });
-
- test('Line info', () {
- expect(h.start(0), 1);
- expect(h.start(1), 1);
- expect(h.length(0), 10);
- expect(h.length(1), 12);
-
- expect(() => h.start(2), throwsA(isA()));
- expect(() => h.length(2), throwsA(isA()));
- });
-
- test('Skip before "class"', () {
- expect(h.dropLinesUntil(patternArgToMatcher('/^ class/')), true);
- expect(h.toString(), hunk1TrimmedBefore);
- });
-
- test('Skip before "class" until "return"', () {
- expect(h.dropLinesUntil(patternArgToMatcher('/^ class/')), true);
- expect(h.dropLinesAfter(patternArgToMatcher(r'/^\s+return/')), true);
- expect(h.toString(), hunk1TrimmedBeforeAndAfter);
- });
- });
-
- group('basic hunk 2', () {
- late Hunk h;
-
- setUp(() {
- h = Hunk(hunk2);
- });
-
- test('Idempotence on src', () {
- expect(h.toString(), hunk2);
- });
-
- test('Line info', () {
- expect(h.start(0), 12);
- expect(h.start(1), 14);
- expect(h.length(0), 7);
- expect(h.length(1), 7);
- });
-
- test('Skip before w/o match', () {
- final skipped = h.dropLinesUntil(patternArgToMatcher('xx'));
- expect(skipped, false);
- expect(h.toString(), hunk2);
- });
- });
-}
diff --git a/packages/code_excerpt_updater/test/main_test.dart b/packages/code_excerpt_updater/test/main_test.dart
deleted file mode 100644
index 6f25f52..0000000
--- a/packages/code_excerpt_updater/test/main_test.dart
+++ /dev/null
@@ -1,251 +0,0 @@
-// Copyright (c) 2017. All rights reserved. Use of this source code
-// is governed by a MIT-style license that can be found in the LICENSE file.
-
-import 'dart:io';
-
-import 'package:code_excerpt_updater/src/code_excerpt_updater.dart';
-import 'package:mockito/mockito.dart';
-import 'package:path/path.dart' as p;
-import 'package:test/test.dart';
-
-const _testDir = 'test_data';
-
-// TODO: enhance tests so that we can inspect the generated error messages.
-// It might be easier to modify the updater to use an IOSink than to try to read
-// stderr.
-
-late Updater updater;
-late Stdout _stderr;
-
-String _readFile(String path) => File(path).readAsStringSync();
-
-String _srcFileName2Path(String fileName) => p.join(_testDir, 'src', fileName);
-String _expectedFn2Path(String relPath) =>
- p.join(_testDir, 'expected', relPath);
-
-String getSrc(String relPath) => _readFile(_srcFileName2Path(relPath));
-String getExpected(String relPath) => _readFile(_expectedFn2Path(relPath));
-
-const Map _errorMessages = {
- 'no_change/frag_not_found.dart':
- 'Error: test_data/src/no_change/frag_not_found.dart:2 '
- 'cannot find a source file "test_data/diff_src/dne.xzy", '
- 'nor fragment file "test_data/frag/dne.xzy.txt"',
- 'no_change/invalid_code_block.dart':
- 'Error: test_data/src/no_change/invalid_code_block.dart:5 '
- 'unterminated markdown code block for ',
- 'no_change/invalid_code_excerpt_arg.dart':
- 'Warning: test_data/src/no_change/invalid_code_excerpt_arg.dart:1 '
- 'instruction ignored: unrecognized set instruction argument: '
- '/// ',
- 'no_change/missing_code_block.dart':
- 'Error: test_data/src/no_change/missing_code_block.dart:3 '
- 'code block should immediately follow - "quote.md"\n'
- ' not: int x = 0;',
- 'no_change/diff.md': 'Error: test_data/src/no_change/diff.md:86 '
- 'You can\'t use both the brace syntax and the diff-with argument; '
- 'choose one or the other.',
-};
-
-void _stdFileTest(String testFilePath) {
- // print('>> testing $testFilePath');
- final testFileName = p.basename(testFilePath);
- test(testFileName, () {
- final testFileRelativePath = testFilePath;
- // var originalSrc = getSrc(testFileRelativePath);
- // print('>> ${_srcFileName2Path(testFileRelativePath)}');
- final updatedDocs =
- updater.generateUpdatedFile(_srcFileName2Path(testFileRelativePath));
- // print('>> updatedDocs: ${updatedDocs}');
-
- final expectedErr = _errorMessages[testFilePath];
- if (expectedErr == null) {
- verifyZeroInteractions(_stderr);
- expect(updater.numErrors, 0);
- } else {
- final vr = verify(_stderr.writeln(captureAny));
- expect(vr.captured.join(';'), expectedErr);
- final isWarning = expectedErr.startsWith('Warn');
- expect(updater.numErrors, isWarning ? 0 : 1);
- expect(updater.numWarnings, isWarning ? 1 : 0);
- }
-
- final expectedDoc = File(_expectedFn2Path(testFilePath)).existsSync()
- ? getExpected(testFilePath)
- : getSrc(testFilePath);
- expect(updatedDocs, expectedDoc);
- });
-}
-
-class MockStderr extends Mock implements Stdout {}
-
-void main() {
- group('Basic:', testsFromDefaultDir);
- group('Set path:', testSetPath);
- group('Default indentation:', testDefaultIndentation);
- group('Disable escape ng interpolation:', testNoEscapeNgInterpolation);
- group('Excerpt from src:', testSrcButNoFrag);
- group('Excerpt YAML:', testExcerptYaml);
-
- test('Replace command line option: invalid expression', () {
- try {
- Updater(p.join(_testDir, 'frag'), p.join(_testDir, 'diff_src'),
- globalReplaceExpr: 'invalidReplaceExpr', err: _stderr);
- } catch (e) {
- expect(
- e.toString(),
- 'Exception: Command line replace expression'
- ' is invalid: invalidReplaceExpr');
- return;
- }
- expect(true, false);
- });
-
- group('Replace command line option:', testReplaceCmdLineOption);
-}
-
-void testReplaceCmdLineOption() {
- const replaceExpr = r'/mundo/$&!/g';
-
- setUp(() {
- clearInteractions(_stderr);
- updater = Updater(p.join(_testDir, 'frag'), '',
- globalReplaceExpr: replaceExpr, err: _stderr);
- });
-
- _stdFileTest('replace.md');
-}
-
-void testsFromDefaultDir() {
- setUp(() {
- _stderr = MockStderr();
- updater = Updater(p.join(_testDir, 'frag'), p.join(_testDir, 'diff_src'),
- err: _stderr);
- });
-
- group('No change to doc;', () {
- setUp(() => clearInteractions(_stderr));
-
- final testFileNames = [
- 'basic_diff.dart',
- 'basic_no_region.dart',
- 'basic_with_args.md',
- 'basic_with_region.dart',
- 'dartdoc.md',
- 'diff.md',
- 'frag_not_found.dart',
- 'invalid_code_block.dart',
- 'invalid_code_excerpt_arg.dart',
- 'missing_code_block.dart',
- 'no_comment_prefix.md',
- 'no_path.md',
- 'no_src.dart',
- 'prettify.md',
- 'skip-and-take.md',
- ].map((fn) => p.join('no_change', fn));
-
- testFileNames.forEach(_stdFileTest);
- });
-
- group('Code updates;', () {
- final testFileNames = [
- 'arg-order.md',
- 'basic_no_region.dart',
- 'basic_with_empty_region.md',
- 'basic_with_region.dart',
- 'dartdoc.md',
- 'escape_ng_interpolation.md',
- 'fragment-indentation.md',
- 'language-tour.md',
- 'list.md',
- 'no_comment_prefix.md',
- 'prettify.md',
- 'remove.md',
- 'retain.md',
- ];
-
- testFileNames.forEach(_stdFileTest);
- });
-
- group('Handle trailing space;', () {
- test('ensure input file has expected trailing whitespace', () {
- final fragPath = p.join(
- updater.fragmentDirPath, 'frag_with_trailing_whitespace.dart.txt');
- final frag = _readFile(fragPath);
- expect(frag.endsWith('\t \n\n'), isTrue);
- });
-
- _stdFileTest('trim.dart');
- });
-}
-
-void testSetPath() {
- setUp(() {
- updater = Updater(p.join(_testDir, ''), p.join(_testDir, ''), err: _stderr);
- });
-
- _stdFileTest('set_path.md');
-}
-
-void testDefaultIndentation() {
- setUp(() {
- updater = Updater(p.join(_testDir, 'frag'), p.join(_testDir, 'diff_src'),
- defaultIndentation: 2, err: _stderr);
- });
-
- // Diffs are unaffected by the indentation setting.
- _stdFileTest(p.join('no_change', 'basic_diff.dart'));
- _stdFileTest('basic_with_region.jade');
-}
-
-void testNoEscapeNgInterpolation() {
- setUp(() {
- updater = Updater(p.join(_testDir, 'frag'), p.join(_testDir, 'diff_src'),
- escapeNgInterpolation: false);
- });
-
- _stdFileTest('no_escape_ng_interpolation.md');
-}
-
-void testSrcButNoFrag() {
- setUp(() {
- updater =
- Updater(p.join(_testDir, 'fragDNE'), p.join(_testDir, 'diff_src'));
- });
-
- _stdFileTest('src_but_no_frag.md');
-}
-
-void testExcerptYaml() {
- final fragAndSrcPath = p.join(_testDir, 'excerpt_yaml');
-
- group('defaults:', () {
- setUp(() {
- updater = Updater(
- fragAndSrcPath,
- fragAndSrcPath,
- excerptsYaml: true,
- );
- });
-
- final testFileNames = [
- 'excerpt_yaml.md',
- 'plaster.md',
- ];
-
- testFileNames.forEach(_stdFileTest);
- });
-
- group('globally change default plaster', () {
- setUp(() {
- updater = Updater(
- fragAndSrcPath,
- fragAndSrcPath,
- excerptsYaml: true,
- globalPlasterTemplate: r'// Insert your code here $defaultPlaster',
- );
- });
-
- _stdFileTest('plaster-global-option.md');
- });
-}
diff --git a/packages/code_excerpt_updater/test_data/diff_src/0-base/basic.dart b/packages/code_excerpt_updater/test_data/diff_src/0-base/basic.dart
deleted file mode 100644
index 8adf2d2..0000000
--- a/packages/code_excerpt_updater/test_data/diff_src/0-base/basic.dart
+++ /dev/null
@@ -1,4 +0,0 @@
-var _greeting = 'hello';
-var _scope = 'world';
-
-void main() => print('$_greeting $_scope');
diff --git a/packages/code_excerpt_updater/test_data/diff_src/0-base/docregion.dart b/packages/code_excerpt_updater/test_data/diff_src/0-base/docregion.dart
deleted file mode 100644
index e9acc49..0000000
--- a/packages/code_excerpt_updater/test_data/diff_src/0-base/docregion.dart
+++ /dev/null
@@ -1,16 +0,0 @@
-var _greeting = 'hello';
-var _scope = 'world';
-
-/// Some
-/// doc
-/// comment
-/// lines
-/// to
-/// ensure
-/// we
-/// get
-/// two
-/// diff
-/// hunks
-// #docregion main
-void main() => print('$_greeting $_scope');
diff --git a/packages/code_excerpt_updater/test_data/diff_src/1-step/basic.dart b/packages/code_excerpt_updater/test_data/diff_src/1-step/basic.dart
deleted file mode 100644
index 605e13b..0000000
--- a/packages/code_excerpt_updater/test_data/diff_src/1-step/basic.dart
+++ /dev/null
@@ -1,4 +0,0 @@
-var _greeting = 'bonjour';
-var _scope = 'world';
-
-void main() => print('$_greeting $_scope');
diff --git a/packages/code_excerpt_updater/test_data/diff_src/1-step/docregion.dart b/packages/code_excerpt_updater/test_data/diff_src/1-step/docregion.dart
deleted file mode 100644
index 5d4c5a1..0000000
--- a/packages/code_excerpt_updater/test_data/diff_src/1-step/docregion.dart
+++ /dev/null
@@ -1,16 +0,0 @@
-var _greeting = 'bonjour';
-var _scope = 'world';
-
-/// Some
-/// doc
-/// comment
-/// lines
-/// to
-/// ensure
-/// we
-/// get
-/// two
-/// diff
-/// hunks
-// #docregion main
-void main() => print('$_greeting $_scope!');
diff --git a/packages/code_excerpt_updater/test_data/excerpt_yaml/basic.dart b/packages/code_excerpt_updater/test_data/excerpt_yaml/basic.dart
deleted file mode 100644
index 177edf6..0000000
--- a/packages/code_excerpt_updater/test_data/excerpt_yaml/basic.dart
+++ /dev/null
@@ -1,7 +0,0 @@
-// #docregion var
-var greeting = 'hello';
-var scope = 'world';
-// #enddocregion var
-
-// #docregion main
-void main() => print('$greeting $scope');
diff --git a/packages/code_excerpt_updater/test_data/excerpt_yaml/basic.dart.excerpt.yaml b/packages/code_excerpt_updater/test_data/excerpt_yaml/basic.dart.excerpt.yaml
deleted file mode 100644
index 7b04e9c..0000000
--- a/packages/code_excerpt_updater/test_data/excerpt_yaml/basic.dart.excerpt.yaml
+++ /dev/null
@@ -1,10 +0,0 @@
-'': |+
- var greeting = 'hello';
- var scope = 'world';
-
- void main() => print('$greeting $scope');
-'var': |+
- var greeting = 'hello';
- var scope = 'world';
-'main': |+
- void main() => print('$greeting $scope');
diff --git a/packages/code_excerpt_updater/test_data/excerpt_yaml/basic_0.dart b/packages/code_excerpt_updater/test_data/excerpt_yaml/basic_0.dart
deleted file mode 100644
index ca01698..0000000
--- a/packages/code_excerpt_updater/test_data/excerpt_yaml/basic_0.dart
+++ /dev/null
@@ -1,4 +0,0 @@
-var greeting = 'hello';
-var scope = 'world';
-
-void main() => print('$greeting $scope');
diff --git a/packages/code_excerpt_updater/test_data/excerpt_yaml/excerpt_getter.dart.excerpt.yaml b/packages/code_excerpt_updater/test_data/excerpt_yaml/excerpt_getter.dart.excerpt.yaml
deleted file mode 100644
index c765c9c..0000000
--- a/packages/code_excerpt_updater/test_data/excerpt_yaml/excerpt_getter.dart.excerpt.yaml
+++ /dev/null
@@ -1,6 +0,0 @@
-'trailing blank lines': |+
- var greeting = 'hello';
-
-
-'main': |+
- void main() => print('$greeting $scope');
diff --git a/packages/code_excerpt_updater/test_data/excerpt_yaml/excerpt_getter_with_border.dart.excerpt.yaml b/packages/code_excerpt_updater/test_data/excerpt_yaml/excerpt_getter_with_border.dart.excerpt.yaml
deleted file mode 100644
index b036141..0000000
--- a/packages/code_excerpt_updater/test_data/excerpt_yaml/excerpt_getter_with_border.dart.excerpt.yaml
+++ /dev/null
@@ -1,7 +0,0 @@
-'#border': '|'
-'main': |+
- |void main() => print('$greeting $scope');
-'trailing blank lines': |+
- |var greeting = 'hello';
- |
- |
diff --git a/packages/code_excerpt_updater/test_data/excerpt_yaml/plaster.css.excerpt.yaml b/packages/code_excerpt_updater/test_data/excerpt_yaml/plaster.css.excerpt.yaml
deleted file mode 100644
index 382fa1d..0000000
--- a/packages/code_excerpt_updater/test_data/excerpt_yaml/plaster.css.excerpt.yaml
+++ /dev/null
@@ -1,4 +0,0 @@
-'': |+
- .abc {}
- ···
- .def {}
diff --git a/packages/code_excerpt_updater/test_data/excerpt_yaml/plaster.dart.excerpt.yaml b/packages/code_excerpt_updater/test_data/excerpt_yaml/plaster.dart.excerpt.yaml
deleted file mode 100644
index be2d672..0000000
--- a/packages/code_excerpt_updater/test_data/excerpt_yaml/plaster.dart.excerpt.yaml
+++ /dev/null
@@ -1,8 +0,0 @@
-'': |+
- var greeting = 'hello';
- ···
- var scope = 'world';
-'html': |+
-
- ···
-
diff --git a/packages/code_excerpt_updater/test_data/excerpt_yaml/plaster.html.excerpt.yaml b/packages/code_excerpt_updater/test_data/excerpt_yaml/plaster.html.excerpt.yaml
deleted file mode 100644
index dd21524..0000000
--- a/packages/code_excerpt_updater/test_data/excerpt_yaml/plaster.html.excerpt.yaml
+++ /dev/null
@@ -1,4 +0,0 @@
-'': |+
-
- ···
-
diff --git a/packages/code_excerpt_updater/test_data/excerpt_yaml/plaster.txt.excerpt.yaml b/packages/code_excerpt_updater/test_data/excerpt_yaml/plaster.txt.excerpt.yaml
deleted file mode 100644
index 74544da..0000000
--- a/packages/code_excerpt_updater/test_data/excerpt_yaml/plaster.txt.excerpt.yaml
+++ /dev/null
@@ -1,4 +0,0 @@
-'': |+
- abc
- ···
- def
diff --git a/packages/code_excerpt_updater/test_data/excerpt_yaml/plaster.yaml.excerpt.yaml b/packages/code_excerpt_updater/test_data/excerpt_yaml/plaster.yaml.excerpt.yaml
deleted file mode 100644
index 636499a..0000000
--- a/packages/code_excerpt_updater/test_data/excerpt_yaml/plaster.yaml.excerpt.yaml
+++ /dev/null
@@ -1,4 +0,0 @@
-'': |+
- abc:
- ···
- def
diff --git a/packages/code_excerpt_updater/test_data/expected/arg-order.md b/packages/code_excerpt_updater/test_data/expected/arg-order.md
deleted file mode 100644
index 1d87b5a..0000000
--- a/packages/code_excerpt_updater/test_data/expected/arg-order.md
+++ /dev/null
@@ -1,10 +0,0 @@
-## Test arg order
-
-
-```
-var greeting = 'bonjour';
-```
-
-
-```
-```
diff --git a/packages/code_excerpt_updater/test_data/expected/basic_no_region.dart b/packages/code_excerpt_updater/test_data/expected/basic_no_region.dart
deleted file mode 100644
index c934dbf..0000000
--- a/packages/code_excerpt_updater/test_data/expected/basic_no_region.dart
+++ /dev/null
@@ -1,27 +0,0 @@
-/// No region arguments in this file.
-library;
-
-/// Test: no code in code block, directive w/o indentation
-///
-/// ```html
-///
-///
Hello World!
-///
-/// ```
-int? basic1;
-
-/// Test: no code in code block, directive with indentation
-///
-/// ```dart
-/// var greeting = 'hello';
-/// var scope = 'world';
-/// ```
-num? basic2;
-
-/// Test: out-of-date code in code block, directive with indentation
-///
-/// ```dart
-/// var greeting = 'hello';
-/// var scope = 'world';
-/// ```
-dynamic basic3;
diff --git a/packages/code_excerpt_updater/test_data/expected/basic_with_empty_region.md b/packages/code_excerpt_updater/test_data/expected/basic_with_empty_region.md
deleted file mode 100644
index ad10854..0000000
--- a/packages/code_excerpt_updater/test_data/expected/basic_with_empty_region.md
+++ /dev/null
@@ -1,16 +0,0 @@
-Test: empty region
-
-
-```dart
-var greeting = 'hello';
-var scope = 'world';
-```
-
-The full file, because an empty region overrides the parenthetical remark in the path/title:
-
-```dart
-var greeting = 'hello';
-var scope = 'world';
-
-void main() => print('$greeting $scope');
-```
diff --git a/packages/code_excerpt_updater/test_data/expected/basic_with_region.dart b/packages/code_excerpt_updater/test_data/expected/basic_with_region.dart
deleted file mode 100644
index 9d04f09..0000000
--- a/packages/code_excerpt_updater/test_data/expected/basic_with_region.dart
+++ /dev/null
@@ -1,23 +0,0 @@
-/// Test: no code in code block, directive with indentation
-///
-/// ```dart
-/// var greeting = 'hello';
-/// var scope = 'world';
-/// ```
-void f() {}
-
-/// Test: region name in path.
-///
-/// ```dart
-/// var greeting = 'hello';
-/// var scope = 'world';
-/// ```
-class D {}
-
-/// Test: region name in path.
-///
-/// ```dart
-/// var greeting = 'hello';
-/// var scope = 'world';
-/// ```
-class E {}
diff --git a/packages/code_excerpt_updater/test_data/expected/basic_with_region.jade b/packages/code_excerpt_updater/test_data/expected/basic_with_region.jade
deleted file mode 100644
index f22b024..0000000
--- a/packages/code_excerpt_updater/test_data/expected/basic_with_region.jade
+++ /dev/null
@@ -1,30 +0,0 @@
-:marked
- Test:
- - Jade file
- - Global indentation setting
- - Valueless instruction argument (`title`).
-
-
- ```dart
- var greeting = 'hello';
- var scope = 'world';
- ```
-
- Test that region argument takes precedence over string in parentheses:
-
- ```
- var greeting = 'hello';
- var scope = 'world';
- ```
-
-
- ```
- var greeting = 'hello';
- var scope = 'world';
- ```
-
-
- ```
- var greeting = 'hello';
- var scope = 'world';
- ```
diff --git a/packages/code_excerpt_updater/test_data/expected/dartdoc.md b/packages/code_excerpt_updater/test_data/expected/dartdoc.md
deleted file mode 100644
index 5c08223..0000000
--- a/packages/code_excerpt_updater/test_data/expected/dartdoc.md
+++ /dev/null
@@ -1,12 +0,0 @@
-## API docs
-
-Markdown code block opened and closed with more than 3 backticks
-that contains another Markdown code block declared with just 3.
-
-
-````dart
-/// ```html
-/// HTML is magical!
-/// ```
-class HTML {}
-````
diff --git a/packages/code_excerpt_updater/test_data/expected/escape_ng_interpolation.md b/packages/code_excerpt_updater/test_data/expected/escape_ng_interpolation.md
deleted file mode 100644
index b5253fa..0000000
--- a/packages/code_excerpt_updater/test_data/expected/escape_ng_interpolation.md
+++ /dev/null
@@ -1,6 +0,0 @@
-
-```
-
-
Hello {!{name}!}!
-
-```
diff --git a/packages/code_excerpt_updater/test_data/expected/excerpt_yaml.md b/packages/code_excerpt_updater/test_data/expected/excerpt_yaml.md
deleted file mode 100644
index feda383..0000000
--- a/packages/code_excerpt_updater/test_data/expected/excerpt_yaml.md
+++ /dev/null
@@ -1,19 +0,0 @@
-## Excerpt-yaml tests
-
-Excerpt:
-
-
-```
-var greeting = 'hello';
-var scope = 'world';
-```
-
-Excerpt full source for which there is no `.excerpt.yaml` file.
-
-
-```
-var greeting = 'hello';
-var scope = 'world';
-
-void main() => print('$greeting $scope');
-```
diff --git a/packages/code_excerpt_updater/test_data/expected/fragment-indentation.md b/packages/code_excerpt_updater/test_data/expected/fragment-indentation.md
deleted file mode 100644
index 1a5bf61..0000000
--- a/packages/code_excerpt_updater/test_data/expected/fragment-indentation.md
+++ /dev/null
@@ -1,20 +0,0 @@
-## Test: code fragment should be unindented
-
-
-```
-// Fragment is indented by 4 spaces
-var x = 1;
-return x;
-```
-
-## Test: code fragment should be unindented
-
-
-```
- // Fragment is indented by 4 spaces
- var x = 1;
-
-/* ... */
- return x;
- /* ... */
-```
diff --git a/packages/code_excerpt_updater/test_data/expected/language-tour.md b/packages/code_excerpt_updater/test_data/expected/language-tour.md
deleted file mode 100644
index 62ddc5c..0000000
--- a/packages/code_excerpt_updater/test_data/expected/language-tour.md
+++ /dev/null
@@ -1,47 +0,0 @@
-## Basic prettify tests
-
-### Without arguments
-
-
-{% prettify %}
-This is a **markdown** fragment.
-{% endprettify %}
-
-### With language argument
-
-
-{% prettify dart %}
-var greeting = 'hello';
-var scope = 'world';
-{% endprettify %}
-
-
-{% prettify html %}
-
-
Hello World!
-
-{% endprettify %}
-
-### With other arguments
-
-
-{% prettify html tag="code" %}
-
-
Hello World!
-
-{% endprettify %}
-
-### With strip-whitespace syntax
-
-
-{% prettify html tag="code+br" -%}
-
-
Hello World!
-
-{%- endprettify %}
-
-
-{%- prettify dart -%}
-var greeting = 'hello';
-var scope = 'world';
-{%- endprettify -%}
diff --git a/packages/code_excerpt_updater/test_data/expected/list.md b/packages/code_excerpt_updater/test_data/expected/list.md
deleted file mode 100644
index d18cd1d..0000000
--- a/packages/code_excerpt_updater/test_data/expected/list.md
+++ /dev/null
@@ -1,34 +0,0 @@
-## Test instructions in markdown lists
-
--
- ```
- // Fragment is indented by 4 spaces
- var x = 1;
- return x;
- ```
-
-*
- ```
- // Fragment is indented by 4 spaces
- var x = 1;
-
- /* ... */
- return x;
- /* ... */
- ```
-
-- Some text
-
- ```
- // Fragment is indented by 4 spaces
- var x = 1;
- return x;
- ```
-
-* Nested list item next:
- -
- ```
- // Fragment is indented by 4 spaces
- var x = 1;
- return x;
- ```
diff --git a/packages/code_excerpt_updater/test_data/expected/no_comment_prefix.md b/packages/code_excerpt_updater/test_data/expected/no_comment_prefix.md
deleted file mode 100644
index e77bd00..0000000
--- a/packages/code_excerpt_updater/test_data/expected/no_comment_prefix.md
+++ /dev/null
@@ -1,20 +0,0 @@
-## Test: no code in code block, directive w/o indentation
-
-
-```
-This is a **markdown** fragment.
-```
-
-## Test: no code in code block, directive with indentation
-
-
-```
- This is a **markdown** fragment.
-```
-
-## Test: out-of-date code in code block, directive with indentation
-
-
-```
- This is a **markdown** fragment.
-```
diff --git a/packages/code_excerpt_updater/test_data/expected/no_escape_ng_interpolation.md b/packages/code_excerpt_updater/test_data/expected/no_escape_ng_interpolation.md
deleted file mode 100644
index 43b566f..0000000
--- a/packages/code_excerpt_updater/test_data/expected/no_escape_ng_interpolation.md
+++ /dev/null
@@ -1,6 +0,0 @@
-
-```
-
-
Hello {{name}}!
-
-```
diff --git a/packages/code_excerpt_updater/test_data/expected/plaster-global-option.md b/packages/code_excerpt_updater/test_data/expected/plaster-global-option.md
deleted file mode 100644
index 6f539a8..0000000
--- a/packages/code_excerpt_updater/test_data/expected/plaster-global-option.md
+++ /dev/null
@@ -1,52 +0,0 @@
-## Test plaster feature
-
-### Globally set default plaster
-
-
-```
-var greeting = 'hello';
-// Insert your code here ···
-var scope = 'world';
-```
-
-### Remove plaster
-
-
-
-
-```
-abc
-def
-```
-
-
-```
-abc
-···
-def
-```
-
-
-
-
-```
-abc
-// Insert your code here ···
-def
-```
-
-### Custom template
-
-
-```
-var greeting = 'hello';
-/*...*/
-var scope = 'world';
-```
-
-
-```
-var greeting = 'hello';
-/* ··· */
-var scope = 'world';
-```
diff --git a/packages/code_excerpt_updater/test_data/expected/plaster.md b/packages/code_excerpt_updater/test_data/expected/plaster.md
deleted file mode 100644
index 9b78cfe..0000000
--- a/packages/code_excerpt_updater/test_data/expected/plaster.md
+++ /dev/null
@@ -1,98 +0,0 @@
-## Test plaster feature
-
-Testing of this feature only became relevant with the use of YAML excerpts.
-
-### Plaster for language without comment syntax
-
-
-```
-abc
-···
-def
-```
-
-### Plaster for language with comment syntax
-
-Languages with start-comment syntax:
-
-
-```
-var greeting = 'hello';
-// ···
-var scope = 'world';
-```
-
-Languages with start- and end-comment syntax:
-
-
-```
-.abc {}
-/* ··· */
-.def {}
-```
-
-
-```
-
-
-
-```
-
-
-```
-abc:
- # ···
- def
-```
-
-### Remove plaster
-
-
-```
-abc
-def
-```
-
-
-```
-var greeting = 'hello';
-var scope = 'world';
-```
-
-
-```
-abc:
- def
-```
-
-### Language spec on code block
-
-
-```html
-
-
-
-```
-
-
-{% prettify html %}
-
-
-
-{% endprettify %}
-
-### Custom template
-
-
-```
-var greeting = 'hello';
-/*...*/
-var scope = 'world';
-```
-
-
-```
-var greeting = 'hello';
-/* ··· */
-var scope = 'world';
-```
diff --git a/packages/code_excerpt_updater/test_data/expected/prettify.md b/packages/code_excerpt_updater/test_data/expected/prettify.md
deleted file mode 100644
index 103e5a3..0000000
--- a/packages/code_excerpt_updater/test_data/expected/prettify.md
+++ /dev/null
@@ -1,14 +0,0 @@
-Also see `no_change/prettify.md` and `language-tour.md` in this test folder for
-other prettify tests.
-
-## API docs
-
-Prettify block containing triple-backticks:
-
-
-{% prettify html %}
-/// ```html
-/// HTML is magical!
-/// ```
-class HTML {}
-{% endprettify %}
diff --git a/packages/code_excerpt_updater/test_data/expected/remove.md b/packages/code_excerpt_updater/test_data/expected/remove.md
deleted file mode 100644
index 8c14a1c..0000000
--- a/packages/code_excerpt_updater/test_data/expected/remove.md
+++ /dev/null
@@ -1,23 +0,0 @@
-## Test remove attribute
-
-Test plain string argument:
-
-
-```
-var greeting = 'hello';
-var scope = 'world';
-```
-
-Test regexp argument:
-
-
-```
-```
-
-Test plain string of the form `/.../`:
-
-
-```
-var x = 1;
-return x;
-```
diff --git a/packages/code_excerpt_updater/test_data/expected/replace.md b/packages/code_excerpt_updater/test_data/expected/replace.md
deleted file mode 100644
index 431600b..0000000
--- a/packages/code_excerpt_updater/test_data/expected/replace.md
+++ /dev/null
@@ -1,112 +0,0 @@
-## Test replace attribute
-
-
-```
-var greeting = 'bonjour';
-var scope = 'world';
-
-void main() => print('$greeting $scope');
-```
-
-
-```
-var greeting = 'bonjour$1$2';
-var scope = 'world';
-
-void main() => print('$greeting $scope');
-```
-
-
-```
-var greeting = 'hello hello';
-var scope = 'world';
-
-void main() => print('$greeting $scope');
-```
-
-
-```
-var greeting = 'hello/bonjour';
-var scope = 'world';
-
-void main() => print('$greeting $scope');
-```
-
-
-```
-var greeting = 'bonjour'; //?
-var scope = 'world'; //!
-
-void main() => print('$greeting $scope'); //!
-```
-
-### Special characters starting with a slash
-
-- Test `\n` in regexp part
-
-
- ```
-
Hello World!
- ```
-
-- Test `\n` in replacement part, along with escaped `\\n`:
-
-
- ```
- This is a
- markdown
- fragment\n
- ```
-
-- Test replacement of `>` when written as `\x3E`:
-
-
- ```
-
-
Hello World!
-
- ```
-
-- Ensure that double slashes aren't interpreted specially:
-
-
- ```
-
-
Hello World\xAB
-
- ```
-
-### Command-line and File-global replace test
-
-Command-line replace expression is /mundo/$&!/g, which is to be applied last.
-
-
-
-
-```
-var greeting = 'hola';
-var scope = 'mundo!';
-
-void main() => print('$greeting $scope');
-```
-
-### Reset file-global replace
-
-
-
-```
-var greeting = 'bonjour';
-var scope = 'world';
-
-void main() => print('$greeting $scope');
-```
-
-### Regression: support `}` in regexp.
-
-
-```
-var greeting = 'hello';
-var scope = 'world';
-
-void main() => print('$greeting $scope'); //!
-```
diff --git a/packages/code_excerpt_updater/test_data/expected/retain.md b/packages/code_excerpt_updater/test_data/expected/retain.md
deleted file mode 100644
index b441057..0000000
--- a/packages/code_excerpt_updater/test_data/expected/retain.md
+++ /dev/null
@@ -1,24 +0,0 @@
-## Test retain attribute
-
-Test plain string argument:
-
-
-```
-void main() => print('$greeting $scope');
-```
-
-Test regexp argument:
-
-
-```
-var greeting = 'hello';
-var scope = 'world';
-void main() => print('$greeting $scope');
-```
-
-Test plain string of the form `/.../`:
-
-
-```
-// Fragment is indented by 4 spaces
-```
diff --git a/packages/code_excerpt_updater/test_data/expected/set_path.md b/packages/code_excerpt_updater/test_data/expected/set_path.md
deleted file mode 100644
index 5825d44..0000000
--- a/packages/code_excerpt_updater/test_data/expected/set_path.md
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-```
-var greeting = 'hello';
-var scope = 'world';
-```
diff --git a/packages/code_excerpt_updater/test_data/expected/src_but_no_frag.md b/packages/code_excerpt_updater/test_data/expected/src_but_no_frag.md
deleted file mode 100644
index 9fa9916..0000000
--- a/packages/code_excerpt_updater/test_data/expected/src_but_no_frag.md
+++ /dev/null
@@ -1,9 +0,0 @@
-## Test
-
-
-```
-var _greeting = 'hello';
-var _scope = 'world';
-
-void main() => print('$_greeting $_scope');
-```
diff --git a/packages/code_excerpt_updater/test_data/expected/trim.dart b/packages/code_excerpt_updater/test_data/expected/trim.dart
deleted file mode 100644
index 7096a2b..0000000
--- a/packages/code_excerpt_updater/test_data/expected/trim.dart
+++ /dev/null
@@ -1,9 +0,0 @@
-// ignore_for_file: type_annotate_public_apis
-/// Test: trimming of whitespace from frag lines
-///
-/// ```dart
-/// // In fragment file, the const declaration line ends with: TAB SPACE
-/// // (Beware: some editors trim out trailing whitespace!)
-/// const c = 1;
-/// ```
-int? v;
diff --git a/packages/code_excerpt_updater/test_data/frag/0-base/docregion-main.dart.txt b/packages/code_excerpt_updater/test_data/frag/0-base/docregion-main.dart.txt
deleted file mode 100644
index 427a167..0000000
--- a/packages/code_excerpt_updater/test_data/frag/0-base/docregion-main.dart.txt
+++ /dev/null
@@ -1 +0,0 @@
-void main() => print('$_greeting $_scope');
diff --git a/packages/code_excerpt_updater/test_data/frag/1-step/docregion-main.dart.txt b/packages/code_excerpt_updater/test_data/frag/1-step/docregion-main.dart.txt
deleted file mode 100644
index 2ca508f..0000000
--- a/packages/code_excerpt_updater/test_data/frag/1-step/docregion-main.dart.txt
+++ /dev/null
@@ -1 +0,0 @@
-void main() => print('$_greeting $_scope!');
diff --git a/packages/code_excerpt_updater/test_data/frag/backticks_in_api_doc.dart.txt b/packages/code_excerpt_updater/test_data/frag/backticks_in_api_doc.dart.txt
deleted file mode 100644
index 9ef0625..0000000
--- a/packages/code_excerpt_updater/test_data/frag/backticks_in_api_doc.dart.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-/// ```html
-/// HTML is magical!
-/// ```
-class HTML {}
diff --git a/packages/code_excerpt_updater/test_data/frag/basic-another-greeting.dart.txt b/packages/code_excerpt_updater/test_data/frag/basic-another-greeting.dart.txt
deleted file mode 100644
index ec68bab..0000000
--- a/packages/code_excerpt_updater/test_data/frag/basic-another-greeting.dart.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-var greeting = 'hello';
-var scope = 'world';
\ No newline at end of file
diff --git a/packages/code_excerpt_updater/test_data/frag/basic-greeting.dart.txt b/packages/code_excerpt_updater/test_data/frag/basic-greeting.dart.txt
deleted file mode 100644
index ec68bab..0000000
--- a/packages/code_excerpt_updater/test_data/frag/basic-greeting.dart.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-var greeting = 'hello';
-var scope = 'world';
\ No newline at end of file
diff --git a/packages/code_excerpt_updater/test_data/frag/basic.dart.txt b/packages/code_excerpt_updater/test_data/frag/basic.dart.txt
deleted file mode 100644
index ca01698..0000000
--- a/packages/code_excerpt_updater/test_data/frag/basic.dart.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-var greeting = 'hello';
-var scope = 'world';
-
-void main() => print('$greeting $scope');
diff --git a/packages/code_excerpt_updater/test_data/frag/frag_with_trailing_whitespace.dart.txt b/packages/code_excerpt_updater/test_data/frag/frag_with_trailing_whitespace.dart.txt
deleted file mode 100644
index 7c69fa0..0000000
--- a/packages/code_excerpt_updater/test_data/frag/frag_with_trailing_whitespace.dart.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-// In fragment file, the const declaration line ends with: TAB SPACE
-// (Beware: some editors trim out trailing whitespace!)
-const c = 1;
-
diff --git a/packages/code_excerpt_updater/test_data/frag/indented_frag-code-blocks.dart.txt b/packages/code_excerpt_updater/test_data/frag/indented_frag-code-blocks.dart.txt
deleted file mode 100644
index 0a59d8d..0000000
--- a/packages/code_excerpt_updater/test_data/frag/indented_frag-code-blocks.dart.txt
+++ /dev/null
@@ -1,6 +0,0 @@
- // Fragment is indented by 4 spaces
- var x = 1;
-
- /* ... */
- return x;
- /* ... */
diff --git a/packages/code_excerpt_updater/test_data/frag/indented_frag-single-code-block.dart.txt b/packages/code_excerpt_updater/test_data/frag/indented_frag-single-code-block.dart.txt
deleted file mode 100644
index bafb53c..0000000
--- a/packages/code_excerpt_updater/test_data/frag/indented_frag-single-code-block.dart.txt
+++ /dev/null
@@ -1,3 +0,0 @@
- // Fragment is indented by 4 spaces
- var x = 1;
- return x;
diff --git a/packages/code_excerpt_updater/test_data/frag/ng_interpolation.html.txt b/packages/code_excerpt_updater/test_data/frag/ng_interpolation.html.txt
deleted file mode 100644
index 7b3b6ef..0000000
--- a/packages/code_excerpt_updater/test_data/frag/ng_interpolation.html.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
Hello {{name}}!
-
\ No newline at end of file
diff --git a/packages/code_excerpt_updater/test_data/frag/no_region.dart.txt b/packages/code_excerpt_updater/test_data/frag/no_region.dart.txt
deleted file mode 100644
index ec68bab..0000000
--- a/packages/code_excerpt_updater/test_data/frag/no_region.dart.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-var greeting = 'hello';
-var scope = 'world';
\ No newline at end of file
diff --git a/packages/code_excerpt_updater/test_data/frag/no_region.html.txt b/packages/code_excerpt_updater/test_data/frag/no_region.html.txt
deleted file mode 100644
index b346b03..0000000
--- a/packages/code_excerpt_updater/test_data/frag/no_region.html.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
Hello World!
-
\ No newline at end of file
diff --git a/packages/code_excerpt_updater/test_data/frag/quote.md.txt b/packages/code_excerpt_updater/test_data/frag/quote.md.txt
deleted file mode 100644
index 2b630d6..0000000
--- a/packages/code_excerpt_updater/test_data/frag/quote.md.txt
+++ /dev/null
@@ -1 +0,0 @@
-This is a **markdown** fragment.
\ No newline at end of file
diff --git a/packages/code_excerpt_updater/test_data/src/arg-order.md b/packages/code_excerpt_updater/test_data/src/arg-order.md
deleted file mode 100644
index 7f67070..0000000
--- a/packages/code_excerpt_updater/test_data/src/arg-order.md
+++ /dev/null
@@ -1,9 +0,0 @@
-## Test arg order
-
-
-```
-```
-
-
-```
-```
diff --git a/packages/code_excerpt_updater/test_data/src/basic_no_region.dart b/packages/code_excerpt_updater/test_data/src/basic_no_region.dart
deleted file mode 100644
index 6253de6..0000000
--- a/packages/code_excerpt_updater/test_data/src/basic_no_region.dart
+++ /dev/null
@@ -1,22 +0,0 @@
-/// No region arguments in this file.
-library;
-
-/// Test: no code in code block, directive w/o indentation
-///
-/// ```html
-/// ```
-int? basic1;
-
-/// Test: no code in code block, directive with indentation
-///
-/// ```dart
-/// ```
-num? basic2;
-
-/// Test: out-of-date code in code block, directive with indentation
-///
-/// ```dart
-/// we don't care what this text is since it will be replaced
-/// misindented text that we don't care about
-/// ```
-dynamic basic3;
diff --git a/packages/code_excerpt_updater/test_data/src/basic_with_empty_region.md b/packages/code_excerpt_updater/test_data/src/basic_with_empty_region.md
deleted file mode 100644
index 0e18c24..0000000
--- a/packages/code_excerpt_updater/test_data/src/basic_with_empty_region.md
+++ /dev/null
@@ -1,10 +0,0 @@
-Test: empty region
-
-
-```dart
-```
-
-The full file, because an empty region overrides the parenthetical remark in the path/title:
-
-```dart
-```
diff --git a/packages/code_excerpt_updater/test_data/src/basic_with_region.dart b/packages/code_excerpt_updater/test_data/src/basic_with_region.dart
deleted file mode 100644
index 3855d1f..0000000
--- a/packages/code_excerpt_updater/test_data/src/basic_with_region.dart
+++ /dev/null
@@ -1,17 +0,0 @@
-/// Test: no code in code block, directive with indentation
-///
-/// ```dart
-/// ```
-void f() {}
-
-/// Test: region name in path.
-///
-/// ```dart
-/// ```
-class D {}
-
-/// Test: region name in path.
-///
-/// ```dart
-/// ```
-class E {}
diff --git a/packages/code_excerpt_updater/test_data/src/basic_with_region.jade b/packages/code_excerpt_updater/test_data/src/basic_with_region.jade
deleted file mode 100644
index 670b728..0000000
--- a/packages/code_excerpt_updater/test_data/src/basic_with_region.jade
+++ /dev/null
@@ -1,22 +0,0 @@
-:marked
- Test:
- - Jade file
- - Global indentation setting
- - Valueless instruction argument (`title`).
-
-
- ```dart
- ```
-
- Test that region argument takes precedence over string in parentheses:
-
- ```
- ```
-
-
- ```
- ```
-
-
- ```
- ```
diff --git a/packages/code_excerpt_updater/test_data/src/dartdoc.md b/packages/code_excerpt_updater/test_data/src/dartdoc.md
deleted file mode 100644
index 6b85d49..0000000
--- a/packages/code_excerpt_updater/test_data/src/dartdoc.md
+++ /dev/null
@@ -1,8 +0,0 @@
-## API docs
-
-Markdown code block opened and closed with more than 3 backticks
-that contains another Markdown code block declared with just 3.
-
-
-````dart
-````
diff --git a/packages/code_excerpt_updater/test_data/src/escape_ng_interpolation.md b/packages/code_excerpt_updater/test_data/src/escape_ng_interpolation.md
deleted file mode 100644
index 27f788f..0000000
--- a/packages/code_excerpt_updater/test_data/src/escape_ng_interpolation.md
+++ /dev/null
@@ -1,3 +0,0 @@
-
-```
-```
diff --git a/packages/code_excerpt_updater/test_data/src/excerpt_yaml.md b/packages/code_excerpt_updater/test_data/src/excerpt_yaml.md
deleted file mode 100644
index 1dce974..0000000
--- a/packages/code_excerpt_updater/test_data/src/excerpt_yaml.md
+++ /dev/null
@@ -1,13 +0,0 @@
-## Excerpt-yaml tests
-
-Excerpt:
-
-
-```
-```
-
-Excerpt full source for which there is no `.excerpt.yaml` file.
-
-
-```
-```
diff --git a/packages/code_excerpt_updater/test_data/src/fragment-indentation.md b/packages/code_excerpt_updater/test_data/src/fragment-indentation.md
deleted file mode 100644
index aae339e..0000000
--- a/packages/code_excerpt_updater/test_data/src/fragment-indentation.md
+++ /dev/null
@@ -1,11 +0,0 @@
-## Test: code fragment should be unindented
-
-
-```
-```
-
-## Test: code fragment should be unindented
-
-
-```
-```
diff --git a/packages/code_excerpt_updater/test_data/src/language-tour.md b/packages/code_excerpt_updater/test_data/src/language-tour.md
deleted file mode 100644
index 2f90c7b..0000000
--- a/packages/code_excerpt_updater/test_data/src/language-tour.md
+++ /dev/null
@@ -1,35 +0,0 @@
-## Basic prettify tests
-
-### Without arguments
-
-
-{% prettify %}
-...
-{% endprettify %}
-
-### With language argument
-
-
-{% prettify dart %}
-...
-{% endprettify %}
-
-
-{% prettify html %}
-{% endprettify %}
-
-### With other arguments
-
-
-{% prettify html tag="code" %}
-{% endprettify %}
-
-### With strip-whitespace syntax
-
-
-{% prettify html tag="code+br" -%}
-{%- endprettify %}
-
-
-{%- prettify dart -%}
-{%- endprettify -%}
diff --git a/packages/code_excerpt_updater/test_data/src/list.md b/packages/code_excerpt_updater/test_data/src/list.md
deleted file mode 100644
index a84cca3..0000000
--- a/packages/code_excerpt_updater/test_data/src/list.md
+++ /dev/null
@@ -1,19 +0,0 @@
-## Test instructions in markdown lists
-
--
- ```
- ```
-
-*
- ```
- ```
-
-- Some text
-
- ```
- ```
-
-* Nested list item next:
- -
- ```
- ```
diff --git a/packages/code_excerpt_updater/test_data/src/no_change/basic_diff.dart b/packages/code_excerpt_updater/test_data/src/no_change/basic_diff.dart
deleted file mode 100644
index 7250ed3..0000000
--- a/packages/code_excerpt_updater/test_data/src/no_change/basic_diff.dart
+++ /dev/null
@@ -1,38 +0,0 @@
-/// Test: multi line
-///
-///
-/// ```diff
-/// --- 0-base/basic.dart
-/// +++ 1-step/basic.dart
-/// @@ -1,4 +1,4 @@
-/// -var _greeting = 'hello';
-/// +var _greeting = 'bonjour';
-/// var _scope = 'world';
-///
-/// void main() => print('$_greeting $_scope');
-/// ```
-class C {}
-
-///
-/// ```diff
-/// ```
-class D {}
-
-///
-/// ```diff
-/// --- 0-base/basic.dart
-/// +++ 1-step/basic.dart
-/// @@ -1 +1 @@
-/// -var _greeting = 'hello';
-/// +var _greeting = 'bonjour';
-/// ```
-class E {}
-
-///
-/// ```diff
-/// --- 0-base/basic.dart
-/// +++ 1-step/basic.dart
-/// @@ -1 +1 @@
-/// -var _greeting = 'hello';
-/// ```
-class F {}
diff --git a/packages/code_excerpt_updater/test_data/src/no_change/basic_no_region.dart b/packages/code_excerpt_updater/test_data/src/no_change/basic_no_region.dart
deleted file mode 100644
index 08aebbd..0000000
--- a/packages/code_excerpt_updater/test_data/src/no_change/basic_no_region.dart
+++ /dev/null
@@ -1,16 +0,0 @@
-/// Test: non-indented code, multi line
-///
-/// ```html
-///
-///
Hello World!
-///
-/// ```
-int? basic1;
-
-/// Test: indented code, multi line
-///
-/// ```dart
-/// var greeting = 'hello';
-/// var scope = 'world';
-/// ```
-void f() {}
diff --git a/packages/code_excerpt_updater/test_data/src/no_change/basic_with_args.md b/packages/code_excerpt_updater/test_data/src/no_change/basic_with_args.md
deleted file mode 100644
index 6d90e6d..0000000
--- a/packages/code_excerpt_updater/test_data/src/no_change/basic_with_args.md
+++ /dev/null
@@ -1,49 +0,0 @@
-## Test `from` arg
-
-
-```dart
-var scope = 'world';
-
-void main() => print('$greeting $scope');
-```
-
-Pattern not in excerpt:
-
-
-```dart
-```
-
-## Test `to` arg
-
-
-```dart
-var greeting = 'hello';
-var scope = 'world';
-```
-
-Pattern matching last line of excerpt:
-
-
-```dart
-var greeting = 'hello';
-var scope = 'world';
-
-void main() => print('$greeting $scope');
-```
-
-Pattern not in excerpt:
-
-
-```dart
-var greeting = 'hello';
-var scope = 'world';
-
-void main() => print('$greeting $scope');
-```
-
-## Test `from` and `to`
-
-
-```dart
-var scope = 'world';
-```
diff --git a/packages/code_excerpt_updater/test_data/src/no_change/basic_with_region.dart b/packages/code_excerpt_updater/test_data/src/no_change/basic_with_region.dart
deleted file mode 100644
index f5e030f..0000000
--- a/packages/code_excerpt_updater/test_data/src/no_change/basic_with_region.dart
+++ /dev/null
@@ -1,23 +0,0 @@
-/// Test: multi line
-///
-/// ```dart
-/// var greeting = 'hello';
-/// var scope = 'world';
-/// ```
-class C {}
-
-/// Test: region name in path.
-///
-/// ```dart
-/// var greeting = 'hello';
-/// var scope = 'world';
-/// ```
-class D {}
-
-/// Test: region name in path.
-///
-/// ```dart
-/// var greeting = 'hello';
-/// var scope = 'world';
-/// ```
-class E {}
diff --git a/packages/code_excerpt_updater/test_data/src/no_change/dartdoc.md b/packages/code_excerpt_updater/test_data/src/no_change/dartdoc.md
deleted file mode 100644
index 5c08223..0000000
--- a/packages/code_excerpt_updater/test_data/src/no_change/dartdoc.md
+++ /dev/null
@@ -1,12 +0,0 @@
-## API docs
-
-Markdown code block opened and closed with more than 3 backticks
-that contains another Markdown code block declared with just 3.
-
-
-````dart
-/// ```html
-/// HTML is magical!
-/// ```
-class HTML {}
-````
diff --git a/packages/code_excerpt_updater/test_data/src/no_change/diff.md b/packages/code_excerpt_updater/test_data/src/no_change/diff.md
deleted file mode 100644
index efc2424..0000000
--- a/packages/code_excerpt_updater/test_data/src/no_change/diff.md
+++ /dev/null
@@ -1,109 +0,0 @@
-## Diff tests of code blocks in Markdown `diff` tags
-
-## Basic
-
-
-```diff
---- 0-base/basic.dart
-+++ 1-step/basic.dart
-@@ -1,4 +1,4 @@
--var _greeting = 'hello';
-+var _greeting = 'bonjour';
- var _scope = 'world';
-
- void main() => print('$_greeting $_scope');
-```
-
-### Files with docregion tags
-
-
-```diff
---- 0-base/docregion.dart
-+++ 1-step/docregion.dart
-@@ -1,4 +1,4 @@
--var _greeting = 'hello';
-+var _greeting = 'bonjour';
- var _scope = 'world';
-
- /// Some
-@@ -12,4 +12,4 @@
- /// two
- /// diff
- /// hunks
--void main() => print('$_greeting $_scope');
-+void main() => print('$_greeting $_scope!');
-```
-
-### Diff region
-
-
-```diff
---- 0-base/docregion.dart (main)
-+++ 1-step/docregion.dart (main)
-@@ -1 +1 @@
--void main() => print('$_greeting $_scope');
-+void main() => print('$_greeting $_scope!');
-```
-
-### Files with docregion tags and diff-u argument
-
-
-```diff
---- 0-base/docregion.dart
-+++ 1-step/docregion.dart
-@@ -1,5 +1,5 @@
--var _greeting = 'hello';
-+var _greeting = 'bonjour';
- var _scope = 'world';
-
- /// Some
- /// doc
-@@ -11,5 +11,5 @@
- /// get
- /// two
- /// diff
- /// hunks
--void main() => print('$_greeting $_scope');
-+void main() => print('$_greeting $_scope!');
-```
-
-## Bash path-brace syntax for diffs
-
-
-```diff
---- 0-base/basic.dart
-+++ 1-step/basic.dart
-@@ -1,4 +1,4 @@
--var _greeting = 'hello';
-+var _greeting = 'bonjour';
- var _scope = 'world';
-
- void main() => print('$_greeting $_scope');
-```
-
-## Bash path-brace syntax with diff-with error
-
-
-```diff
---- 0-base/basic.dart
-+++ 1-step/basic.dart
-@@ -1,4 +1,4 @@
--var _greeting = 'hello';
-+var _greeting = 'bonjour';
- var _scope = 'world';
-
- void main() => print('$_greeting $_scope');
-```
-
-## Remove argument
-
-
-```diff
---- 0-base/basic.dart
-+++ 1-step/basic.dart
-@@ -1,3 +1,3 @@
--var _greeting = 'hello';
-+var _greeting = 'bonjour';
-
- void main() => print('$_greeting $_scope');
-```
diff --git a/packages/code_excerpt_updater/test_data/src/no_change/frag_not_found.dart b/packages/code_excerpt_updater/test_data/src/no_change/frag_not_found.dart
deleted file mode 100644
index a6a5c04..0000000
--- a/packages/code_excerpt_updater/test_data/src/no_change/frag_not_found.dart
+++ /dev/null
@@ -1,5 +0,0 @@
-///
-/// ```
-/// ...
-/// ```
-int? x;
diff --git a/packages/code_excerpt_updater/test_data/src/no_change/invalid_code_block.dart b/packages/code_excerpt_updater/test_data/src/no_change/invalid_code_block.dart
deleted file mode 100644
index efe8a9b..0000000
--- a/packages/code_excerpt_updater/test_data/src/no_change/invalid_code_block.dart
+++ /dev/null
@@ -1,4 +0,0 @@
-/// Closing code-block token is missing below:
-///
-/// ```
-int x = 1;
diff --git a/packages/code_excerpt_updater/test_data/src/no_change/invalid_code_excerpt_arg.dart b/packages/code_excerpt_updater/test_data/src/no_change/invalid_code_excerpt_arg.dart
deleted file mode 100644
index 77ee211..0000000
--- a/packages/code_excerpt_updater/test_data/src/no_change/invalid_code_excerpt_arg.dart
+++ /dev/null
@@ -1,2 +0,0 @@
-///
-int? noApiDoc0;
diff --git a/packages/code_excerpt_updater/test_data/src/no_change/missing_code_block.dart b/packages/code_excerpt_updater/test_data/src/no_change/missing_code_block.dart
deleted file mode 100644
index ae187b7..0000000
--- a/packages/code_excerpt_updater/test_data/src/no_change/missing_code_block.dart
+++ /dev/null
@@ -1,3 +0,0 @@
-/// Missing code block
-///
-int x = 0;
diff --git a/packages/code_excerpt_updater/test_data/src/no_change/no_comment_prefix.md b/packages/code_excerpt_updater/test_data/src/no_change/no_comment_prefix.md
deleted file mode 100644
index cf5c615..0000000
--- a/packages/code_excerpt_updater/test_data/src/no_change/no_comment_prefix.md
+++ /dev/null
@@ -1,13 +0,0 @@
-## Test: code without indentation, single line
-
-
-```
-This is a **markdown** fragment.
-```
-
-## Test: indented code, single line
-
-
-```
- This is a **markdown** fragment.
-```
diff --git a/packages/code_excerpt_updater/test_data/src/no_change/no_path.md b/packages/code_excerpt_updater/test_data/src/no_change/no_path.md
deleted file mode 100644
index 91be199..0000000
--- a/packages/code_excerpt_updater/test_data/src/no_change/no_path.md
+++ /dev/null
@@ -1,11 +0,0 @@
-Test: code-excerpt instruction w/o a path; i.e., which need not be updated:
-
-
-```html
-Hello {{name}}!
-```
-
-
-```dart
-var x = 1;
-```
diff --git a/packages/code_excerpt_updater/test_data/src/no_change/no_src.dart b/packages/code_excerpt_updater/test_data/src/no_change/no_src.dart
deleted file mode 100644
index dc5fb4b..0000000
--- a/packages/code_excerpt_updater/test_data/src/no_change/no_src.dart
+++ /dev/null
@@ -1,2 +0,0 @@
-/// A file with no PIs
-int? noApiDoc0;
diff --git a/packages/code_excerpt_updater/test_data/src/no_change/prettify.md b/packages/code_excerpt_updater/test_data/src/no_change/prettify.md
deleted file mode 100644
index 018c576..0000000
--- a/packages/code_excerpt_updater/test_data/src/no_change/prettify.md
+++ /dev/null
@@ -1,17 +0,0 @@
-Regression test for https://github.com/dart-lang/site-www/pull/719.
-Originally, when run on the code excerpt instruction below,
-the code excerpt would be duplicated.
-
-Also see `../prettify.md` and `language-tour.md` in this test folder for other prettify tests.
-
-## API docs
-
-Prettify block containing triple-backticks:
-
-
-{% prettify html %}
-/// ```html
-/// HTML is magical!
-/// ```
-class HTML {}
-{% endprettify %}
diff --git a/packages/code_excerpt_updater/test_data/src/no_change/skip-and-take.md b/packages/code_excerpt_updater/test_data/src/no_change/skip-and-take.md
deleted file mode 100644
index 4386ff6..0000000
--- a/packages/code_excerpt_updater/test_data/src/no_change/skip-and-take.md
+++ /dev/null
@@ -1,36 +0,0 @@
-## Test `skip`
-
-
-```dart
-void main() => print('$greeting $scope');
-```
-
-Negative arg:
-
-
-```dart
-var greeting = 'hello';
-var scope = 'world';
-```
-
-## Test `take`
-
-
-```dart
-var greeting = 'hello';
-var scope = 'world';
-```
-
-Negative arg:
-
-
-```dart
-void main() => print('$greeting $scope');
-```
-
-## Test `skip` and `take` together
-
-
-```dart
-var scope = 'world';
-```
diff --git a/packages/code_excerpt_updater/test_data/src/no_comment_prefix.md b/packages/code_excerpt_updater/test_data/src/no_comment_prefix.md
deleted file mode 100644
index 0518966..0000000
--- a/packages/code_excerpt_updater/test_data/src/no_comment_prefix.md
+++ /dev/null
@@ -1,19 +0,0 @@
-## Test: no code in code block, directive w/o indentation
-
-
-```
-```
-
-## Test: no code in code block, directive with indentation
-
-
-```
-```
-
-## Test: out-of-date code in code block, directive with indentation
-
-
-```
- we don't care what this text is since it will be replaced
-misindented text that we don't care about
-```
diff --git a/packages/code_excerpt_updater/test_data/src/no_escape_ng_interpolation.md b/packages/code_excerpt_updater/test_data/src/no_escape_ng_interpolation.md
deleted file mode 100644
index 27f788f..0000000
--- a/packages/code_excerpt_updater/test_data/src/no_escape_ng_interpolation.md
+++ /dev/null
@@ -1,3 +0,0 @@
-
-```
-```
diff --git a/packages/code_excerpt_updater/test_data/src/plaster-global-option.md b/packages/code_excerpt_updater/test_data/src/plaster-global-option.md
deleted file mode 100644
index 2c7bab8..0000000
--- a/packages/code_excerpt_updater/test_data/src/plaster-global-option.md
+++ /dev/null
@@ -1,35 +0,0 @@
-## Test plaster feature
-
-### Globally set default plaster
-
-
-```
-```
-
-### Remove plaster
-
-
-
-
-```
-```
-
-
-```
-```
-
-
-
-
-```
-```
-
-### Custom template
-
-
-```
-```
-
-
-```
-```
diff --git a/packages/code_excerpt_updater/test_data/src/plaster.md b/packages/code_excerpt_updater/test_data/src/plaster.md
deleted file mode 100644
index d4716ab..0000000
--- a/packages/code_excerpt_updater/test_data/src/plaster.md
+++ /dev/null
@@ -1,65 +0,0 @@
-## Test plaster feature
-
-Testing of this feature only became relevant with the use of YAML excerpts.
-
-### Plaster for language without comment syntax
-
-
-```
-```
-
-### Plaster for language with comment syntax
-
-Languages with start-comment syntax:
-
-
-```
-```
-
-Languages with start- and end-comment syntax:
-
-
-```
-```
-
-
-```
-```
-
-
-```
-```
-
-### Remove plaster
-
-
-```
-```
-
-
-```
-```
-
-
-```
-```
-
-### Language spec on code block
-
-
-```html
-```
-
-
-{% prettify html %}
-{% endprettify %}
-
-### Custom template
-
-
-```
-```
-
-
-```
-```
diff --git a/packages/code_excerpt_updater/test_data/src/prettify.md b/packages/code_excerpt_updater/test_data/src/prettify.md
deleted file mode 100644
index c19c0c2..0000000
--- a/packages/code_excerpt_updater/test_data/src/prettify.md
+++ /dev/null
@@ -1,11 +0,0 @@
-Also see `no_change/prettify.md` and `language-tour.md` in this test folder for
-other prettify tests.
-
-## API docs
-
-Prettify block containing triple-backticks:
-
-
-{% prettify html %}
-...
-{% endprettify %}
diff --git a/packages/code_excerpt_updater/test_data/src/remove.md b/packages/code_excerpt_updater/test_data/src/remove.md
deleted file mode 100644
index 96b4c30..0000000
--- a/packages/code_excerpt_updater/test_data/src/remove.md
+++ /dev/null
@@ -1,19 +0,0 @@
-## Test remove attribute
-
-Test plain string argument:
-
-
-```
-```
-
-Test regexp argument:
-
-
-```
-```
-
-Test plain string of the form `/.../`:
-
-
-```
-```
diff --git a/packages/code_excerpt_updater/test_data/src/replace.md b/packages/code_excerpt_updater/test_data/src/replace.md
deleted file mode 100644
index 6670cf7..0000000
--- a/packages/code_excerpt_updater/test_data/src/replace.md
+++ /dev/null
@@ -1,70 +0,0 @@
-## Test replace attribute
-
-
-```
-```
-
-
-```
-```
-
-
-```
-```
-
-
-```
-```
-
-
-```
-```
-
-### Special characters starting with a slash
-
-- Test `\n` in regexp part
-
-
- ```
- ```
-
-- Test `\n` in replacement part, along with escaped `\\n`:
-
-
- ```
- ```
-
-- Test replacement of `>` when written as `\x3E`:
-
-
- ```
- ```
-
-- Ensure that double slashes aren't interpreted specially:
-
-
- ```
- ```
-
-### Command-line and File-global replace test
-
-Command-line replace expression is /mundo/$&!/g, which is to be applied last.
-
-
-
-
-```
-```
-
-### Reset file-global replace
-
-
-
-```
-```
-
-### Regression: support `}` in regexp.
-
-
-```
-```
diff --git a/packages/code_excerpt_updater/test_data/src/retain.md b/packages/code_excerpt_updater/test_data/src/retain.md
deleted file mode 100644
index 37f301a..0000000
--- a/packages/code_excerpt_updater/test_data/src/retain.md
+++ /dev/null
@@ -1,19 +0,0 @@
-## Test retain attribute
-
-Test plain string argument:
-
-
-```
-```
-
-Test regexp argument:
-
-
-```
-```
-
-Test plain string of the form `/.../`:
-
-
-```
-```
diff --git a/packages/code_excerpt_updater/test_data/src/set_path.md b/packages/code_excerpt_updater/test_data/src/set_path.md
deleted file mode 100644
index c13dfcc..0000000
--- a/packages/code_excerpt_updater/test_data/src/set_path.md
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-```
-```
diff --git a/packages/code_excerpt_updater/test_data/src/src_but_no_frag.md b/packages/code_excerpt_updater/test_data/src/src_but_no_frag.md
deleted file mode 100644
index d467dec..0000000
--- a/packages/code_excerpt_updater/test_data/src/src_but_no_frag.md
+++ /dev/null
@@ -1,5 +0,0 @@
-## Test
-
-
-```
-```
diff --git a/packages/code_excerpt_updater/test_data/src/trim.dart b/packages/code_excerpt_updater/test_data/src/trim.dart
deleted file mode 100644
index 81d4553..0000000
--- a/packages/code_excerpt_updater/test_data/src/trim.dart
+++ /dev/null
@@ -1,6 +0,0 @@
-// ignore_for_file: type_annotate_public_apis
-/// Test: trimming of whitespace from frag lines
-///
-/// ```dart
-/// ```
-int? v;
diff --git a/packages/code_excerpter/.gitignore b/packages/code_excerpter/.gitignore
deleted file mode 100644
index fdc2120..0000000
--- a/packages/code_excerpter/.gitignore
+++ /dev/null
@@ -1,14 +0,0 @@
-# Files and directories created by pub
-.dart_tool
-.pub/
-build/
-packages
-# Remove the following pattern if you wish to check in your lock file
-pubspec.lock
-
-# Directory created by dartdoc
-doc/api/
-
-# IDEs
-.idea/
-.vscode/
diff --git a/packages/code_excerpter/CHANGELOG.md b/packages/code_excerpter/CHANGELOG.md
deleted file mode 100644
index 43c45c2..0000000
--- a/packages/code_excerpter/CHANGELOG.md
+++ /dev/null
@@ -1,61 +0,0 @@
-# Changelog
-
-## 1.0.0
-
-- When YAML excerpt files are generated, the excerpt values
- are now multiline strings with a left border character as
- the first character of each line. The value of the special
- map key '#border' is the border character. (The code-excerpt
- updater trims of this border character when present.)
-
-## 0.6.2
-
-- Internal changes (ran format --fix).
-
-## 0.6.1
-
-- Don't process dot files.
-
-## 0.6.0
-
-- Upgrade to v1 of `builder` and `build_runner`.
-
-## 0.5.0
-
-- Set max SDK version to <3.0.0.
-
-## 0.4.1
-
-- Updated README to explain usage, syntax, etc.
-- Set min SDK to 2.0.0-dev.67.0 and upgrade `build_runner` to 0.9.0.
-
-## 0.4.0
-
-- Set min SDK to 2.0.0-dev.64.1 and upgrade `test` to 1.0.0.
-
-## 0.3.1+1, +2
-
-- Set min SDK to 2.0.0-dev.61 and other package version downgrades.
-
-## 0.3.1
-
-- Fix type error.
-- Set min SDK to 2.0.0-dev.62
-
-## 0.3.0
-
-- Change base config so that the builder applies to all packages
- (via `auto_apply: all_packages`).
-
-## 0.2.0
-
-- Support quoted default region name `''`, and deprecate
- unquoted default region name usage.
-- Warn about repeated region names.
-
-## 0.1.0
-
-- First public version, inspired by JavaScript-based
- [github.com/chalin/code-excerpter](https://github.com/chalin/code-excerpter),
- which was derived from tooling used under angular.io.
-
diff --git a/packages/code_excerpter/LICENSE b/packages/code_excerpter/LICENSE
deleted file mode 100644
index fc5612b..0000000
--- a/packages/code_excerpter/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License
-
-Copyright (c) 2018 Dart Project Authors https://www.dartlang.org
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/packages/code_excerpter/README.md b/packages/code_excerpter/README.md
deleted file mode 100644
index 22c583d..0000000
--- a/packages/code_excerpter/README.md
+++ /dev/null
@@ -1,127 +0,0 @@
-# code_excerpter
-
-A line-based builder for extracting code regions from source files.
-
-Documentation for a package or framework often contains code excerpts.
-There are two main approaches to ensuring that such **code excerpts remain
-up-to-date** as the package or framework code base evolves.
-(1) A [literate programming][] approach, where **code
-fragments are extracted from the docs**, then analyzed and tested.
-(2) A complementary approach where named **code regions are extracted from
-sources**, and docs are refreshed (as needed) when code regions change.
-
-Both approaches have their merits, but `code_excerpter`, and its companion tool
-[code_excerpt_updater][], support (2). More specifically:
-
-- `code_excerpter` is a builder that can be used to extract code regions from source files.
-- [code_excerpt_updater][] can be used to refresh code regions inside docs using
- the output from `code_excerpter`
-
-## Usage synopsis
-
-1. One-time setup: define a builder config file.
-2. Markup your sources with (optionally named) code regions
- delimited by `#docregion` / `#enddocregion` pairs, each written
- inside a line comment. An example is given below.
-3. Run the builder.
-4. Use [code_excerpt_updater][] to update your docs.
-
-Repeat steps 2-4 as the code base evolves.
-
-## Examples sources
-
-
-```dart
-// #docregion imports
-import 'dart:async';
-// #enddocregion imports
-
-// #docregion main, main-stub
-void main() async {
- // #enddocregion main-stub
- print('Compute π using the Monte Carlo method.');
- await for (var estimate in computePi().take(500)) {
- print('π ≅ $estimate');
- }
- // #docregion main-stub
-}
-// #enddocregion main, main-stub
-
-/// Generates a stream of increasingly accurate estimates of π.
-Stream computePi({int batch: 100000}) async* {
- // ...
-}
-```
-
-The regions defined in the Dart source above are: `imports`, `main`, `main-stub`,
-and (implicitly) the **default region** named `''`.
-If you don't explicitly delimit the default region, it is assumed to be the
-entire file.
-
-Some of the regions defined in the example above include:
-
-- `imports` region:
- > ```dart
- > import 'dart:async';
- > ```
-
-- `main-stub` region:
- > ```dart
- > void main() async {
- > // ···
- > }
- > ```
-
-The `main-stub` region is discontinuous, that is, it has a break in it.
-By default, when the [code_excerpt_updater][] renders a region with breaks,
-each breaks is replaced by a (language-specific) comment line filled with a
-plaster marker (`···`).
-
-For details concerning the processing of plasters, see the
-[code_excerpt_updater][] documentation.
-
-Notes:
-
-- If a code region end coincides with the file end, then its closing
- `#enddocregion` can be omitted.
-- The `code_excerpter` supports source files in all popular languages including
- Dart, HTML, YAML, CSS, SCSS, and more.
-
-
-## Syntax
-
-As illustrated above, the region markers can be followed by zero or more comma-separated region names.
-
-A legal **region name** is one of:
-
-- `''`
-- A non-empty sequence of alphanumeric characters possibly containing a hyphen (`-`)
- or an underscore (`_`).
-
-## Sample builder config
-
-To use the builder, create a config file such as the following:
-
-```yaml
-targets:
- $default:
- sources:
- include: [examples/**]
- exclude:
- - '**/.*/**'
- - '**/build/**'
- builders:
- code_excerpter|code_excerpter:
- enabled: true
-```
-
-Build by running this command:
-
-```console
-> pub run build_runner build --output=
-```
-
-Yaml files containing excerpts (`*.excerpt.yaml`) will be placed in the build output folder.
-
-[code_excerpt_updater]: https://github.com/chalin/code_excerpt_updater
-[literate programming]: https://en.wikipedia.org/wiki/Literate_programming
\ No newline at end of file
diff --git a/packages/code_excerpter/analysis_options.yaml b/packages/code_excerpter/analysis_options.yaml
deleted file mode 100644
index b9bdf80..0000000
--- a/packages/code_excerpter/analysis_options.yaml
+++ /dev/null
@@ -1 +0,0 @@
-include: package:analysis_defaults/analysis.yaml
diff --git a/packages/code_excerpter/build.yaml b/packages/code_excerpter/build.yaml
deleted file mode 100644
index e285e02..0000000
--- a/packages/code_excerpter/build.yaml
+++ /dev/null
@@ -1,31 +0,0 @@
-builders:
- code_excerpter:
- import: 'package:code_excerpter/builder.dart'
- auto_apply: all_packages
- builder_factories: [builder]
- build_extensions: {'': [.excerpt.yaml]}
- # TODO(redbrogdon): Consider removing this if not used elsewhere.
- defaults:
- generate_for:
- include:
- - example/**
- - examples/**
- - lib/**
- - test/**
- - web/**
- exclude:
- - '**/.*'
- - '**/.*/**'
- - '**/.DS_Store'
- - '**/build/**'
- - '**/node_modules/**'
- - '**/*.bmp'
- - '**/*.cur'
- - '**/*.ico'
- - '**/*.jpg'
- - '**/*.jpeg'
- - '**/*.png'
- - '**/*.sum'
- - '**/*.tiff'
- - '**/*.zip'
- - '**/*.gzip'
diff --git a/packages/code_excerpter/lib/builder.dart b/packages/code_excerpter/lib/builder.dart
deleted file mode 100644
index 0501de2..0000000
--- a/packages/code_excerpter/lib/builder.dart
+++ /dev/null
@@ -1,69 +0,0 @@
-import 'dart:async';
-
-import 'package:build/build.dart';
-
-import 'src/excerpter.dart';
-import 'src/util/line.dart';
-
-const excerptLineLeftBorderChar = '|';
-
-Builder builder(BuilderOptions options) => CodeExcerptBuilder(options);
-
-class CodeExcerptBuilder implements Builder {
- static const outputExtension = '.excerpt.yaml';
-
- final BuilderOptions? options;
-
- CodeExcerptBuilder([this.options]);
-
- @override
- Future build(BuildStep buildStep) async {
- final assetId = buildStep.inputId;
- if (assetId.package.startsWith(r'$') || assetId.path.endsWith(r'$')) return;
-
- final String content;
- try {
- content = await buildStep.readAsString(assetId);
- } on FormatException {
- log.finest('Skipped ${assetId.path} due to failing to read as string.');
- return;
- }
-
- final outputAssetId = assetId.addExtension(outputExtension);
-
- final excerpter = Excerpter(assetId.path, content);
- final yaml = _toYaml(excerpter.weave().excerpts);
- if (yaml.isNotEmpty) {
- await buildStep.writeAsString(outputAssetId, yaml);
- log.info('wrote $outputAssetId');
- } else {
- // log.warning(' $outputAssetId has no excerpts');
- }
- }
-
- @override
- Map> get buildExtensions => {
- '': [outputExtension]
- };
-
- String _toYaml(Map> excerpts) {
- if (excerpts.isEmpty) return '';
-
- const yamlExcerptLeftBorderCharKey = '#border';
- final s = StringBuffer();
-
- s.writeln("'$yamlExcerptLeftBorderCharKey': '$excerptLineLeftBorderChar'");
- excerpts.forEach((name, lines) {
- s.writeln(_yamlEntry(name, lines));
- });
- return s.toString();
- }
-
- String _yamlEntry(String regionName, List lines) {
- final codeAsYamlStringValue = lines
- // YAML multiline string: indent by 2 spaces.
- .map((line) => ' $excerptLineLeftBorderChar$line')
- .join(eol);
- return "'$regionName': |+\n$codeAsYamlStringValue";
- }
-}
diff --git a/packages/code_excerpter/lib/src/directive.dart b/packages/code_excerpter/lib/src/directive.dart
deleted file mode 100644
index 7f12dcd..0000000
--- a/packages/code_excerpter/lib/src/directive.dart
+++ /dev/null
@@ -1,96 +0,0 @@
-/// Directives usually appear inside a line comment.
-///
-/// Ignore any close-comment syntax:
-///
-/// - CSS and Java-like languages: `*/`
-/// - HTML: `-->`
-///
-final _directiveRegEx = RegExp(
- r'^(\s*)(\S.*?)?#((?:end)?docregion)\b\s*(.*?)(?:\s*(?:-->|\*\/))?\s*$');
-
-final _argSeparator = RegExp(r'\s*,\s*');
-
-/// Represents a code-excerpter directive (both the model and lexical elements)
-class Directive {
- static const int _lexemeIndex = 3;
-
- final Match _match;
- final Kind kind;
-
- late final List _args;
-
- /// Issues raised while parsing this directive.
- final List issues = [];
-
- Directive._(this.kind, this._match) {
- final argsMaybeWithDups = _parseArgs();
- final argCounts = {};
-
- for (var arg in argsMaybeWithDups) {
- if (arg.isEmpty) {
- issues.add('unquoted default region name is deprecated');
- } else if (arg == "''") {
- arg = '';
- }
-
- var argCount = argCounts[arg] ?? 0;
- argCount += 1;
-
- if (argCount == 2) {
- issues.add('repeated argument "$arg"');
- }
-
- argCounts[arg] = argCount;
- }
-
- _args = argCounts.keys.toList();
- }
-
- String get line => _match[0] ?? '';
-
- /// Whitespace before the directive
- String get indentation => _match[1] ?? '';
-
- /// Characters at the start of the line before the directive lexeme
- String get prefix => indentation + (_match[2] ?? '');
-
- /// The directive's lexeme or empty if not found
- String get lexeme => _match[_lexemeIndex] ?? '';
-
- /// Raw string corresponding to the directive's arguments
- String get rawArgs => _match[4] ?? '';
-
- List get args => _args;
-
- static Directive? tryParse(String line) {
- final match = _directiveRegEx.firstMatch(line);
-
- if (match == null) return null;
-
- final lexeme = match[_lexemeIndex];
- final kind = tryParseKind(lexeme);
- return kind == null ? null : Directive._(kind, match);
- }
-
- List _parseArgs() =>
- rawArgs.isEmpty ? const [] : rawArgs.split(_argSeparator);
-}
-
-enum Kind {
- startRegion,
- endRegion,
- plaster, // TO be deprecated
-}
-
-Kind? tryParseKind(String? lexeme) {
- switch (lexeme) {
- case 'docregion':
- return Kind.startRegion;
- case 'enddocregion':
- return Kind.endRegion;
- case 'docplaster':
- return Kind.plaster;
- default:
- return null;
- }
-}
diff --git a/packages/code_excerpter/lib/src/excerpter.dart b/packages/code_excerpter/lib/src/excerpter.dart
deleted file mode 100644
index 2bd6ff1..0000000
--- a/packages/code_excerpter/lib/src/excerpter.dart
+++ /dev/null
@@ -1,186 +0,0 @@
-import 'directive.dart';
-import 'util/line.dart';
-import 'util/logging.dart';
-
-/// Key used for excerpt representing the entire file w/o directives
-const fullFileKey = '\u0000';
-const defaultRegionKey = '';
-const defaultPlaster = '···';
-
-Map> newExcerptsMap() => {};
-
-class Excerpter {
- final String uri;
- final String content;
- final List _lines; // content as list of lines
-
- // Index of next line to process.
- int _lineIdx;
- int get _lineNum => _lineIdx + 1;
- String get _line => _lines[_lineIdx];
-
- bool containsDirectives = false;
-
- int get numExcerpts => excerpts.length;
-
- Excerpter(this.uri, this.content)
- : _lines = content.split(eol),
- _lineIdx = 0;
-
- final Map> excerpts = newExcerptsMap();
- final Set _openExcerpts = {};
-
- Excerpter weave() {
- final lines = content.split(eol);
-
- // Collect the full file in case we need it.
- _excerptStart(fullFileKey);
-
- for (_lineIdx = 0; _lineIdx < lines.length; _lineIdx++) {
- _processLine();
- }
-
- // Drop trailing blank lines for all excerpts.
- // Normalize indentation for all but the full file.
- for (final entry in excerpts.entries) {
- final name = entry.key;
- final excerpt = entry.value;
-
- dropTrailingBlankLines(excerpt);
- _dropTrailingPlaster(excerpt);
- if (name == fullFileKey) continue;
- excerpts[name] = maxUnindent(excerpt).toList();
- }
-
- // Final adjustment to excerpts relative to fullFileKey:
- if (!containsDirectives) {
- // No directives? Don't report any excerpts
- excerpts.clear();
- } else if (excerpts.containsKey(defaultRegionKey)) {
- // There was an explicitly named default region. Drop fullFileKey.
- excerpts.remove(fullFileKey);
- } else {
- // Report fullFileKey excerpt for defaultRegionKey
- final fullFileExcerpt = excerpts.remove(fullFileKey);
- if (fullFileExcerpt != null) {
- excerpts[defaultRegionKey] = fullFileExcerpt;
- }
- }
- return this;
- }
-
- void _processLine() {
- final directive = Directive.tryParse(_line);
-
- if (directive == null) {
- // Add line to open regions
- for (final name in _openExcerpts) {
- excerpts[name]?.add(_line);
- }
- return;
- }
-
- directive.issues.forEach(_warn);
-
- switch (directive.kind) {
- case Kind.startRegion:
- containsDirectives = true;
- _startRegion(directive);
- case Kind.endRegion:
- containsDirectives = true;
- _endRegion(directive);
- default:
- throw Exception('Unimplemented directive: $_line');
- }
- }
-
- void _startRegion(Directive directive) {
- final regionAlreadyStarted = [];
- final regionNames = directive.args;
-
- log.finer('_startRegion(regionNames = $regionNames)');
-
- if (regionNames.isEmpty) regionNames.add(defaultRegionKey);
- for (final name in regionNames) {
- final isNew = _excerptStart(name);
- if (!isNew) {
- regionAlreadyStarted.add(_quoteName(name));
- }
- }
-
- _warnRegions(
- regionAlreadyStarted,
- (regions) => 'repeated start for $regions',
- );
- }
-
- void _endRegion(Directive directive) {
- final regionsWithoutStart = [];
- final regionNames = directive.args;
- log.finer('_endRegion(regionNames = $regionNames)');
-
- if (regionNames.isEmpty) {
- regionNames.add('');
- // _warn('${directive.lexeme} has no explicit arguments; assuming ""');
- }
-
- for (final name in regionNames) {
- if (_openExcerpts.remove(name)) {
- final excerpt = excerpts[name];
- if (excerpt == null) {
- return;
- }
-
- if (excerpt.isEmpty) {
- _warnRegions(
- [name],
- (regions) => 'empty $regions',
- );
- }
- excerpt.add(directive.indentation + defaultPlaster);
- } else {
- regionsWithoutStart.add(_quoteName(name));
- }
- }
-
- _warnRegions(
- regionsWithoutStart,
- (regions) => '$regions end without a prior start',
- );
- }
-
- void _warnRegions(
- List regions,
- String Function(String) msg,
- ) {
- if (regions.isEmpty) return;
- final joinedRegions = regions.join(', ');
- final s = joinedRegions.isEmpty
- ? ''
- : regions.length > 1
- ? 's ($joinedRegions)'
- : ' $joinedRegions';
- _warn(msg('region$s'));
- }
-
- /// Registers [name] as an open excerpt.
- ///
- /// If [name] is a new excerpt, then its value in
- /// [excerpts] is set to the empty list.
- ///
- /// Returns false iff name was already open
- bool _excerptStart(String name) {
- excerpts.putIfAbsent(name, () => []);
- return _openExcerpts.add(name);
- }
-
- void _warn(String msg) => log.warning('$msg at $uri:$_lineNum');
-
- /// Quote a region name if it isn't already quoted.
- String _quoteName(String name) => name.startsWith("'") ? name : '"$name"';
-
- void _dropTrailingPlaster(List excerpt) {
- if (excerpt.isEmpty || !excerpt.last.contains(defaultPlaster)) return;
- excerpt.removeLast();
- }
-}
diff --git a/packages/code_excerpter/lib/src/util/line.dart b/packages/code_excerpter/lib/src/util/line.dart
deleted file mode 100644
index 7e3497f..0000000
--- a/packages/code_excerpter/lib/src/util/line.dart
+++ /dev/null
@@ -1,37 +0,0 @@
-import 'dart:math' show min;
-
-const eol = '\n';
-
-final blankLine = RegExp(r'^\s*$');
-final _leadingWhitespace = RegExp(r'^[ \t]*');
-
-/// WARNING: this method potentially mutates its argument.
-void dropTrailingBlankLines(List lines) {
- // Drop any blank lines at the end of lines
- while (lines.isNotEmpty && blankLine.hasMatch(lines.last)) {
- lines.removeLast();
- }
-}
-
-/// Unindent [lines] to the extent possible without losing
-/// the relative inter-line indentation. Note that blank
-/// lines are ignored in the process computing the maximal
-/// left-shift.
-Iterable maxUnindent(Iterable lines) {
- final nonBlankLines = lines.where((s) => !blankLine.hasMatch(s));
-
- // Length of leading spaces to be trimmed
- final lengths = nonBlankLines.map((s) {
- final matchLength = _leadingWhitespace.firstMatch(s)?[0]?.length;
- return matchLength ?? 0;
- });
-
- if (lengths.isEmpty) {
- return lines;
- }
-
- final len = lengths.reduce(min);
- return len == 0
- ? lines
- : lines.map((line) => line.length < len ? line : line.substring(len));
-}
diff --git a/packages/code_excerpter/lib/src/util/logging.dart b/packages/code_excerpter/lib/src/util/logging.dart
deleted file mode 100644
index b82f5c6..0000000
--- a/packages/code_excerpter/lib/src/util/logging.dart
+++ /dev/null
@@ -1,45 +0,0 @@
-/// Exposes a singleton logger via [log].
-///
-/// The singleton logger is initialized as follows:
-///
-/// - If the build system logger is defined, that logger is used.
-/// - Otherwise, create a new Logger named 'package:code_excerpter'
-///
-library;
-
-import 'dart:async';
-
-import 'package:logging/logging.dart';
-
-const _buildLogKey = #buildLog;
-
-/// Initial logging level. It must be set before calling [log].
-Level initLevel = Level.FINE;
-
-/// The build logger or if there isn't one, a new default logger.
-final Logger log = () {
- // Use build logger if there is one:
- var logger = Zone.current[_buildLogKey] as Logger?;
-
- if (logger == null) {
- logger = Logger('package:code_excerpter');
- Logger.root.level = initLevel;
- Logger.root.onRecord.listen((r) {
- for (final h in logListeners) {
- h(r);
- }
- });
- }
-
- return logger;
-}();
-
-//---------------------------------------------------------
-
-typedef LogListener = void Function(LogRecord);
-
-final List logListeners = [
- printLogRecord,
-];
-
-void printLogRecord(LogRecord r) => print('${r.level.name}: ${r.message}');
diff --git a/packages/code_excerpter/mono_pkg.yaml b/packages/code_excerpter/mono_pkg.yaml
deleted file mode 100644
index d4e257b..0000000
--- a/packages/code_excerpter/mono_pkg.yaml
+++ /dev/null
@@ -1,12 +0,0 @@
-# See https://github.com/google/mono_repo.dart for details on this file
-sdk:
-- pubspec
-- dev
-
-stages:
-- analyzer_and_format:
- - group:
- - format
- - analyze: --fatal-infos .
-- unit_test:
- - test:
diff --git a/packages/code_excerpter/pubspec.yaml b/packages/code_excerpter/pubspec.yaml
deleted file mode 100644
index 4492cc2..0000000
--- a/packages/code_excerpter/pubspec.yaml
+++ /dev/null
@@ -1,17 +0,0 @@
-name: code_excerpter
-publish_to: none
-
-environment:
- sdk: ^3.4.0
-
-dependencies:
- build: ^2.4.1
- logging: ^1.2.0
- path: ^1.9.0
- yaml: ^3.1.2
-
-dev_dependencies:
- analysis_defaults:
- path: ../analysis_defaults
- build_runner: ^2.4.9
- test: ^1.25.2
diff --git a/packages/code_excerpter/test/builder_input/example.dart b/packages/code_excerpter/test/builder_input/example.dart
deleted file mode 100644
index 3090b05..0000000
--- a/packages/code_excerpter/test/builder_input/example.dart
+++ /dev/null
@@ -1,19 +0,0 @@
-// #docregion imports
-import 'dart:async';
-// #enddocregion imports
-
-// #docregion main, main-stub
-Future main() async {
- // #enddocregion main-stub
- print('Compute π using the Monte Carlo method.');
- await for (final estimate in computePi().take(500)) {
- print('π ≅ $estimate');
- }
- // #docregion main-stub
-}
-// #enddocregion main, main-stub
-
-/// Generates a stream of increasingly accurate estimates of π.
-Stream computePi({int batch = 100000}) async* {
- // ...
-}
diff --git a/packages/code_excerpter/test/builder_input/example.html b/packages/code_excerpter/test/builder_input/example.html
deleted file mode 100644
index 01ade72..0000000
--- a/packages/code_excerpter/test/builder_input/example.html
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
- Title
-
-
-
-
-
-
-
-
-
diff --git a/packages/code_excerpter/test/builder_test.dart b/packages/code_excerpter/test/builder_test.dart
deleted file mode 100644
index 3866eb9..0000000
--- a/packages/code_excerpter/test/builder_test.dart
+++ /dev/null
@@ -1,25 +0,0 @@
-import 'dart:io';
-
-import 'package:build/build.dart';
-import 'package:code_excerpter/builder.dart';
-import 'package:test/test.dart';
-import 'package:yaml/yaml.dart';
-
-void main() {
- test('build.yaml build_extensions matches Builder', () {
- final buildYamlFile = File('build.yaml');
- final content = buildYamlFile.readAsStringSync();
- final yaml = loadYaml(content) as YamlMap;
- final builders = yaml['builders'] as Map;
- expect(builders, isNotNull);
- final codeExcerpter = builders['code_excerpter'] as Map;
- expect(codeExcerpter, isNotNull);
- final buildExtensions = codeExcerpter['build_extensions'] as Map;
- expect(buildExtensions, isNotNull);
- expect(buildExtensions, CodeExcerptBuilder().buildExtensions);
- });
-
- test('top-level builder factory function returns a CodeExcerptBuilder', () {
- expect(builder(BuilderOptions.empty), isA());
- });
-}
diff --git a/packages/code_excerpter/test/directive_test.dart b/packages/code_excerpter/test/directive_test.dart
deleted file mode 100644
index 7035825..0000000
--- a/packages/code_excerpter/test/directive_test.dart
+++ /dev/null
@@ -1,142 +0,0 @@
-import 'package:code_excerpter/src/directive.dart';
-import 'package:test/test.dart';
-
-void main() {
- group('basic', () {
- test('not a directive', () {
- final d = Directive.tryParse('');
- expect(d, isNull);
- });
-
- test(Kind.startRegion, () {
- final d = Directive.tryParse('#docregion');
- expect(d, isNotNull);
- if (d != null) {
- expect(d.kind, Kind.startRegion);
- expect(d.rawArgs, '');
- expect(d.args, []);
- }
- });
-
- test(Kind.endRegion, () {
- final d = Directive.tryParse('#enddocregion');
- expect(d, isNotNull);
- if (d != null) {
- expect(d.kind, Kind.endRegion);
- expect(d.rawArgs, '');
- expect(d.args, []);
- }
- });
- });
-
- // Leading and trailing text is ignored
- group('context insensitive', () {
- test(Kind.startRegion, () {
- const spaces = ' ';
- final d = Directive.tryParse('$spaces// #docregion');
- expect(d, isNotNull);
- if (d != null) {
- expect(d.kind, Kind.startRegion);
- expect(d.rawArgs, '');
- expect(d.args, []);
- expect(d.indentation, spaces);
- }
- });
-
- test(Kind.endRegion, () {
- final d = Directive.tryParse(' #enddocregion a,b, c ');
- expect(d, isNotNull);
- if (d != null) {
- expect(d.kind, Kind.endRegion);
- expect(d.rawArgs, 'a,b, c');
- expect(d.args, ['a', 'b', 'c']);
- expect(d.indentation, ' ');
- }
- });
- });
-
- group('close comment syntax:', () {
- group('HTML:', () {
- test(Kind.startRegion, () {
- final d = Directive.tryParse('');
- expect(d, isNotNull);
- if (d != null) {
- expect(d.kind, Kind.startRegion);
- expect(d.rawArgs, '');
- expect(d.args, []);
- expect(d.indentation, '');
- }
- });
-
- test(Kind.endRegion, () {
- final d = Directive.tryParse(' ');
- expect(d, isNotNull);
- if (d != null) {
- expect(d.kind, Kind.endRegion);
- expect(d.rawArgs, 'a');
- expect(d.args, ['a']);
- expect(d.indentation, '');
- }
- });
- });
-
- group('CSS:', () {
- test(Kind.startRegion, () {
- final d = Directive.tryParse('/*#docregion*/');
- expect(d, isNotNull);
- if (d != null) {
- expect(d.kind, Kind.startRegion);
- expect(d.rawArgs, '');
- expect(d.args, []);
- expect(d.indentation, '');
- }
- });
-
- test(Kind.endRegion, () {
- final d = Directive.tryParse('/* #enddocregion a */ ');
- expect(d, isNotNull);
- if (d != null) {
- expect(d.kind, Kind.endRegion);
- expect(d.rawArgs, 'a');
- expect(d.args, ['a']);
- expect(d.indentation, '');
- }
- });
- });
- });
-
- group('problem cases:', () {
- test('Deprecated unquoted default region name', () {
- final d = Directive.tryParse('#docregion ,a');
- expect(d, isNotNull);
- if (d != null) {
- expect(d.kind, Kind.startRegion);
- expect(d.rawArgs, ',a');
- expect(d.args, ['', 'a']);
- expect(d.issues, ['unquoted default region name is deprecated']);
- }
- });
-
- test('Duplicate "a" region', () {
- final d = Directive.tryParse('#docregion a,b,c,a');
- expect(d, isNotNull);
- if (d != null) {
- expect(d.kind, Kind.startRegion);
- expect(d.rawArgs, 'a,b,c,a');
- expect(d.args, ['a', 'b', 'c']);
- expect(d.issues, ['repeated argument "a"']);
- }
- });
-
- test('Duplicate "" region', () {
- final d = Directive.tryParse("#docregion '',''");
- expect(d, isNotNull);
- if (d != null) {
- expect(d.kind, Kind.startRegion);
- expect(d.rawArgs, "'',''");
- expect(d.args, ['']);
- expect(d.issues, ['repeated argument ""']);
- }
- });
- });
-}
diff --git a/packages/code_excerpter/test/excerpter_test.dart b/packages/code_excerpter/test/excerpter_test.dart
deleted file mode 100644
index aef840e..0000000
--- a/packages/code_excerpter/test/excerpter_test.dart
+++ /dev/null
@@ -1,337 +0,0 @@
-import 'package:code_excerpter/src/excerpter.dart';
-import 'package:code_excerpter/src/util/logging.dart';
-import 'package:logging/logging.dart';
-import 'package:test/test.dart';
-
-// Mock URI used for all content origins.
-const uri = 'foo';
-
-List contentGeneratingNoExcerpts = [
- '',
- 'abc',
- 'abc\ndef\n',
- 'docregion', // Without leading #
-];
-
-final emptyLines = List.unmodifiable([]);
-
-final List logs = [];
-
-void _expectNoLogs() => expect(logs, []);
-
-void main() {
- setUpAll(() {
- logListeners.clear(); // Don't print during tests
- logListeners.add(logs.add);
- });
-
- setUp(logs.clear);
-
- // Each individual test must check [logs], and then clear them.
- // This will catch situations where this is not done.
- tearDown(_expectNoLogs);
-
- test('helper sanity:', () {
- const content = '''
- #docregion a
- abc
- #enddocregion a
- #docregion b
- def
- #enddocregion b
- ''';
- expect(stripDirectives(content), [
- ' abc',
- ' def',
- ]);
- });
-
- group('no excerpts:', () {
- for (final content in contentGeneratingNoExcerpts) {
- final testName = "'${content.replaceAll('\n', '\\n')}'";
- test(testName, () {
- final excerpter = Excerpter(uri, content);
- excerpter.weave();
- expect(excerpter.excerpts, >{});
- _expectNoLogs();
- });
- }
- });
-
- // Independent of indentation
- group('basic delimited default region:', () {
- test('1-line region', () {
- final excerpter = Excerpter(uri, '#docregion\nabc\n#enddocregion');
- excerpter.weave();
- expect(excerpter.excerpts, {
- defaultRegionKey: ['abc']
- });
- _expectNoLogs();
- });
- });
-
- group('normalized indentation:', () {
- test('default region', () {
- final excerpter = Excerpter(uri, '''
- #docregion
- abc
- #enddocregion
- ''');
- expect(excerpter.weave().excerpts, {
- defaultRegionKey: ['abc']
- });
- _expectNoLogs();
- });
-
- test('region a', () {
- const content = '''
- #docregion a
- abc
- #enddocregion a
- ''';
- final excerpter = Excerpter(uri, content);
- expect(excerpter.weave().excerpts, {
- defaultRegionKey: [' abc'],
- 'a': ['abc'],
- });
- _expectNoLogs();
- });
- });
-
- test('two disjoint regions', () {
- const content = '''
- #docregion a
- abc
- #enddocregion a
- #docregion b
- def
- #enddocregion b
- ''';
- final excerpter = Excerpter(uri, content);
- expect(excerpter.weave().excerpts, {
- defaultRegionKey: stripDirectives(content),
- 'a': ['abc'],
- 'b': ['def'],
- });
- _expectNoLogs();
- });
-
- group('region not closed:', () {
- for (final eol in const ['', '\n']) {
- group('empty region:', () {
- test('default region', () {
- final excerpter = Excerpter(uri, '#docregion$eol');
- expect(excerpter.weave().excerpts, {defaultRegionKey: emptyLines});
- _expectNoLogs();
- });
-
- test('region a', () {
- final excerpter = Excerpter(uri, '#docregion a$eol');
- expect(excerpter.weave().excerpts,
- {defaultRegionKey: emptyLines, 'a': emptyLines});
- _expectNoLogs();
- });
- });
-
- test('region with a line', () {
- final expectedLines = ['abc'];
- final excerpter = Excerpter(uri, '#docregion b\nabc$eol');
- expect(excerpter.weave().excerpts,
- {defaultRegionKey: expectedLines, 'b': expectedLines});
- _expectNoLogs();
- });
- }
- });
-
- group('problems:', problemCases);
- group('plaster:', plasterCases);
-}
-
-void problemCases() {
- test('empty region', () {
- final excerpter = Excerpter(uri, '#docregion\n#enddocregion');
- excerpter.weave();
- expect(logs.length, 1);
- expect(logs[0].message, contains('empty region at $uri:2'));
- expect(excerpter.excerpts, {defaultRegionKey: []});
- logs.clear();
- });
-
- group('end before start', () {
- test('default region', () {
- final excerpter = Excerpter(uri, '#enddocregion');
- excerpter.weave();
- expect(logs.length, 1);
- expect(logs[0].message,
- contains('region "" end without a prior start at $uri:1'));
- expect(excerpter.excerpts, {defaultRegionKey: emptyLines});
- logs.clear();
- });
-
- test('region a', () {
- final excerpter = Excerpter(uri, 'abc\n#enddocregion a');
- excerpter.weave();
- expect(logs.length, 1);
- expect(logs[0].message,
- contains('region "a" end without a prior start at $uri:2'));
- expect(excerpter.excerpts, {
- defaultRegionKey: ['abc']
- });
- logs.clear();
- });
-
- test('region a,b', () {
- final excerpter = Excerpter(uri, 'abc\n#enddocregion a,b');
- excerpter.weave();
- expect(logs.length, 1);
- expect(logs[0].message,
- contains('regions ("a", "b") end without a prior start at $uri:2'));
- expect(excerpter.excerpts, {
- defaultRegionKey: ['abc']
- });
- logs.clear();
- });
-
- test('start a end default region', () {
- final expectedLines = ['abc'];
- final excerpter = Excerpter(uri, '#docregion a\nabc\n#enddocregion');
- excerpter.weave();
- expect(logs.length, 1);
- expect(logs[0].message,
- contains('region "" end without a prior start at $uri:3'));
- expect(excerpter.excerpts, {
- defaultRegionKey: expectedLines,
- 'a': expectedLines,
- });
- logs.clear();
- });
- });
-
- group('repeated start:', () {
- test('default region', () {
- final excerpter = Excerpter(uri, '#docregion\n#docregion');
- excerpter.weave();
- expect(logs.length, 1);
- expect(
- logs[0].message, contains('repeated start for region "" at $uri:2'));
- expect(excerpter.excerpts, {
- defaultRegionKey: [],
- });
- logs.clear();
- });
-
- test('region a', () {
- final excerpter = Excerpter(uri, '#docregion a\n#docregion a');
- excerpter.weave();
- expect(logs.length, 1);
- expect(
- logs[0].message, contains('repeated start for region "a" at $uri:2'));
- expect(excerpter.excerpts, {
- defaultRegionKey: [],
- 'a': [],
- });
- logs.clear();
- });
- });
-
- group('directives:', () {
- test('warn unquoted default region name', () {
- final excerpter = Excerpter(uri, '#docregion ,a');
- excerpter.weave();
- expect(logs.length, 1);
- expect(logs[0].message,
- contains('unquoted default region name is deprecated at $uri:1'));
- expect(excerpter.excerpts, {
- defaultRegionKey: [],
- 'a': [],
- });
- logs.clear();
- });
-
- test('dup "a" region', () {
- final excerpter = Excerpter(uri, '#docregion a,a');
- excerpter.weave();
- expect(logs.length, 1);
- expect(logs[0].message, contains('repeated argument "a" at $uri:1'));
- expect(excerpter.excerpts, {
- defaultRegionKey: [],
- 'a': [],
- });
- logs.clear();
- });
- });
-}
-
-void plasterCases() {
- test('region a with 1 plaster', () {
- const content = '''
- #docregion a
- abc
- #enddocregion a
- 123
- #docregion a
- def
- #enddocregion a
- ''';
- final excerpter = Excerpter(uri, content);
- expect(excerpter.weave().excerpts, {
- defaultRegionKey: stripDirectives(content),
- 'a': ['abc', defaultPlaster, 'def'],
- });
- _expectNoLogs();
- });
-
- test('overlapping regions', () {
- const content = '''
- #docregion a,b,c
- abc
- #enddocregion b, c
- #docregion b
- def
- #enddocregion a, b
- ''';
- final excerpter = Excerpter(uri, content);
- expect(excerpter.weave().excerpts, {
- defaultRegionKey: stripDirectives(content),
- 'a': ['abc', 'def'],
- 'b': ['abc', defaultPlaster, 'def'],
- 'c': ['abc'],
- });
- _expectNoLogs();
- });
-
- test('plaster with different indentations', () {
- const content = '''
- #docregion a,b,c
- abc
- #enddocregion b, c
- #docregion b
- def
- #enddocregion a, b
- ''';
- final excerpter = Excerpter(uri, content);
- expect(excerpter.weave().excerpts, {
- defaultRegionKey: stripDirectives(content),
- 'a': ['abc', 'def'],
- 'b': ['abc', ' $defaultPlaster', 'def'],
- 'c': ['abc'],
- });
- _expectNoLogs();
- });
-}
-
-// Utils
-
-const eol = '\n';
-
-final _directiveRegEx = RegExp(r'#(end)?docregion');
-final _blankLine = RegExp(r'^\s*$');
-
-List stripDirectives(String excerpt) {
- final lines = excerpt
- .split(eol)
- .where((line) => !_directiveRegEx.hasMatch(line))
- .toList();
- if (_blankLine.hasMatch(lines.last)) lines.removeLast();
- return lines;
-}
diff --git a/packages/code_excerpter/test/util_test.dart b/packages/code_excerpter/test/util_test.dart
deleted file mode 100644
index 131b145..0000000
--- a/packages/code_excerpter/test/util_test.dart
+++ /dev/null
@@ -1,38 +0,0 @@
-import 'package:code_excerpter/src/util/line.dart';
-import 'package:test/test.dart';
-
-void main() {
- group('maxUnindent', () {
- test('empty list', () {
- expect(maxUnindent([]), []);
- });
-
- test('no leading space', () {
- final lines = ['abc'];
- expect(maxUnindent(lines), lines);
- });
-
- test('with leading space', () {
- final lines = [' abc'];
- expect(maxUnindent(lines), ['abc']);
- });
-
- test('trim one leading space', () {
- final lines = [' abc', ' def'];
- expect(maxUnindent(lines), [' abc', 'def']);
- });
-
- test('ignore blank lines', () {
- final lines = [
- ' abc',
- ' ',
- ' ',
- ' def',
- '',
- ' ',
- ];
- dropTrailingBlankLines(lines);
- expect(maxUnindent(lines), [' abc', '', ' ', 'def']);
- });
- });
-}