Remove more tests which depend on dartdoc, which has been deleted.
Review URL: https://codereview.chromium.org//156903004 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@32393 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
||||
// 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.
|
||||
|
||||
/**
|
||||
* This program reads the HTML libraries from [LIB_PATH] and outputs their
|
||||
* documentation to [JSON_PATH].
|
||||
*/
|
||||
|
||||
import 'dart:io';
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import '../lib/docs.dart';
|
||||
|
||||
final String json_path = Platform.script.resolve('../docs.json').toFilePath();
|
||||
final String lib_uri = Platform.script.resolve('../../../../sdk').toString();
|
||||
|
||||
main() {
|
||||
print('Converting HTML docs from $lib_uri to $json_path.');
|
||||
|
||||
convert(lib_uri, json_path)
|
||||
.then((bool anyErrors) {
|
||||
print('Converted HTML docs ${anyErrors ? "with": "without"}'
|
||||
' errors.');
|
||||
});
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,7 +0,0 @@
|
||||
# Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
||||
# 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.
|
||||
|
||||
# docs.dart is a tool that only runs on the VM
|
||||
[ $compiler == dart2js || $compiler == dart2dart || $runtime == drt || $runtime == dartium ]
|
||||
*: Skip
|
||||
@@ -1,197 +0,0 @@
|
||||
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
||||
// 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.
|
||||
|
||||
/**
|
||||
* A library for extracting the documentation from the various HTML libraries
|
||||
* ([dart:html], [dart:svg], [dart:web_audio], [dart:indexed_db]) and saving
|
||||
* those documentation comments to a JSON file.
|
||||
*/
|
||||
|
||||
library docs;
|
||||
|
||||
import '../../../../sdk/lib/_internal/dartdoc/lib/src/dart2js_mirrors.dart';
|
||||
import '../../../../sdk/lib/_internal/compiler/implementation/mirrors/source_mirrors.dart';
|
||||
import '../../../../sdk/lib/_internal/compiler/implementation/mirrors/mirrors_util.dart';
|
||||
import '../../../../sdk/lib/_internal/dartdoc/lib/dartdoc.dart';
|
||||
import '../../../../sdk/lib/_internal/dartdoc/lib/src/json_serializer.dart';
|
||||
import '../../../../utils/apidoc/lib/metadata.dart';
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
/// The various HTML libraries.
|
||||
const List<String> HTML_LIBRARY_NAMES = const ['dart:html',
|
||||
'dart:indexed_db',
|
||||
'dart:svg',
|
||||
'dart:web_audio',
|
||||
'dart:web_gl',
|
||||
'dart:web_sql'];
|
||||
/**
|
||||
* Converts the libraries in [HTML_LIBRARY_NAMES] to a json file at [jsonPath]
|
||||
* given the library path at [libUri].
|
||||
*
|
||||
* The json output looks like:
|
||||
* {
|
||||
* $library_name: {
|
||||
* $interface_name: {
|
||||
* comment: "$comment"
|
||||
* members: {
|
||||
* $member: [
|
||||
* [$comment1line1,
|
||||
* $comment1line2,
|
||||
* ...],
|
||||
* ...
|
||||
* ],
|
||||
* ...
|
||||
* }
|
||||
* },
|
||||
* ...
|
||||
* },
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
* Completes to true if any errors were encountered, false otherwise.
|
||||
*/
|
||||
Future<bool> convert(String libUri, String jsonPath) {
|
||||
var paths = <String>[];
|
||||
for (var libraryName in HTML_LIBRARY_NAMES) {
|
||||
paths.add(libraryName);
|
||||
}
|
||||
|
||||
return analyze(paths, libUri, options: ['--preserve-comments'])
|
||||
.then((MirrorSystem mirrors) {
|
||||
var convertedJson = _generateJsonFromLibraries(mirrors);
|
||||
return _exportJsonToFile(convertedJson, jsonPath);
|
||||
});
|
||||
}
|
||||
|
||||
Future<bool> _exportJsonToFile(Map convertedJson, String jsonPath) {
|
||||
return new Future.sync(() {
|
||||
final jsonFile = new File(jsonPath);
|
||||
var writeJson = prettySerialize(convertedJson);
|
||||
|
||||
var outputStream = jsonFile.openWrite();
|
||||
outputStream.writeln(writeJson);
|
||||
outputStream.close();
|
||||
return outputStream.done.then((_) => false);
|
||||
});
|
||||
}
|
||||
|
||||
Map _generateJsonFromLibraries(MirrorSystem mirrors) {
|
||||
var convertedJson = {};
|
||||
|
||||
// Sort the libraries by name (not key).
|
||||
var sortedLibraries = new List<LibraryMirror>.from(
|
||||
mirrors.libraries.values.where(
|
||||
(e) => HTML_LIBRARY_NAMES.indexOf(e.uri.toString()) >= 0))
|
||||
..sort((x, y) =>
|
||||
x.uri.toString().toUpperCase().compareTo(
|
||||
y.uri.toString().toUpperCase()));
|
||||
|
||||
for (LibraryMirror libMirror in sortedLibraries) {
|
||||
print('Extracting documentation from ${libMirror.simpleName}.');
|
||||
|
||||
var libraryJson = {};
|
||||
var sortedClasses = _sortAndFilterMirrors(
|
||||
classesOf(libMirror.declarations).toList(), ignoreDocsEditable: true);
|
||||
|
||||
for (ClassMirror classMirror in sortedClasses) {
|
||||
print(' class: $classMirror');
|
||||
var classJson = {};
|
||||
var sortedMembers = _sortAndFilterMirrors(
|
||||
membersOf(classMirror.declarations).toList());
|
||||
|
||||
var membersJson = {};
|
||||
for (var memberMirror in sortedMembers) {
|
||||
print(' member: $memberMirror');
|
||||
var memberDomName = domNames(memberMirror)[0];
|
||||
var memberComment = _splitCommentsByNewline(
|
||||
computeUntrimmedCommentAsList(memberMirror));
|
||||
|
||||
// Remove interface name from Dom Name.
|
||||
if (memberDomName.indexOf('.') >= 0) {
|
||||
memberDomName =
|
||||
memberDomName.substring(memberDomName.indexOf('.') + 1);
|
||||
}
|
||||
|
||||
if (!memberComment.isEmpty) {
|
||||
membersJson.putIfAbsent(memberDomName, () => memberComment);
|
||||
}
|
||||
}
|
||||
|
||||
// Only include the comment if DocsEditable is set.
|
||||
var classComment = _splitCommentsByNewline(
|
||||
computeUntrimmedCommentAsList(classMirror));
|
||||
if (!classComment.isEmpty &&
|
||||
findMetadata(classMirror.metadata, 'DocsEditable') != null) {
|
||||
classJson.putIfAbsent('comment', () => classComment);
|
||||
}
|
||||
if (!membersJson.isEmpty) {
|
||||
classJson.putIfAbsent('members', () =>
|
||||
membersJson);
|
||||
}
|
||||
|
||||
if (!classJson.isEmpty) {
|
||||
libraryJson.putIfAbsent(domNames(classMirror)[0], () =>
|
||||
classJson);
|
||||
}
|
||||
}
|
||||
|
||||
if (!libraryJson.isEmpty) {
|
||||
convertedJson.putIfAbsent(nameOf(libMirror), () =>
|
||||
libraryJson);
|
||||
}
|
||||
}
|
||||
|
||||
return convertedJson;
|
||||
}
|
||||
|
||||
/// Filter out mirrors that are private, or which are not part of this docs
|
||||
/// process. That is, ones without the DocsEditable annotation.
|
||||
/// If [ignoreDocsEditable] is true, relax the restriction on @DocsEditable().
|
||||
/// This is to account for classes that are defined in a template, but whose
|
||||
/// members are generated.
|
||||
List<DeclarationMirror> _sortAndFilterMirrors(List<DeclarationMirror> mirrors,
|
||||
{ignoreDocsEditable: false}) {
|
||||
|
||||
var filteredMirrors = mirrors.where((DeclarationMirror c) =>
|
||||
!domNames(c).isEmpty &&
|
||||
!displayName(c).startsWith('_') &&
|
||||
(!ignoreDocsEditable ? (findMetadata(c.metadata, 'DocsEditable') != null)
|
||||
: true))
|
||||
.toList();
|
||||
|
||||
filteredMirrors.sort((x, y) =>
|
||||
domNames(x)[0].toUpperCase().compareTo(
|
||||
domNames(y)[0].toUpperCase()));
|
||||
|
||||
return filteredMirrors;
|
||||
}
|
||||
|
||||
List<String> _splitCommentsByNewline(List<String> comments) {
|
||||
var out = [];
|
||||
|
||||
comments.forEach((c) {
|
||||
out.addAll(c.split(new RegExp('\n')));
|
||||
});
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
/// Given the class mirror, returns the names found or an empty list.
|
||||
List<String> domNames(DeclarationMirror mirror) {
|
||||
var domNameMetadata = findMetadata(mirror.metadata, 'DomName');
|
||||
|
||||
if (domNameMetadata != null) {
|
||||
var domNames = <String>[];
|
||||
var tags = domNameMetadata.getField(#name);
|
||||
for (var s in tags.reflectee.split(',')) {
|
||||
domNames.add(s.trim());
|
||||
}
|
||||
|
||||
if (domNames.length == 1 && domNames[0] == 'none') return <String>[];
|
||||
return domNames;
|
||||
} else {
|
||||
return <String>[];
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
||||
// 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 docs_test;
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:unittest/unittest.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import '../bin/docs.dart';
|
||||
import '../lib/docs.dart';
|
||||
|
||||
final testJsonPath = Platform.script.resolve('test.json').toFilePath();
|
||||
|
||||
main() {
|
||||
// Some tests take more than the default 20 second unittest timeout.
|
||||
unittestConfiguration.timeout = null;
|
||||
group('docs', () {
|
||||
var oldJson = new File(json_path);
|
||||
var testJson = new File(testJsonPath);
|
||||
|
||||
tearDown(() {
|
||||
// Clean up.
|
||||
if (testJson.existsSync()) {
|
||||
testJson.deleteSync();
|
||||
}
|
||||
assert(!testJson.existsSync());
|
||||
});
|
||||
|
||||
test('Ensure that docs.json is up to date', () {
|
||||
// We should find a json file where we expect it.
|
||||
expect(oldJson.existsSync(), isTrue);
|
||||
|
||||
// Save the last modified time to check it at the end.
|
||||
var oldJsonModified = oldJson.lastModifiedSync();
|
||||
|
||||
// There should be no test file yet.
|
||||
if (testJson.existsSync()) testJson.deleteSync();
|
||||
assert(!testJson.existsSync());
|
||||
|
||||
expect(convert(lib_uri, testJsonPath)
|
||||
.then((bool anyErrors) {
|
||||
expect(anyErrors, isFalse);
|
||||
|
||||
// We should have a file now.
|
||||
expect(testJson.existsSync(), isTrue);
|
||||
|
||||
// Ensure that there's nothing different between the new JSON and old.
|
||||
expect(testJson.readAsStringSync(), equals(oldJson.readAsStringSync()));
|
||||
|
||||
// Ensure that the old JSON file didn't actually change.
|
||||
expect(oldJsonModified, equals(oldJson.lastModifiedSync()));
|
||||
}), completes);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -65,10 +65,6 @@ final TEST_SUITE_DIRECTORIES = [
|
||||
new Path('utils/tests/css'),
|
||||
new Path('utils/tests/peg'),
|
||||
new Path('sdk/lib/_internal/pub'),
|
||||
// TODO(amouravski): move these to tests/ once they no longer rely on weird
|
||||
// dependencies.
|
||||
new Path('sdk/lib/_internal/dartdoc'),
|
||||
new Path('tools/dom/docs'),
|
||||
];
|
||||
|
||||
void testConfigurations(List<Map> configurations) {
|
||||
|
||||
Reference in New Issue
Block a user