-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: part directive * feat: library directive * feat: library augmentation * chore: update README * feat: support augmentation import * feat(test): part and part-of * feat(test): library * chore: format * chore: remove augment test * chore: format
- Loading branch information
Showing
7 changed files
with
125 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import 'package:analyzer/dart/ast/ast.dart'; | ||
import 'package:dartdoc_json/src/utils.dart'; | ||
|
||
Map<String, dynamic> serializeLibraryDirective(LibraryDirective library) { | ||
return filterMap(<String, dynamic>{ | ||
'kind': 'library', | ||
'name': library.name2?.name, | ||
}); | ||
} | ||
|
||
Map<String, dynamic> serializeLibraryAugmentationDirective( | ||
LibraryAugmentationDirective libraryAgumentation, | ||
) { | ||
return filterMap(<String, dynamic>{ | ||
'kind': 'library', | ||
'augmentation': true, | ||
'uri': libraryAgumentation.uri, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import 'package:analyzer/dart/ast/ast.dart'; | ||
import 'package:dartdoc_json/src/utils.dart'; | ||
|
||
Map<String, dynamic> serializePartDirective(PartDirective part) { | ||
return filterMap(<String, dynamic>{ | ||
'kind': 'part', | ||
'uri': part.uri.stringValue, | ||
}); | ||
} | ||
|
||
Map<String, dynamic> serializePartOfDirective(PartOfDirective partOf) { | ||
return filterMap(<String, dynamic>{ | ||
'kind': 'part-of', | ||
'uri': partOf.uri?.stringValue, | ||
'name': partOf.libraryName?.name, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import 'package:test/test.dart'; | ||
|
||
import 'utils.dart'; | ||
|
||
void main() { | ||
group('LibraryDirective', () { | ||
test('simple library', () { | ||
expect( | ||
parseAsJson('library foo;'), | ||
{'kind': 'library', 'name': 'foo'}, | ||
); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import 'package:test/test.dart'; | ||
|
||
import 'utils.dart'; | ||
|
||
void main() { | ||
group('PartDirective', () { | ||
test('simple part', () { | ||
expect( | ||
parseAsJson('part "foo.dart";'), | ||
{'kind': 'part', 'uri': 'foo.dart'}, | ||
); | ||
}); | ||
|
||
test('multiple part', () { | ||
expect( | ||
parseAsJson(''' | ||
part 'foo.dart'; | ||
part 'boo.dart'; | ||
'''), | ||
[ | ||
{'kind': 'part', 'uri': 'foo.dart'}, | ||
{'kind': 'part', 'uri': 'boo.dart'}, | ||
], | ||
); | ||
}); | ||
}); | ||
|
||
group('PartOfDirective', () { | ||
test('simple part', () { | ||
expect( | ||
parseAsJson('part of "foo.dart";'), | ||
{'kind': 'part-of', 'uri': 'foo.dart'}, | ||
); | ||
}); | ||
|
||
test('part of library', () { | ||
expect( | ||
parseAsJson(''' | ||
part of foo; | ||
'''), | ||
{'kind': 'part-of', 'name': 'foo'}, | ||
); | ||
}); | ||
}); | ||
} |