mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 10:49:00 +00:00
[VM/Service] Fix package generator
package:markdown was updated to follow CommonMark's rules for encoding
certain special characters as HTMLEntities.
See 43bafebbe8/lib/src/util.dart (L15)
This CL updates the package:vm_service generators to handle these
changes.
Change-Id: I4e2e4c1c800a44ff1f3b9e7e163d60876cd6b013
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272522
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
This commit is contained in:
parent
be7779ae7f
commit
dba1e5fd3f
4 changed files with 26 additions and 16 deletions
|
@ -937,10 +937,10 @@ abstract class VmServiceInterface {
|
|||
/// their resolved (or absolute) paths. For example, URIs passed to this RPC
|
||||
/// are mapped in the following ways:
|
||||
///
|
||||
/// - `dart:io` -> `org-dartlang-sdk:///sdk/lib/io/io.dart`
|
||||
/// - `package:test/test.dart` ->
|
||||
/// - `dart:io` -> `org-dartlang-sdk:///sdk/lib/io/io.dart`
|
||||
/// - `package:test/test.dart` ->
|
||||
/// `file:///$PACKAGE_INSTALLATION_DIR/lib/test.dart`
|
||||
/// - `file:///foo/bar/bazz.dart` -> `file:///foo/bar/bazz.dart`
|
||||
/// - `file:///foo/bar/bazz.dart` -> `file:///foo/bar/bazz.dart`
|
||||
///
|
||||
/// If a URI is not known, the corresponding entry in the [UriList] response
|
||||
/// will be `null`.
|
||||
|
@ -956,10 +956,10 @@ abstract class VmServiceInterface {
|
|||
/// unresolved paths. For example, URIs passed to this RPC are mapped in the
|
||||
/// following ways:
|
||||
///
|
||||
/// - `org-dartlang-sdk:///sdk/lib/io/io.dart` -> `dart:io`
|
||||
/// - `file:///$PACKAGE_INSTALLATION_DIR/lib/test.dart` ->
|
||||
/// - `org-dartlang-sdk:///sdk/lib/io/io.dart` -> `dart:io`
|
||||
/// - `file:///$PACKAGE_INSTALLATION_DIR/lib/test.dart` ->
|
||||
/// `package:test/test.dart`
|
||||
/// - `file:///foo/bar/bazz.dart` -> `file:///foo/bar/bazz.dart`
|
||||
/// - `file:///foo/bar/bazz.dart` -> `file:///foo/bar/bazz.dart`
|
||||
///
|
||||
/// If a URI is not known, the corresponding entry in the [UriList] response
|
||||
/// will be `null`.
|
||||
|
|
|
@ -36,6 +36,20 @@ String titleCase(String str) =>
|
|||
String lowerTitleCase(String str) =>
|
||||
str.substring(0, 1).toLowerCase() + str.substring(1);
|
||||
|
||||
/// Certain special characters are encoded as HTML entities by the Markdown
|
||||
/// parser, this function changes those HTML entities back into the characters
|
||||
/// they represent.
|
||||
String replaceHTMLEntities(String text) {
|
||||
return text
|
||||
// TODO(derekx): Remove the line handling single-quotes once the
|
||||
// package:markdown dep is bumped to ^7.0.0.
|
||||
.replaceAll(''', "'")
|
||||
.replaceAll('"', '"')
|
||||
.replaceAll('&', '&')
|
||||
.replaceAll('<', '<')
|
||||
.replaceAll('>', '>');
|
||||
}
|
||||
|
||||
String joinLast(Iterable<String> strs, String join, [String? last]) {
|
||||
if (strs.isEmpty) return '';
|
||||
List list = strs.toList();
|
||||
|
|
|
@ -468,11 +468,9 @@ class Api extends Member with ApiParseUtil {
|
|||
String? get docs => null;
|
||||
|
||||
void _parse(String name, String definition, [String? docs]) {
|
||||
name = name.trim();
|
||||
definition = definition.trim();
|
||||
// clean markdown introduced changes
|
||||
definition = definition.replaceAll('<', '<').replaceAll('>', '>');
|
||||
if (docs != null) docs = docs.trim();
|
||||
name = replaceHTMLEntities(name.trim());
|
||||
definition = replaceHTMLEntities(definition.trim());
|
||||
if (docs != null) docs = replaceHTMLEntities(docs.trim());
|
||||
|
||||
if (definition.startsWith('class ')) {
|
||||
types.add(Type(this, name, definition, docs));
|
||||
|
|
|
@ -308,11 +308,9 @@ class Api extends Member with ApiParseUtil {
|
|||
}
|
||||
|
||||
void _parse(String name, String definition, [String? docs]) {
|
||||
name = name.trim();
|
||||
definition = definition.trim();
|
||||
// clean markdown introduced changes
|
||||
definition = definition.replaceAll('<', '<').replaceAll('>', '>');
|
||||
if (docs != null) docs = docs.trim();
|
||||
name = replaceHTMLEntities(name.trim());
|
||||
definition = replaceHTMLEntities(definition.trim());
|
||||
if (docs != null) docs = replaceHTMLEntities(docs.trim());
|
||||
|
||||
if (definition.startsWith('class ')) {
|
||||
types.add(Type(this, scriptLocation, name, definition, docs));
|
||||
|
|
Loading…
Reference in a new issue