8ae255d876
Some requests have additional newlines, so this change allows any number instead of exactly one. Change-Id: Ie32b525b9b834223f91cd6339f6932fb02007c78 Reviewed-on: https://dart-review.googlesource.com/c/87060 Auto-Submit: Danny Tuppeny <dantup@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
26 lines
880 B
Dart
26 lines
880 B
Dart
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
final _typeScriptBlockPattern =
|
|
new RegExp(r'\B```typescript([\S\s]*?)\n```', multiLine: true);
|
|
final _methodNamesPattern = new RegExp(
|
|
r'''_(?:Notification|Request):?_:?(?:\r?\n)+\* method: '(.*?)'\r?\n''',
|
|
multiLine: true);
|
|
|
|
/// Extracts fenced code blocks that are explicitly marked as TypeScript from a
|
|
/// markdown document.
|
|
List<String> extractTypeScriptBlocks(String text) {
|
|
return _typeScriptBlockPattern
|
|
.allMatches(text)
|
|
.map((m) => m.group(1).trim())
|
|
.toList();
|
|
}
|
|
|
|
List<String> extractMethodNames(String spec) {
|
|
return _methodNamesPattern
|
|
.allMatches(spec)
|
|
.map((m) => m.group(1).trim())
|
|
.toList();
|
|
}
|