Skip to content

Commit 0b9f9f6

Browse files
committed
Merge pull request #26 from keertip/ver
add version info, process excludes
2 parents 279b6fd + aca6d28 commit 0b9f9f6

File tree

2 files changed

+31
-27
lines changed

2 files changed

+31
-27
lines changed

lib/dartdoc.dart

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ const String DEFAULT_OUTPUT_DIRECTORY = 'docs';
2929
/// directory.
3030
class DartDoc {
3131

32-
//TODO(keertip): implement excludes
3332
List<String> _excludes;
3433
Directory _rootDir;
3534
final CSS css = new CSS();
@@ -45,7 +44,16 @@ class DartDoc {
4544
Stopwatch stopwatch = new Stopwatch();
4645
stopwatch.start();
4746
var files = findFilesToDocumentInPackage(_rootDir.path);
48-
libraries.addAll(parseLibraries(files));
47+
List<LibraryElement> libs = [];
48+
libs.addAll(parseLibraries(files));
49+
// remove excluded libraries
50+
_excludes.forEach(
51+
(pattern) => libs.removeWhere((l) => l.name.startsWith(pattern)));
52+
libs.removeWhere(
53+
(LibraryElement library) => _excludes.contains(library.name));
54+
libs.sort(elementCompare);
55+
libraries.addAll(libs);
56+
4957
generator = new GeneratorHelper(libraries);
5058
// create the out directory
5159
out = new Directory(DEFAULT_OUTPUT_DIRECTORY);
@@ -79,6 +87,7 @@ class DartDoc {
7987
context.sourceFactory = sourceFactory;
8088

8189
files.forEach((String filePath) {
90+
print('parsing ${filePath}...');
8291
Source source = new FileBasedSource.con1(new JavaFile(filePath));
8392
if (context.computeKindOf(source) == SourceKind.LIBRARY) {
8493
LibraryElement library = context.computeLibraryElement(source);
@@ -108,6 +117,7 @@ class DartDoc {
108117
void generatePackage() {
109118
var packageName = getPackageName(_rootDir.path);
110119
var packageDesc = getPackageDescription(_rootDir.path);
120+
var packageVersion = getPackageVersion(_rootDir.path);
111121
if (packageName.isNotEmpty) {
112122
File f = joinFile(new Directory(out.path), ['${packageName}_package.html']);
113123
print('generating ${f.path}');
@@ -122,7 +132,9 @@ class DartDoc {
122132
html.startTag('div', attributes: "class='span3'");
123133
html.startTag('ul', attributes: 'class="nav nav-tabs nav-stacked left-nav"');
124134
html.startTag('li', attributes: 'class="active"', newLine: false);
125-
html.write('<a href="${packageName}">' '<i class="chevron-nav icon-white icon-chevron-right"></i> ' '${packageName}</a>');
135+
html.write('<a href="${packageName}">'
136+
'<i class="chevron-nav icon-white icon-chevron-right"></i> '
137+
'${packageName}-${packageVersion}</a>');
126138
html.endTag(); //li
127139
html.endTag(); //ul
128140
html.endTag();
@@ -147,8 +159,6 @@ class DartDoc {
147159

148160
}
149161

150-
151-
152162
void generateLibrary(LibraryElement library) {
153163
File f = joinFile(new Directory(out.path), [getFileNameFor(library)]);
154164
print('generating ${f.path}');
@@ -165,18 +175,11 @@ class DartDoc {
165175
// left nav
166176
html.startTag('div', attributes: "class='span3'");
167177
html.startTag('ul', attributes: 'class="nav nav-tabs nav-stacked left-nav"');
168-
// for (LibraryElement lib in libraries) {
169-
// if (lib == library) {
170178
html.startTag('li', attributes: 'class="active"', newLine: false);
171-
html.write('<a href="${getFileNameFor(library)}">' '<i class="chevron-nav icon-white icon-chevron-right"></i> ' '${library.name}</a>');
172-
// } else {
173-
// html.startTag('li', newLine: false);
174-
// html.write('<a href="${getFileNameFor(lib)}">'
175-
// '<i class="chevron-nav icon-chevron-right"></i> '
176-
// '${lib.name}</a>');
177-
// }
179+
html.write('<a href="${getFileNameFor(library)}">'
180+
'<i class="chevron-nav icon-white icon-chevron-right"></i> '
181+
'${library.name}</a>');
178182
html.endTag(); // li
179-
// }
180183
html.endTag(); // ul.nav
181184
html.endTag(); // div.span3
182185

lib/src/package_utils.dart

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,26 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
65
library dartdoc.package_utils;
76

87
import 'dart:io';
98

109
import 'package:path/path.dart' as path;
1110
import 'package:yaml/yaml.dart';
1211

13-
1412
String getPackageName(String directoryName) =>
1513
_getPubspec(directoryName)['name'];
1614

17-
Map _getPubspec(String directoryName) {
18-
var pubspecName = path.join(directoryName, 'pubspec.yaml');
19-
File pubspec = new File(pubspecName);
20-
if (!pubspec.existsSync()) return {'name': ''};
21-
var contents = pubspec.readAsStringSync();
22-
return loadYaml(contents);
23-
}
24-
25-
String getPackageDescription(String directoryName) =>
26-
_getPubspec(directoryName)['description'];
15+
Map _getPubspec(String directoryName) {
16+
var pubspecName = path.join(directoryName, 'pubspec.yaml');
17+
File pubspec = new File(pubspecName);
18+
if (!pubspec.existsSync()) return {'name': ''};
19+
var contents = pubspec.readAsStringSync();
20+
return loadYaml(contents);
21+
}
22+
23+
String getPackageDescription(String directoryName) =>
24+
_getPubspec(directoryName)['description'];
25+
26+
String getPackageVersion(String directoryName) =>
27+
_getPubspec(directoryName)['version'];

0 commit comments

Comments
 (0)