diff --git a/lib/dartdoc.dart b/lib/dartdoc.dart index 1469b83fdb..10cd8ea8a1 100644 --- a/lib/dartdoc.dart +++ b/lib/dartdoc.dart @@ -29,7 +29,6 @@ const String DEFAULT_OUTPUT_DIRECTORY = 'docs'; /// directory. class DartDoc { - //TODO(keertip): implement excludes List _excludes; Directory _rootDir; final CSS css = new CSS(); @@ -45,7 +44,16 @@ class DartDoc { Stopwatch stopwatch = new Stopwatch(); stopwatch.start(); var files = findFilesToDocumentInPackage(_rootDir.path); - libraries.addAll(parseLibraries(files)); + List libs = []; + libs.addAll(parseLibraries(files)); + // remove excluded libraries + _excludes.forEach( + (pattern) => libs.removeWhere((l) => l.name.startsWith(pattern))); + libs.removeWhere( + (LibraryElement library) => _excludes.contains(library.name)); + libs.sort(elementCompare); + libraries.addAll(libs); + generator = new GeneratorHelper(libraries); // create the out directory out = new Directory(DEFAULT_OUTPUT_DIRECTORY); @@ -79,6 +87,7 @@ class DartDoc { context.sourceFactory = sourceFactory; files.forEach((String filePath) { + print('parsing ${filePath}...'); Source source = new FileBasedSource.con1(new JavaFile(filePath)); if (context.computeKindOf(source) == SourceKind.LIBRARY) { LibraryElement library = context.computeLibraryElement(source); @@ -108,6 +117,7 @@ class DartDoc { void generatePackage() { var packageName = getPackageName(_rootDir.path); var packageDesc = getPackageDescription(_rootDir.path); + var packageVersion = getPackageVersion(_rootDir.path); if (packageName.isNotEmpty) { File f = joinFile(new Directory(out.path), ['${packageName}_package.html']); print('generating ${f.path}'); @@ -122,7 +132,9 @@ class DartDoc { html.startTag('div', attributes: "class='span3'"); html.startTag('ul', attributes: 'class="nav nav-tabs nav-stacked left-nav"'); html.startTag('li', attributes: 'class="active"', newLine: false); - html.write('' ' ' '${packageName}'); + html.write('' + ' ' + '${packageName}-${packageVersion}'); html.endTag(); //li html.endTag(); //ul html.endTag(); @@ -147,8 +159,6 @@ class DartDoc { } - - void generateLibrary(LibraryElement library) { File f = joinFile(new Directory(out.path), [getFileNameFor(library)]); print('generating ${f.path}'); @@ -165,18 +175,11 @@ class DartDoc { // left nav html.startTag('div', attributes: "class='span3'"); html.startTag('ul', attributes: 'class="nav nav-tabs nav-stacked left-nav"'); -// for (LibraryElement lib in libraries) { -// if (lib == library) { html.startTag('li', attributes: 'class="active"', newLine: false); - html.write('' ' ' '${library.name}'); -// } else { -// html.startTag('li', newLine: false); -// html.write('' -// ' ' -// '${lib.name}'); -// } + html.write('' + ' ' + '${library.name}'); html.endTag(); // li -// } html.endTag(); // ul.nav html.endTag(); // div.span3 diff --git a/lib/src/package_utils.dart b/lib/src/package_utils.dart index d17ce40dc2..c9c7f4a89f 100644 --- a/lib/src/package_utils.dart +++ b/lib/src/package_utils.dart @@ -2,7 +2,6 @@ // 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 dartdoc.package_utils; import 'dart:io'; @@ -10,17 +9,19 @@ import 'dart:io'; import 'package:path/path.dart' as path; import 'package:yaml/yaml.dart'; - String getPackageName(String directoryName) => _getPubspec(directoryName)['name']; - Map _getPubspec(String directoryName) { - var pubspecName = path.join(directoryName, 'pubspec.yaml'); - File pubspec = new File(pubspecName); - if (!pubspec.existsSync()) return {'name': ''}; - var contents = pubspec.readAsStringSync(); - return loadYaml(contents); - } - - String getPackageDescription(String directoryName) => - _getPubspec(directoryName)['description']; \ No newline at end of file +Map _getPubspec(String directoryName) { + var pubspecName = path.join(directoryName, 'pubspec.yaml'); + File pubspec = new File(pubspecName); + if (!pubspec.existsSync()) return {'name': ''}; + var contents = pubspec.readAsStringSync(); + return loadYaml(contents); +} + +String getPackageDescription(String directoryName) => + _getPubspec(directoryName)['description']; + +String getPackageVersion(String directoryName) => + _getPubspec(directoryName)['version'];