Several new features and improvements for dartdoc.

* Dartdoc now works on multiple libraries and entrypoints.
* A dartdoc/dartdoc.bat script is generated into dart-sdk/bin
* The API libraries recognized by dart2js using the 'dart:' prefix
  have been updated to use the 'dart:*' name in their library tags.
  This makes the libraries show up with the correct prefix in the API docs.
* The processed libraries can be selected or limited, API
  libraries are not processed by default, and links to api.dartlang.org
  can be generated for API libraries.

  Because of the changed library tags on API libraries, the generated
  links don't current match the addresses on api.dartlang.org.
  For instance, the docs for Object is currently located in
  api.dartlang.org/core/Object.html, but with the new library
  tag 'dart:core', the address will be api.dartlang.org/dart_core/Object.html.
  The links will thus not work until api.dartlang.org have been updated with
  this patch.
* Code and pre blocks use overflow-x:auto to support wide lines.

BUG=2656,2686,3533,4029,4145,3555

Review URL: https://chromiumcodereview.appspot.com//10809035

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@9843 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
johnniwinther@google.com 2012-07-24 09:16:33 +00:00
parent b8f94d0b59
commit c6d70857e4
21 changed files with 252 additions and 148 deletions

View file

@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#library("math");
#library("dart:math");
#source("base.dart");
#source("random.dart");

View file

@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#library('core');
#library('dart:core');
#import('coreimpl.dart');

View file

@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#library('coreimpl');
#library('dart:coreimpl');
#import('js_helper.dart');

View file

@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#library('interceptors');
#library('dart:_interceptors');
#import('coreimpl.dart');
#import('js_helper.dart');

View file

@ -9,7 +9,7 @@
// TODO(ahe): Separate API from implementation details.
#library("io");
#library("dart:io");
#import("dart:coreimpl");
#import("dart:isolate");
// TODO(ahe): Should Leg support this library?

View file

@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#library('js_helper');
#library('dart:_js_helper');
#import('coreimpl.dart');

View file

@ -10,44 +10,49 @@
* Simple struct holding the path to a library and an optional path
* to a patch file for the library.
*/
class LibraryPatchPath {
class LibraryInfo {
final String libraryPath;
final String patchPath;
const LibraryPatchPath(this.libraryPath, this.patchPath);
/** If [:true:], the library is not part of the public API. */
final bool isInternal;
const LibraryInfo(this.libraryPath,
[this.patchPath = null, this.isInternal = false]);
}
/**
* Specifies the location of Dart platform libraries.
*/
final Map<String,LibraryPatchPath> DART2JS_LIBRARY_MAP
= const <LibraryPatchPath> {
"core": const LibraryPatchPath(
"lib/compiler/implementation/lib/core.dart", null),
"coreimpl": const LibraryPatchPath(
"lib/compiler/implementation/lib/coreimpl.dart", null),
"_js_helper": const LibraryPatchPath(
"lib/compiler/implementation/lib/js_helper.dart", null),
"_interceptors": const LibraryPatchPath(
"lib/compiler/implementation/lib/interceptors.dart", null),
"crypto": const LibraryPatchPath(
"lib/crypto/crypto.dart", null),
"dom_deprecated": const LibraryPatchPath(
"lib/dom/frog/dom_frog.dart", null),
"html": const LibraryPatchPath(
"lib/html/frog/html_frog.dart", null),
"io": const LibraryPatchPath(
"lib/compiler/implementation/lib/io.dart", null),
"isolate": const LibraryPatchPath(
"lib/isolate/isolate_leg.dart", null),
"json": const LibraryPatchPath(
"lib/json/json.dart", null),
"math": const LibraryPatchPath(
final Map<String, LibraryInfo> DART2JS_LIBRARY_MAP
= const <LibraryInfo> {
"core": const LibraryInfo(
"lib/compiler/implementation/lib/core.dart"),
"coreimpl": const LibraryInfo(
"lib/compiler/implementation/lib/coreimpl.dart"),
"_js_helper": const LibraryInfo(
"lib/compiler/implementation/lib/js_helper.dart", isInternal: true),
"_interceptors": const LibraryInfo(
"lib/compiler/implementation/lib/interceptors.dart", isInternal: true),
"crypto": const LibraryInfo(
"lib/crypto/crypto.dart"),
"dom_deprecated": const LibraryInfo(
"lib/dom/frog/dom_frog.dart", isInternal: true),
"html": const LibraryInfo(
"lib/html/frog/html_frog.dart"),
"io": const LibraryInfo(
"lib/compiler/implementation/lib/io.dart"),
"isolate": const LibraryInfo(
"lib/isolate/isolate_leg.dart"),
"json": const LibraryInfo(
"lib/json/json.dart"),
"math": const LibraryInfo(
"corelib/unified/math/math.dart",
"lib/compiler/implementation/lib/math.dartp"),
"uri": const LibraryPatchPath(
"lib/uri/uri.dart", null),
"utf": const LibraryPatchPath(
"lib/utf/utf.dart", null),
"web": const LibraryPatchPath(
"lib/web/web.dart", null),
"lib/compiler/implementation/lib/math.dartp", isInternal: true),
"uri": const LibraryInfo(
"lib/uri/uri.dart"),
"utf": const LibraryInfo(
"lib/utf/utf.dart"),
"web": const LibraryInfo(
"lib/web/web.dart"),
};

View file

@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#library('crypto');
#library('dart:crypto');
#source('crypto_utils.dart');
#source('hash_utils.dart');

View file

@ -26,6 +26,7 @@
#import('markdown.dart', prefix: 'md');
#import('../compiler/implementation/scanner/scannerlib.dart',
prefix: 'dart2js');
#import('../compiler/implementation/library_map.dart');
#source('comment_map.dart');
#source('utils.dart');
@ -56,19 +57,15 @@ final MODE_STATIC = 0;
*/
final MODE_LIVE_NAV = 1;
final API_LOCATION = 'http://api.dartlang.org/';
/**
* Run this from the `lib/dartdoc` directory.
*/
void main() {
final args = new Options().arguments;
// Parse the dartdoc options.
bool includeSource;
int mode;
Path outputDir;
bool generateAppCache;
bool omitGenerationTime;
bool verbose;
final dartdoc = new Dartdoc();
if (args.isEmpty()) {
print('No arguments provided.');
@ -76,37 +73,57 @@ void main() {
return;
}
for (int i = 0; i < args.length - 1; i++) {
final entrypoints = <Path>[];
var i = 0;
while (i < args.length) {
final arg = args[i];
if (!arg.startsWith('--')) {
// The remaining arguments must be entry points.
break;
}
switch (arg) {
case '--no-code':
includeSource = false;
dartdoc.includeSource = false;
break;
case '--mode=static':
mode = MODE_STATIC;
dartdoc.mode = MODE_STATIC;
break;
case '--mode=live-nav':
mode = MODE_LIVE_NAV;
dartdoc.mode = MODE_LIVE_NAV;
break;
case '--generate-app-cache':
case '--generate-app-cache=true':
generateAppCache = true;
dartdoc.generateAppCache = true;
break;
case '--omit-generation-time':
omitGenerationTime = true;
dartdoc.omitGenerationTime = true;
break;
case '--verbose':
verbose = true;
dartdoc.verbose = true;
break;
case '--include-api':
dartdoc.includeApi = true;
break;
case '--link-api':
dartdoc.linkToApi = true;
break;
default:
if (arg.startsWith('--out=')) {
outputDir = new Path.fromNative(arg.substring('--out='.length));
dartdoc.outputDir =
new Path.fromNative(arg.substring('--out='.length));
} else if (arg.startsWith('--include-lib=')) {
dartdoc.includedLibraries =
arg.substring('--include-lib='.length).split(',');
} else if (arg.startsWith('--exclude-lib=')) {
dartdoc.excludedLibraries =
arg.substring('--exclude-lib='.length).split(',');
} else {
print('Unknown option: $arg');
printUsage();
@ -114,24 +131,23 @@ void main() {
}
break;
}
i++;
}
while (i < args.length) {
final arg = args[i];
entrypoints.add(new Path.fromNative(arg));
i++;
}
final entrypoint = new Path.fromNative(args[args.length - 1]);
final dartdoc = new Dartdoc();
if (includeSource != null) dartdoc.includeSource = includeSource;
if (mode != null) dartdoc.mode = mode;
if (outputDir != null) dartdoc.outputDir = outputDir;
if (generateAppCache != null) dartdoc.generateAppCache = generateAppCache;
if (omitGenerationTime != null) {
dartdoc.omitGenerationTime = omitGenerationTime;
if (entrypoints.isEmpty()) {
print('No entrypoints provided.');
printUsage();
return;
}
if (verbose != null) dartdoc.verbose = verbose;
cleanOutputDirectory(dartdoc.outputDir);
dartdoc.documentEntryPoint(entrypoint, libPath);
dartdoc.documentLibraries(entrypoints, libPath);
// Compile the client-side code to JS.
final clientScript = (dartdoc.mode == MODE_STATIC) ? 'static' : 'live-nav';
@ -151,7 +167,7 @@ void main() {
void printUsage() {
print('''
Usage dartdoc [options] <entrypoint>
Usage dartdoc [options] <entrypoint(s)>
[options] include
--no-code Do not include source code in the documentation.
@ -179,6 +195,25 @@ Usage dartdoc [options] <entrypoint>
--out=<dir> Generates files into directory <dir>. If omitted
the files are generated into ./docs/
--link-api Link to the online language API in the generated
documentation. The option overrides inclusion
through --include-api or --include-lib.
--include-api Include the used API libraries in the generated
documentation. If the --link-api option is used,
this option is ignored.
--include-lib=<libs> Use this option to explicitly specify which
libraries to include in the documentation. If
omitted, all used libraries are included by
default. <libs> is comma-separated list of library
names.
--exclude-lib=<libs> Use this option to explicitly specify which
libraries to exclude from the documentation. If
omitted, no libraries are excluded. <libs> is
comma-separated list of library names.
--verbose Print verbose information during generation.
''');
}
@ -312,8 +347,17 @@ class Dartdoc {
/** Set by Dartdoc user to print extra information during generation. */
bool verbose = false;
/** Set this to select the libraries to document */
List<String> libraries = null;
/** Set this to include API libraries in the documentation. */
bool includeApi = false;
/** Set this to generate links to the online API. */
bool linkToApi = false;
/** Set this to select the libraries to include in the documentation. */
List<String> includedLibraries = const <String>[];
/** Set this to select the libraries to exclude from the documentation. */
List<String> excludedLibraries = const <String>[];
/**
* This list contains the libraries sorted in by the library name.
@ -353,11 +397,50 @@ class Dartdoc {
currentMember: _currentMember));
}
bool includeLibrary(LibraryMirror library) {
if (libraries != null) {
return libraries.indexOf(library.simpleName()) != -1;
/**
* Returns `true` if [library] is included in the generated documentation.
*/
bool shouldIncludeLibrary(LibraryMirror library) {
if (shouldLinkToPublicApi(library)) {
return false;
}
return true;
var includeByDefault = true;
String libraryName = library.simpleName();
if (!includedLibraries.isEmpty()) {
includeByDefault = false;
if (includedLibraries.indexOf(libraryName) != -1) {
return true;
}
}
if (excludedLibraries.indexOf(libraryName) != -1) {
return false;
}
if (libraryName.startsWith('dart:')) {
String suffix = libraryName.substring('dart:'.length);
LibraryInfo info = DART2JS_LIBRARY_MAP[suffix];
if (info != null) {
return !info.isInternal && includeApi;
}
}
return includeByDefault;
}
/**
* Returns `true` if links to the public API should be generated for
* [library].
*/
bool shouldLinkToPublicApi(LibraryMirror library) {
if (linkToApi) {
String libraryName = library.simpleName();
if (libraryName.startsWith('dart:')) {
String suffix = libraryName.substring('dart:'.length);
LibraryInfo info = DART2JS_LIBRARY_MAP[suffix];
if (info != null) {
return !info.isInternal;
}
}
}
return false;
}
String get footerContent(){
@ -391,7 +474,8 @@ class Dartdoc {
void _document(Compilation compilation) {
// Sort the libraries by name (not key).
_sortedLibraries = new List<LibraryMirror>.from(
compilation.mirrors().libraries().getValues().filter(includeLibrary));
compilation.mirrors().libraries().getValues().filter(
shouldIncludeLibrary));
_sortedLibraries.sort((x, y) {
return x.simpleName().toUpperCase().compareTo(
y.simpleName().toUpperCase());
@ -1281,7 +1365,9 @@ class Dartdoc {
assert(type is InterfaceMirror);
// Link to the type.
if (includeLibrary(type.library())) {
if (shouldLinkToPublicApi(type.library())) {
write('<a href="$API_LOCATION${typeUrl(type)}">${type.simpleName()}</a>');
} else if (shouldIncludeLibrary(type.library())) {
write(a(typeUrl(type), type.simpleName()));
} else {
write(type.simpleName());

View file

@ -52,7 +52,8 @@ pre, code {
margin: 22px 0;
padding: 0 4px;
border-radius: 4px;
overflow: hidden;
overflow-x:auto;
overflow-y:hidden;
}
a {

View file

@ -1,4 +1,4 @@
#library('dom');
#library('dart:dom_deprecated');
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a

View file

@ -1,4 +1,4 @@
#library('html');
#library('dart:html');
#import('dart:isolate');
#import('dart:json');
@ -4047,7 +4047,7 @@ class _CompositionEventImpl extends _UIEventImpl implements CompositionEvent nat
class _ConsoleImpl
// Console is sometimes a singleton bag-of-properties without a prototype.
implements Console
implements Console
native "=(typeof console == 'undefined' ? {} : console)" {
final _MemoryInfoImpl memory;
@ -4853,7 +4853,7 @@ class _DocumentImpl extends _NodeImpl implements Document
void webkitExitPointerLock() native;
// TODO(jacobr): implement all Element methods not on Document.
// TODO(jacobr): implement all Element methods not on Document.
_ElementImpl query(String selectors) {
// It is fine for our RegExp to detect element id query selectors to have
@ -6005,14 +6005,14 @@ class _ElementRectImpl implements ElementRect {
// TODO(jacobr): should we move these outside of ElementRect to avoid the
// overhead of computing them every time even though they are rarely used.
final _ClientRectImpl _boundingClientRect;
final _ClientRectImpl _boundingClientRect;
final _ClientRectListImpl _clientRects;
_ElementRectImpl(_ElementImpl element) :
client = new _SimpleClientRect(element.$dom_clientLeft,
element.$dom_clientTop,
element.$dom_clientWidth,
element.$dom_clientHeight),
element.$dom_clientWidth,
element.$dom_clientHeight),
offset = new _SimpleClientRect(element.$dom_offsetLeft,
element.$dom_offsetTop,
element.$dom_offsetWidth,
@ -6637,7 +6637,7 @@ class _EventsImpl implements Events {
}
class _EventListenerListImpl implements EventListenerList {
// TODO(jacobr): make this _EventTargetImpl
final Dynamic _ptr;
final String _type;
@ -9535,7 +9535,7 @@ class _NodeImpl extends _EventTargetImpl implements Node native "*Node" {
final _NodeImpl parent = this.parent;
parent.$dom_replaceChild(otherNode, this);
} catch(var e) {
};
return this;
}
@ -9786,7 +9786,7 @@ class _NodeListImpl implements NodeList native "*NodeList" {
void addAll(Collection<_NodeImpl> collection) {
for (_NodeImpl node in collection) {
_parent.$dom_appendChild(node);
_parent.$dom_appendChild(node);
}
}
@ -37078,7 +37078,7 @@ class _RemoteSendPortSync implements SendPortSync {
}
static _call(int isolateId, int portId, var message) {
var target = 'dart-port-$isolateId-$portId';
var target = 'dart-port-$isolateId-$portId';
// TODO(vsm): Make this re-entrant.
// TODO(vsm): Set this up set once, on the first call.
var source = '$target-result';
@ -37143,13 +37143,13 @@ class ReceivePortSync {
static int get _isolateId() {
// TODO(vsm): Make this coherent with existing isolate code.
if (_cachedIsolateId == null) {
_cachedIsolateId = _getNewIsolateId();
_cachedIsolateId = _getNewIsolateId();
}
return _cachedIsolateId;
}
static String _getListenerName(isolateId, portId) =>
'dart-port-$isolateId-$portId';
'dart-port-$isolateId-$portId';
String get _listenerName() => _getListenerName(_isolateId, _portId);
void receive(callback(var message)) {
@ -37341,7 +37341,7 @@ class _CSSStyleDeclarationFactoryProvider {
final style = new Element.tag('div').style;
style.cssText = css;
return style;
}
}
factory CSSStyleDeclaration() {
return new CSSStyleDeclaration.css('');

View file

@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#library("json");
#library("dart:json");
// Pure Dart implementation of JSON protocol.

View file

@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#library('uri');
#library('dart:uri');
#import('dart:utf');

View file

@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#library("utf");
#library("dart:utf");
#source("utf_core.dart");
#source("utf8.dart");
#source("utf16.dart");

View file

@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#library("web");
#library("dart:web");
// Web related functions and data that are not specific to a single environment
// (e.g., only in a browser or only on a server).

View file

@ -145,12 +145,16 @@ def CopyDart2Js(build_dir, sdk_root):
ReplaceInFiles([dart2js],
[(r'%SCRIPTPATH%\.\.\\lib',
r'%SCRIPTPATH%..\lib\dart2js\lib')])
dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc.bat')
Copy(os.path.join(build_dir, 'dartdoc.bat'), dartdoc)
else:
dart2js = os.path.join(sdk_root, 'bin', 'dart2js')
Copy(os.path.join(build_dir, 'dart2js'), dart2js)
ReplaceInFiles([dart2js],
[(r'\$BIN_DIR/\.\./\.\./lib',
r'$BIN_DIR/../lib/dart2js/lib')])
dartdoc = os.path.join(sdk_root, 'bin', 'dartdoc')
Copy(os.path.join(build_dir, 'dartdoc'), dartdoc)
def Main(argv):

View file

@ -21,6 +21,7 @@
#import('../../lib/dartdoc/mirrors/mirrors.dart');
#import('../../lib/dartdoc/mirrors/mirrors_util.dart');
#import('../../lib/dartdoc/dartdoc.dart', prefix: 'doc');
#import('../../lib/compiler/implementation/library_map.dart');
HtmlDiff _diff;
@ -102,38 +103,22 @@ void main() {
// TODO(johnniwinther): Libraries for the compilation seem to be more like
// URIs. Perhaps Path should have a toURI() method.
// Add all of the core libraries.
var apidocLibraries = <Path>[
const Path('dart:core'),
const Path('dart:coreimpl'),
const Path('dart:crypto'),
const Path('dart:html'),
const Path('dart:io'),
const Path('dart:isolate'),
const Path('dart:json'),
doc.scriptDir.append('../../lib/math/math.dart'),
doc.scriptDir.append('../../lib/unittest/unittest.dart'),
doc.scriptDir.append('../../lib/i18n/intl.dart'),
const Path('dart:uri'),
const Path('dart:utf'),
const Path('dart:web'),
];
final apidocLibraries = <Path>[];
DART2JS_LIBRARY_MAP.forEach((String name, LibraryInfo info) {
if (!info.isInternal) {
apidocLibraries.add(new Path('dart:$name'));
}
});
apidocLibraries.add(doc.scriptDir.append('../../lib/unittest/unittest.dart'));
apidocLibraries.add(doc.scriptDir.append('../../lib/i18n/intl.dart'));
print('Generating docs...');
final apidoc = new Apidoc(mdn, htmldoc, outputDir, mode, generateAppCache);
// Select the libraries to include in the produced documentation:
apidoc.libraries = <String>[
'core',
'coreimpl',
'crypto',
'html',
'io',
'dart:isolate',
'json',
'math',
apidoc.includeApi = true;
apidoc.includedLibraries = <String>[
'unittest',
'intl',
'uri',
'utf',
'web',
];
Futures.wait([compiled, copiedStatic, copiedApiDocStatic]).then((_) {
@ -172,7 +157,7 @@ class Htmldoc extends doc.Dartdoc {
}
String getRecordedLibraryComment(LibraryMirror library) {
if (library.simpleName() == 'html') {
if (library.simpleName() == HTML_LIBRARY_NAME) {
return libraryComment;
}
return null;
@ -364,7 +349,7 @@ class Apidoc extends doc.Dartdoc {
}
String getLibraryComment(LibraryMirror library) {
if (library.simpleName() == 'html') {
if (library.simpleName() == HTML_LIBRARY_NAME) {
return htmldoc.libraryComment;
}
return super.getLibraryComment(library);
@ -452,7 +437,7 @@ class Apidoc extends doc.Dartdoc {
* scraped from MDN.
*/
includeMdnTypeComment(TypeMirror type) {
if (type.library().simpleName() == 'html') {
if (type.library().simpleName() == HTML_LIBRARY_NAME) {
// If it's an HTML type, try to map it to a base DOM type so we can find
// the MDN docs.
final domTypes = _diff.htmlTypesToDom[type.qualifiedName()];
@ -464,7 +449,7 @@ class Apidoc extends doc.Dartdoc {
// TODO(rnystrom): Shame there isn't a simpler way to get the one item
// out of a singleton Set.
type = domTypes.iterator().next();
} else if (type.library().simpleName() != 'dom') {
} else if (type.library().simpleName() != DOM_LIBRARY_NAME) {
// Not a DOM type.
return null;
}
@ -484,7 +469,7 @@ class Apidoc extends doc.Dartdoc {
*/
includeMdnMemberComment(MemberMirror member) {
var library = findLibrary(member);
if (library.simpleName() == 'html') {
if (library.simpleName() == HTML_LIBRARY_NAME) {
// If it's an HTML type, try to map it to a base DOM type so we can find
// the MDN docs.
final domMembers = _diff.htmlToDom[member.qualifiedName()];
@ -496,7 +481,7 @@ class Apidoc extends doc.Dartdoc {
// TODO(rnystrom): Shame there isn't a simpler way to get the one item
// out of a singleton Set.
member = domMembers.iterator().next();
} else if (library.simpleName() != 'dom') {
} else if (library.simpleName() != DOM_LIBRARY_NAME) {
// Not a DOM type.
return null;
}

View file

@ -15,6 +15,9 @@
#import('../../lib/dartdoc/mirrors/mirrors.dart');
#import('../../lib/dartdoc/mirrors/mirrors_util.dart');
final HTML_LIBRARY_NAME = 'dart:html';
final DOM_LIBRARY_NAME = 'dart:dom_deprecated';
/**
* A class for computing a many-to-many mapping between the types and
* members in `dart:dom_deprecated` and `dart:html`. This mapping is
@ -83,13 +86,13 @@ class HtmlDiff {
static void initialize(Path libDir) {
_compilation = new Compilation.library(
const <Path>[
const Path('dart:dom_deprecated'),
const Path('dart:html')
const Path(DOM_LIBRARY_NAME),
const Path(HTML_LIBRARY_NAME)
], libDir);
_mirrors = _compilation.mirrors();
// Find 'dart:dom_deprecated' by its library tag 'dom'.
dom = findMirror(_mirrors.libraries(), 'dom');
dom = findMirror(_mirrors.libraries(), DOM_LIBRARY_NAME);
}
HtmlDiff([bool printWarnings = false]) :
@ -114,9 +117,9 @@ class HtmlDiff {
* [HtmlDiff.initialize] should be called.
*/
void run() {
LibraryMirror htmlLib = findMirror(_mirrors.libraries(), 'html');
LibraryMirror htmlLib = findMirror(_mirrors.libraries(), HTML_LIBRARY_NAME);
if (htmlLib === null) {
warn('Could not find dart:html');
warn('Could not find $HTML_LIBRARY_NAME');
return;
}
for (InterfaceMirror htmlType in htmlLib.types().getValues()) {
@ -143,9 +146,10 @@ class HtmlDiff {
void _addMemberDiff(MemberMirror htmlMember, List<TypeMirror> domTypes) {
var domMembers = htmlToDomMembers(htmlMember, domTypes);
if (htmlMember == null && !domMembers.isEmpty()) {
warn('dart:html member '
warn('$HTML_LIBRARY_NAME member '
'${htmlMember.surroundingDeclaration().simpleName()}.'
'${htmlMember.simpleName()} has no corresponding dart:html member.');
'${htmlMember.simpleName()} has no corresponding '
'$HTML_LIBRARY_NAME member.');
}
if (htmlMember == null) return;
@ -174,7 +178,7 @@ class HtmlDiff {
for (var domName in domNames) {
final domType = findMirror(dom.types(), domName);
if (domType == null) {
warn('no dart:dom_deprecated type named $domName');
warn('no $DOM_LIBRARY_NAME type named $domName');
} else {
domTypes.add(domType);
}

View file

@ -15,7 +15,8 @@ main() {
String dartVmPath = nativeToUriPath(arguments[1]);
String productionName = nativeToUriPath(arguments[2]);
String developerName = nativeToUriPath(arguments[3]);
String dartDir = appendSlash(nativeToUriPath(arguments[4]));
String dartdocName = nativeToUriPath(arguments[4]);
String dartDir = appendSlash(nativeToUriPath(arguments[5]));
Uri dartUri = cwd.resolve(dartDir);
Uri productUri = cwd.resolve(productDir);
@ -23,12 +24,25 @@ main() {
Uri dartVmUri = productUri.resolve(dartVmPath);
Uri productionUri = productUri.resolve(arguments[2]);
Uri developerUri = productUri.resolve(arguments[3]);
List<String> productionScript = buildScript(dartUri, dartVmUri, '');
List<String> developerScript = buildScript(dartUri, dartVmUri,
' --enable_checked_mode');
Uri dartdocUri = productUri.resolve(arguments[4]);
List<String> productionScript = buildScript(
'dart2js-production',
dartUri, dartVmUri,
'lib/compiler/implementation/dart2js.dart', '');
writeScript(productionUri, productionScript);
List<String> developerScript = buildScript(
'dart2js-developer',
dartUri, dartVmUri,
'lib/compiler/implementation/dart2js.dart', ' --enable_checked_mode');
writeScript(developerUri, developerScript);
List<String> dartdocScript = buildScript(
'dartdoc',
dartUri, dartVmUri,
'lib/dartdoc/dartdoc.dart', '');
writeScript(dartdocUri, dartdocScript);
}
writeScript(Uri uri, List<String> scripts) {
@ -62,16 +76,18 @@ writeScript(Uri uri, List<String> scripts) {
}
}
List<String> buildScript(Uri dartUri, Uri dartVmLocation, String options) {
Uri dart2jsUri = dartUri.resolve('lib/compiler/implementation/dart2js.dart');
String dart2jsPath = relativize(dartVmLocation, dart2jsUri);
String dart2jsPathWin = dart2jsPath.replaceAll("/", "\\");
List<String> buildScript(String name,
Uri dartUri, Uri dartVmLocation,
String entrypoint, String options) {
Uri uri = dartUri.resolve(entrypoint);
String path = relativize(dartVmLocation, uri);
String pathWin = path.replaceAll("/", "\\");
print('dartUri = $dartUri');
print('dartVmLocation = $dartVmLocation');
print('dart2jsUri = $dart2jsUri');
print('dart2jsPath = $dart2jsPath');
print('dart2jsPathWin = $dart2jsPathWin');
print('${name}Uri = $uri');
print('${name}Path = $path');
print('${name}PathWin = $pathWin');
// Tell the VM to grow the heap more aggressively. This should only
// be necessary temporarily until the VM is better at detecting how
@ -87,7 +103,7 @@ List<String> buildScript(Uri dartUri, Uri dartVmLocation, String options) {
# BSD-style license that can be found in the LICENSE file.
BIN_DIR=`dirname \$0`
exec \$BIN_DIR/dart$options \$BIN_DIR/$dart2jsPath "\$@"
exec \$BIN_DIR/dart$options \$BIN_DIR/$path "\$@"
''',
'''
@echo off
@ -102,6 +118,6 @@ if %SCRIPTPATH:~-1%==\ set SCRIPTPATH=%SCRIPTPATH:~0,-1%
set arguments=%*
"%SCRIPTPATH%\dart.exe"$options "%SCRIPTPATH%$dart2jsPathWin" %arguments%
"%SCRIPTPATH%\dart.exe"$options "%SCRIPTPATH%$pathWin" %arguments%
'''.replaceAll('\n', '\r\n')];
}

View file

@ -26,6 +26,8 @@
'<(PRODUCT_DIR)/dart2js.bat',
'<(PRODUCT_DIR)/dart2js_developer',
'<(PRODUCT_DIR)/dart2js_developer.bat',
'<(PRODUCT_DIR)/dartdoc',
'<(PRODUCT_DIR)/dartdoc.bat',
],
'action': [
'<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)dart<(EXECUTABLE_SUFFIX)',
@ -39,6 +41,7 @@
'<(EXECUTABLE_PREFIX)dart<(EXECUTABLE_SUFFIX)',
'dart2js',
'dart2js_developer',
'dartdoc',
'<(dart_dir)',
],
},