From ce9b4cdef2d7e52dd3993d68850997c655d74ef7 Mon Sep 17 00:00:00 2001 From: Seth Ladd Date: Fri, 7 Aug 2015 12:42:31 -0700 Subject: [PATCH] upgrade markdown, fixes bug with names with multiple underscores Closes #784 LGTM given by: @keertip Squashed commit of the following: commit 42068841c321b13ac7f9e072edad56d3c80c03ed Author: Seth Ladd Date: Fri Aug 7 11:32:48 2015 -0700 upgrade markdown, fixes bug with names with multiple underscores --- pubspec.lock | 2 +- pubspec.yaml | 2 +- test/model_test.dart | 150 +++++++++++++++++++++++++++---------------- 3 files changed, 96 insertions(+), 58 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index ec9156362b..47c7b29cca 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -88,7 +88,7 @@ packages: markdown: description: markdown source: hosted - version: "0.7.1+3" + version: "0.7.2" matcher: description: matcher source: hosted diff --git a/pubspec.yaml b/pubspec.yaml index 62aa51ad8f..febc1a7389 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: html: ^0.12.1 http: ^0.11.0 logging: '>=0.9.0 <0.12.0' - markdown: ^0.7.1 + markdown: ^0.7.2 mustache4dart: ^1.0.9 path: ^1.3.0 pub_cache: ^0.1.0 diff --git a/test/model_test.dart b/test/model_test.dart index 72351a9699..991e1e6d20 100644 --- a/test/model_test.dart +++ b/test/model_test.dart @@ -34,7 +34,8 @@ void main() { exit(1); } - Package sdkAsPackage = new Package(getSdkLibrariesToDocument( + Package sdkAsPackage = new Package( + getSdkLibrariesToDocument( testUtils.sdkDir, testUtils.analyzerHelper.context), new PackageMeta.fromSdk(sdkDir)); @@ -93,7 +94,8 @@ void main() { Library dartAsyncLib; setUp(() { - dartAsyncLib = new Library(getSdkLibrariesToDocument( + dartAsyncLib = new Library( + getSdkLibrariesToDocument( testUtils.sdkDir, testUtils.analyzerHelper.context).first, sdkAsPackage); @@ -224,33 +226,33 @@ void main() { }); test('links to a reference to its class', () { - expect(docsAsHtml, contains( - 'BaseForDocComments')); + expect( + docsAsHtml, + contains( + 'BaseForDocComments')); }); test( 'links to a reference to a top-level const with multiple underscores', () { expect( - docsAsHtml, contains('NAME_WITH_TWO_UNDERSCORES')); - }, skip: 'Wait for https://github.com/dart-lang/dartdoc/issues/768'); - - // remove this test when the above is fixed. just here to track when - // the behavior changes - test( - 'literally renders a reference to a top-level const with multiple underscores', - () { - expect(docsAsHtml, contains('[NAME_WITH_TWO_UNDERSCORES]')); + docsAsHtml, + contains( + 'NAME_WITH_TWO_UNDERSCORES')); }); test('links to a method in this class', () { - expect(docsAsHtml, contains( - 'anotherMethod')); + expect( + docsAsHtml, + contains( + 'anotherMethod')); }); test('links to a top-level function in this library', () { - expect(docsAsHtml, contains( - 'topLevelFunction')); + expect( + docsAsHtml, + contains( + 'topLevelFunction')); }); test('links to top-level function from an imported library', () { @@ -263,34 +265,44 @@ void main() { }); test('links to a top-level const from an imported lib', () { - expect(docsAsHtml, contains( - 'incorrectDocReference')); + expect( + docsAsHtml, + contains( + 'incorrectDocReference')); }); test('links to a top-level variable with a prefix from an imported lib', () { expect(docsAsHtml, contains('css.theOnlyThingInTheLibrary')); - }, skip: 'Wait for https://github.com/dart-lang/dartdoc/issues/767 to be fixed'); + }, + skip: + 'Wait for https://github.com/dart-lang/dartdoc/issues/767 to be fixed'); // remove this test when the above test is fixed. just here to // track when the behavior changes test('codeifies a prefixed top-level variable an imported lib', () { - expect(docsAsHtml, contains( - 'css.theOnlyThingInTheLibrary')); + expect( + docsAsHtml, + contains( + 'css.theOnlyThingInTheLibrary')); }); test('links to a name with a single underscore', () { - expect(docsAsHtml, contains( - 'NAME_SINGLEUNDERSCORE')); + expect( + docsAsHtml, + contains( + 'NAME_SINGLEUNDERSCORE')); }); }); test('multi-underscore names in brackets do not become italicized', () { expect(short.documentation, contains('[NAME_WITH_TWO_UNDERSCORES]')); - expect(short.documentationAsHtml, contains( - 'NAME_WITH_TWO_UNDERSCORES')); - }, skip: 'Wait for https://github.com/dart-lang/dartdoc/issues/768'); + expect( + short.documentationAsHtml, + contains( + 'NAME_WITH_TWO_UNDERSCORES')); + }); test('still has brackets inside code blocks', () { expect(topLevelFunction.documentationAsHtml, @@ -301,8 +313,10 @@ void main() { () { Method add = specialList.allInstanceMethods.firstWhere((m) => m.name == 'add'); - expect(add.oneLineDoc, equals( - 'Adds value to the end of this list,\nextending the length by one.')); + expect( + add.oneLineDoc, + equals( + 'Adds value to the end of this list,\nextending the length by one.')); }); test( @@ -310,8 +324,10 @@ void main() { () { Method add = specialList.allInstanceMethods.firstWhere((m) => m.name == 'add'); - expect(add.documentationAsHtml, startsWith( - '

Adds value to the end of this list,\nextending the length by one.')); + expect( + add.documentationAsHtml, + startsWith( + '

Adds value to the end of this list,\nextending the length by one.')); }); test('incorrect doc references are still wrapped in code blocks', () { @@ -330,8 +346,10 @@ void main() { }); test('doc ref to class in SDK does not render as link', () { - expect(thisIsAsync.documentationAsHtml, equals( - '

An async function. It should look like I return a Future.

')); + expect( + thisIsAsync.documentationAsHtml, + equals( + '

An async function. It should look like I return a Future.

')); }); test('references are correct in exported libraries', () { @@ -341,8 +359,10 @@ void main() { expect(resolved, isNotNull); expect(resolved, contains('BaseClass')); - expect(resolved, contains( - 'linking over to Apple.')); + expect( + resolved, + contains( + 'linking over to Apple.')); }); test('references to class and constructors', () { @@ -351,8 +371,10 @@ void main() { contains('Extends class Apple')); expect( comment, contains('use new Apple')); - expect(comment, contains( - 'new Apple.fromString')); + expect( + comment, + contains( + 'new Apple.fromString')); }); test('reference to class from another library', () { @@ -362,13 +384,17 @@ void main() { test('reference to method', () { String comment = foo2.documentationAsHtml; - expect(comment, equals( - '

link to method from class Apple.m

')); + expect( + comment, + equals( + '

link to method from class Apple.m

')); }); test('legacy code blocks render correctly', () { - expect(testingCodeSyntaxInOneLiners.oneLineDoc, equals( - 'These are code syntaxes: true and false')); + expect( + testingCodeSyntaxInOneLiners.oneLineDoc, + equals( + 'These are code syntaxes: true and false')); }); test('doc comments to parameters are marked as code', () { @@ -493,8 +519,8 @@ void main() { test('exported class should have linkedReturnType for the current library', () { - Method toUTC = DT.instanceMethods.firstWhere((m) => m.name == 'toUtc', - orElse: () => null); + Method toUTC = DT.instanceMethods + .firstWhere((m) => m.name == 'toUtc', orElse: () => null); expect(toUTC, isNotNull); expect(toUTC.linkedReturnType, equals('DateTime')); @@ -626,10 +652,14 @@ void main() { test('async function', () { expect(thisIsAsync.isAsynchronous, isTrue); expect(thisIsAsync.linkedReturnType, equals('Future')); - expect(thisIsAsync.documentation, equals( - 'An async function. It should look like I return a [Future].')); - expect(thisIsAsync.documentationAsHtml, equals( - '

An async function. It should look like I return a Future.

')); + expect( + thisIsAsync.documentation, + equals( + 'An async function. It should look like I return a [Future].')); + expect( + thisIsAsync.documentationAsHtml, + equals( + '

An async function. It should look like I return a Future.

')); }); test('docs do not lose brackets in code blocks', () { @@ -637,8 +667,10 @@ void main() { }); test('has source code', () { - expect(topLevelFunction.sourceCode, startsWith( - '/// Top-level function 3 params and 1 optional positional param.')); + expect( + topLevelFunction.sourceCode, + startsWith( + '/// Top-level function 3 params and 1 optional positional param.')); expect(topLevelFunction.sourceCode, endsWith(''' String topLevelFunction(int param1, bool param2, Cool coolBeans, [double optionalPositional = 0.0]) { @@ -658,7 +690,8 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, fakeLibrary.classes.singleWhere((c) => c.name == 'HasGenerics'); m = classB.instanceMethods.first; isGreaterThan = exLibrary.classes - .singleWhere((c) => c.name == 'Apple').instanceMethods + .singleWhere((c) => c.name == 'Apple') + .instanceMethods .singleWhere((m) => m.name == 'isGreaterThan'); m4 = classB.instanceMethods[1]; m5 = klass.instanceMethods.singleWhere((m) => m.name == 'another'); @@ -722,8 +755,9 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, onlySetter = LongFirstLine.instanceProperties .firstWhere((p) => p.name == 'onlySetter'); - lengthX = fakeLibrary.classes.firstWhere( - (c) => c.name == 'WithGetterAndSetter').allInstanceProperties + lengthX = fakeLibrary.classes + .firstWhere((c) => c.name == 'WithGetterAndSetter') + .allInstanceProperties .firstWhere((c) => c.name == 'lengthX'); }); @@ -857,7 +891,8 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, setUp(() { fList = exLibrary.classes - .firstWhere((c) => c.name == 'B').instanceProperties + .firstWhere((c) => c.name == 'B') + .instanceProperties .singleWhere((p) => p.name == 'list'); }); @@ -894,7 +929,8 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, isGreaterThan = c.instanceMethods.singleWhere((m) => m.name == 'isGreaterThan'); asyncM = exLibrary.classes - .firstWhere((c) => c.name == 'Dog').instanceMethods + .firstWhere((c) => c.name == 'Dog') + .instanceMethods .firstWhere((m) => m.name == 'foo'); intNumber = isGreaterThan.parameters.first; intCheckOptional = isGreaterThan.parameters.last; @@ -1007,8 +1043,10 @@ String topLevelFunction(int param1, bool param2, Cool coolBeans, () => expect(forAnnotation.annotations, hasLength(1))); test('has the right annotation', () { - expect(forAnnotation.annotations.first, equals( - 'ForAnnotation(\'my value\')')); + expect( + forAnnotation.annotations.first, + equals( + 'ForAnnotation(\'my value\')')); }); test('methods has the right annotation', () {