Chromium Code Reviews| Index: pkg/docgen/lib/docgen.dart |
| diff --git a/pkg/docgen/lib/docgen.dart b/pkg/docgen/lib/docgen.dart |
| index a51ab86d0ad85fda06bf9eb98a81f24782ca1fe0..caf1067225125550c14fd188a4715b32acae65f8 100644 |
| --- a/pkg/docgen/lib/docgen.dart |
| +++ b/pkg/docgen/lib/docgen.dart |
| @@ -244,26 +244,50 @@ void _documentLibraries(List<LibraryMirror> libs, {bool includeSdk: false, |
| if (parseSdk) entityMap['dart.core.Object'].subclasses.clear(); |
| var filteredEntities = entityMap.values.where(_isVisible); |
| - // Output libraries and classes to file after all information is generated. |
| - filteredEntities.where((e) => e is Class || e is Library).forEach((output) { |
| - _writeIndexableToFile(output, outputToYaml); |
| - }); |
| + |
| // Outputs a YAML or JSON file with all libraries and their preview comments |
| // after creating all libraries. This will help the viewer know what |
| // libraries are available to read in. |
| - var libraryMap = { |
| - 'libraries' : filteredEntities.where((e) => |
| - e is Library).map((e) => e.previewMap).toList(), |
| - 'introduction' : introduction == '' ? |
| - '' : markdown.markdownToHtml(new File(introduction).readAsStringSync(), |
| - linkResolver: linkResolver, inlineSyntaxes: markdownSyntaxes) |
| - }; |
| - if (outputToYaml) { |
| - _writeToFile(getYamlString(libraryMap), 'library_list.yaml', |
| - append: append); |
| + var libraryMap; |
| + if (append) { |
| + var docsDir = listDir('docs'); |
| + if (docsDir.contains('docs/library_list.json')){ |
|
Bob Nystrom
2013/08/16 20:51:10
Nit: space before "{".
Also, I would flip the con
janicejl
2013/08/16 21:33:45
Done.
|
| + libraryMap = parse(new File('docs/library_list.json').readAsStringSync()); |
| + } else { |
| + throw new StateError('No library_list.json.'); |
| + } |
| + libraryMap['libraries'].addAll(filteredEntities.where((e) => |
| + e is Library).map((e) => e.previewMap).toList()); |
|
Bob Nystrom
2013/08/16 20:51:10
Nit, how about wrapping this on ".", like:
librar
janicejl
2013/08/16 21:33:45
Done.
|
| + if (introduction.isNotEmpty) { |
| + var intro = libraryMap['introduction']; |
| + if (intro.isNotEmpty) { |
| + intro = intro + '<br/><br/>' + markdown.markdownToHtml( |
|
Bob Nystrom
2013/08/16 20:51:10
intro += '<br/><br/>'...
Bob Nystrom
2013/08/16 20:51:10
You can get rid of some duplicate code:
var intro
janicejl
2013/08/16 21:33:45
Done.
|
| + new File(introduction).readAsStringSync(), |
| + linkResolver: linkResolver, inlineSyntaxes: markdownSyntaxes); |
| + } else { |
| + intro = markdown.markdownToHtml(new File(introduction) |
| + .readAsStringSync(), linkResolver: linkResolver, |
| + inlineSyntaxes: markdownSyntaxes); |
| + } |
| + libraryMap['introduction'] = intro; |
| + } |
| + outputToYaml = libraryMap['filetype'] == 'yaml'; |
| } else { |
| - _writeToFile(stringify(libraryMap), 'library_list.json', append: append); |
| + libraryMap = { |
| + 'libraries' : filteredEntities.where((e) => |
| + e is Library).map((e) => e.previewMap).toList(), |
| + 'introduction' : introduction == '' ? |
| + '' : markdown.markdownToHtml(new File(introduction) |
| + .readAsStringSync(), linkResolver: linkResolver, |
| + inlineSyntaxes: markdownSyntaxes), |
| + 'filetype' : outputToYaml ? 'yaml' : 'json' |
| + }; |
| } |
| + _writeToFile(stringify(libraryMap), 'library_list.json'); |
| + // Output libraries and classes to file after all information is generated. |
| + filteredEntities.where((e) => e is Class || e is Library).forEach((output) { |
| + _writeIndexableToFile(output, outputToYaml); |
| + }); |
| // Outputs all the qualified names documented with their type. |
| // This will help generate search results. |
| _writeToFile(filteredEntities.map((e) => |