Chromium Code Reviews| Index: pkg/docgen/lib/docgen.dart |
| diff --git a/pkg/docgen/lib/docgen.dart b/pkg/docgen/lib/docgen.dart |
| index d75b60f6910434507e801f508b942d694a4d4623..a2a71b1998a866ed667ec2391323802e9e02d7a4 100644 |
| --- a/pkg/docgen/lib/docgen.dart |
| +++ b/pkg/docgen/lib/docgen.dart |
| @@ -42,11 +42,61 @@ var _outputDirectory; |
| const String USAGE = 'Usage: dart docgen.dart [OPTIONS] fooDir/barFile'; |
| - |
| List<String> skippedAnnotations = const [ |
| 'metadata.DocsEditable', '_js_helper.JSName', '_js_helper.Creates', |
| '_js_helper.Returns']; |
| +/// If we can't find the SDK introduction text, which will happen if running |
| +/// from a snapshot and using --parse-sdk or --include-sdk, then use this |
| +/// hard-coded version. This should be updated to be consistent with the text |
| +/// in docgen/doc/sdk-introduction.md |
|
ricow1
2014/01/08 06:39:49
any reason to keep it in that file then? if we onl
Alan Knight
2014/01/08 22:19:02
Sounds reasonable. Done.
|
| +const DEFAULT_SDK_INTRODUCTION = """ |
| +Welcome to the Dart API reference documentation, |
| +covering the official Dart API libraries. |
| +Some of the most fundamental Dart libraries include: |
| + |
| +* [dart:core](#dart:core): |
| + Core functionality such as strings, numbers, collections, errors, |
| + dates, and URIs. |
| +* [dart:html](#dart:html): |
| + DOM manipulation for web apps. |
| +* [dart:io](#dart:io): |
| + I/O for command-line apps. |
| + |
| +Except for dart:core, you must import a library before you can use it. |
| +Here's an example of importing dart:html, dart:math, and a |
| +third popular library called |
| +[polymer.dart](http://www.dartlang.org/polymer-dart/): |
| + |
| + import 'dart:html'; |
| + import 'dart:math'; |
| + import 'package:polymer/polymer.dart'; |
| + |
| +Polymer.dart is an example of a library that isn't |
| +included in the Dart download, |
| +but is easy to get and update using the _pub package manager_. |
| +For information on finding, using, and publishing libraries (and more) |
| +with pub, see |
| +[pub.dartlang.org](http://pub.dartlang.org). |
| + |
| +The main site for learning and using Dart is |
| +[www.dartlang.org](http://www.dartlang.org). |
| +Check out these pages: |
| + |
| + * [Dart homepage](http://www.dartlang.org) |
| + * [Tutorials](http://www.dartlang.org/docs/tutorials/) |
| + * [Programmer's Guide](http://www.dartlang.org/docs/) |
| + * [Samples](http://www.dartlang.org/samples/) |
| + * [A Tour of the Dart Libraries](http://www.dartlang.org/docs/dart-up-and-running/contents/ch03.html) |
| + |
| +This API reference is automatically generated from the source code in the |
| +[Dart project](https://code.google.com/p/dart/). |
| +If you'd like to contribute to this documentation, see |
| +[Contributing](https://code.google.com/p/dart/wiki/Contributing) |
| +and |
| +[Writing API Documentation](https://code.google.com/p/dart/wiki/WritingApiDocumentation). |
| +"""; |
| + |
| /// Set of libraries declared in the SDK, so libraries that can be accessed |
| /// when running dart by default. |
| Iterable<LibraryMirror> _sdkLibraries; |
| @@ -152,7 +202,7 @@ Future<bool> docgen(List<String> files, {String packageRoot, |
| /// All of the directories for our dependent packages |
| List<String> allDependentPackageDirs(String packageDirectory) { |
| - var dependentsJson = Process.runSync('pub', ['list-package-dirs'], |
| + var dependentsJson = Process.runSync('/Users/alanknight/dart-git/dart/xcodebuild/ReleaseIA32/dart-sdk/bin/pub', ['list-package-dirs'], |
|
kustermann
2014/01/08 08:39:18
Why do you have a hardcoded path to pub here?
Alan Knight
2014/01/08 22:19:02
Yikes. That was debugging code. Removed, thanks.
|
| workingDirectory: packageDirectory, runInShell: true); |
| if (dependentsJson.exitCode != 0) { |
| print(dependentsJson.stderr); |
| @@ -258,7 +308,7 @@ String _findPackageRoot(String directory) { |
| if (packageRoot != '') { |
| packageRoot = path.join(path.dirname(packageRoot), 'packages'); |
| } |
| - return packageRoot; |
| + return path.normalize(path.absolute(packageRoot)); |
| } |
| /// Read a pubspec and return the library name. |
| @@ -357,6 +407,15 @@ void _documentLibraries(List<LibraryMirror> libs, {bool includeSdk: false, |
| // This will help the viewer know what libraries are available to read in. |
| var libraryMap; |
| var linkResolver = (name) => fixReference(name, null, null, null); |
| + |
| + String readIntro(String introFileName) { |
|
kustermann
2014/01/08 08:39:18
Rename to readIntroductionFile?
Alan Knight
2014/01/08 22:19:02
Done.
|
| + var introFile = new File(introFileName); |
| + var introText = introFile.existsSync() ? introFile.readAsStringSync() : |
| + DEFAULT_SDK_INTRODUCTION; |
| + return markdown.markdownToHtml(introText, |
| + linkResolver: linkResolver, inlineSyntaxes: markdownSyntaxes); |
| + } |
| + |
| if (append) { |
| var docsDir = listDir(_outputDirectory); |
| if (!docsDir.contains('$_outputDirectory/library_list.json')) { |
| @@ -371,20 +430,14 @@ void _documentLibraries(List<LibraryMirror> libs, {bool includeSdk: false, |
| if (introduction.isNotEmpty) { |
| var intro = libraryMap['introduction']; |
| if (intro.isNotEmpty) intro += '<br/><br/>'; |
| - intro += markdown.markdownToHtml( |
| - new File(introduction).readAsStringSync(), |
| - linkResolver: linkResolver, inlineSyntaxes: markdownSyntaxes); |
| - libraryMap['introduction'] = intro; |
| + libraryMap['introduction'] = "$intro${readIntro(introduction)}"; |
| } |
| outputToYaml = libraryMap['filetype'] == 'yaml'; |
| } else { |
| 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), |
| + 'introduction' : introduction.isEmpty ? '' : readIntro(introduction), |
| 'filetype' : outputToYaml ? 'yaml' : 'json' |
| }; |
| } |