@@ -14,11 +14,13 @@ import 'package:analyzer/src/generated/sdk.dart';
14
14
import 'package:analyzer/src/generated/sdk_io.dart' ;
15
15
import 'package:analyzer/src/generated/source_io.dart' ;
16
16
17
+
17
18
import 'src/css.dart' ;
18
19
import 'src/helpers.dart' ;
19
20
import 'src/html_gen.dart' ;
20
21
import 'src/io_utils.dart' ;
21
22
import 'src/model_utils.dart' ;
23
+ import 'src/package_utils.dart' ;
22
24
import 'src/utils.dart' ;
23
25
24
26
const String DEFAULT_OUTPUT_DIRECTORY = 'docs' ;
@@ -52,16 +54,15 @@ class DartDoc {
52
54
}
53
55
// generate the docs
54
56
html = new HtmlGenerator ();
57
+ generatePackage ();
55
58
libraries.forEach ((lib) => generateLibrary (lib));
56
59
// copy the css resource into 'out'
57
60
File f = joinFile (new Directory (out.path), [css.getCssName ()]);
58
61
f.writeAsStringSync (css.getCssContent ());
59
62
60
63
double seconds = stopwatch.elapsedMilliseconds / 1000.0 ;
61
64
print ('' );
62
- print ("Documented ${libraries .length } "
63
- "librar${libraries .length == 1 ? 'y' : 'ies' } in "
64
- "${seconds .toStringAsFixed (1 )} seconds." );
65
+ print ("Documented ${libraries .length } " "librar${libraries .length == 1 ? 'y' : 'ies' } in " "${seconds .toStringAsFixed (1 )} seconds." );
65
66
}
66
67
67
68
List <LibraryElement > parseLibraries (List <String > files) {
@@ -104,13 +105,57 @@ class DartDoc {
104
105
return new File (Platform .executable).parent.parent;
105
106
}
106
107
108
+ void generatePackage () {
109
+ var packageName = getPackageName (_rootDir.path);
110
+ var packageDesc = getPackageDescription (_rootDir.path);
111
+ if (packageName.isNotEmpty) {
112
+ File f = joinFile (new Directory (out.path), ['${packageName }_package.html' ]);
113
+ print ('generating ${f .path }' );
114
+ html = new HtmlGenerator ();
115
+ html.start (title: 'Package ${packageName }' , cssRef: css.getCssName ());
116
+ generateHeader ();
117
+
118
+ html.startTag ('div' , attributes: "class='container'" , newLine: false );
119
+ html.writeln ();
120
+ html.startTag ('div' , attributes: "class='row'" , newLine: false );
121
+ html.writeln ();
122
+ html.startTag ('div' , attributes: "class='span3'" );
123
+ html.startTag ('ul' , attributes: 'class="nav nav-tabs nav-stacked left-nav"' );
124
+ 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>' );
126
+ html.endTag (); //li
127
+ html.endTag (); //ul
128
+ html.endTag ();
129
+ html.startTag ('div' , attributes: "class='span9'" );
130
+ html.tag ('h1' , contents: packageName);
131
+ html.writeln ('<hr>' );
132
+ html.write (packageDesc);
133
+ html.startTag ('dl' );
134
+ html.startTag ('h4' );
135
+ html.tag ('dt' , contents: 'Libraries' );
136
+ html.endTag ();
137
+ html.startTag ('dd' );
138
+ for (LibraryElement lib in libraries) {
139
+ html.writeln ('<a href="${getFileNameFor (lib )}"> ${lib .name }</a><br>' );
140
+ }
141
+ html.endTag ();
142
+ html.endTag (); // div.container
143
+ generateFooter ();
144
+ html.end ();
145
+ f.writeAsStringSync (html.toString ());
146
+ }
147
+
148
+ }
149
+
150
+
151
+
107
152
void generateLibrary (LibraryElement library) {
108
153
File f = joinFile (new Directory (out.path), [getFileNameFor (library)]);
109
154
print ('generating ${f .path }' );
110
155
html = new HtmlGenerator ();
111
156
html.start (title: 'Library ${library .name }' , cssRef: css.getCssName ());
112
157
113
- generateHeader (library );
158
+ generateHeader ();
114
159
115
160
html.startTag ('div' , attributes: "class='container'" , newLine: false );
116
161
html.writeln ();
@@ -195,21 +240,21 @@ class DartDoc {
195
240
196
241
html.endTag (); // div.container
197
242
198
- generateFooter (library );
243
+ generateFooter ();
199
244
200
245
html.end ();
201
246
202
247
// write the file contents
203
248
f.writeAsStringSync (html.toString ());
204
249
}
205
250
206
- void generateHeader (LibraryElement library ) {
251
+ void generateHeader () {
207
252
// header
208
253
html.startTag ('header' );
209
254
html.endTag ();
210
255
}
211
256
212
- void generateFooter (LibraryElement library ) {
257
+ void generateFooter () {
213
258
// footer
214
259
html.startTag ('footer' );
215
260
// html.startTag('div', 'class="navbar navbar-fixed-bottom"');
0 commit comments