Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Unified Diff: pkg/docgen/lib/docgen.dart

Issue 116043013: Add a snapshot for docgen and use it in the build (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/docgen/lib/docgen.dart
diff --git a/pkg/docgen/lib/docgen.dart b/pkg/docgen/lib/docgen.dart
index d75b60f6910434507e801f508b942d694a4d4623..abc3eea59fcd0780250408947759cc1f06f35e39 100644
--- a/pkg/docgen/lib/docgen.dart
+++ b/pkg/docgen/lib/docgen.dart
@@ -42,11 +42,63 @@ 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'];
+/**
Bob Nystrom 2014/01/08 00:16:57 Use a ///-style doc comment like the rest of this
Alan Knight 2014/01/08 01:22:52 Done.
+ * 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
+ */
+const String DEFAULT_SDK_INTRODUCTION = """
Bob Nystrom 2014/01/08 00:16:57 You don't need to type annotate constants.
Alan Knight 2014/01/08 01:22:52 Done.
+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;
@@ -357,6 +409,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) {
+ 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 +432,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'
};
}

Powered by Google App Engine
This is Rietveld 408576698