OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /** An awesome documentation generator. */ | 5 /** An awesome documentation generator. */ |
6 #library('dartdoc'); | 6 #library('dartdoc'); |
7 | 7 |
8 #import('../../frog/lang.dart'); | 8 #import('../../frog/lang.dart'); |
9 #import('../../frog/file_system.dart'); | 9 #import('../../frog/file_system.dart'); |
10 #import('../../frog/file_system_node.dart'); | 10 #import('../../frog/file_system_node.dart'); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 * support creating new directories. | 44 * support creating new directories. |
45 */ | 45 */ |
46 void main() { | 46 void main() { |
47 // The entrypoint of the library to generate docs for. | 47 // The entrypoint of the library to generate docs for. |
48 final libPath = process.argv[2]; | 48 final libPath = process.argv[2]; |
49 | 49 |
50 files = new NodeFileSystem(); | 50 files = new NodeFileSystem(); |
51 parseOptions('../../frog', [] /* args */, files); | 51 parseOptions('../../frog', [] /* args */, files); |
52 | 52 |
53 final elapsed = time(() { | 53 final elapsed = time(() { |
54 _comments = <String, Map<int, String>>{}; | 54 initializeDartDoc(); |
55 | 55 |
56 initializeWorld(files); | 56 initializeWorld(files); |
57 | 57 |
58 world.processScript(libPath); | 58 world.processScript(libPath); |
59 world.resolveAll(); | 59 world.resolveAll(); |
60 | 60 |
61 // Clean the output directory. | 61 // Clean the output directory. |
62 if (files.fileExists(outdir)) { | 62 if (files.fileExists(outdir)) { |
63 files.removeDirectory(outdir, recursive: true); | 63 files.removeDirectory(outdir, recursive: true); |
64 } | 64 } |
65 files.createDirectory(outdir, recursive: true); | 65 files.createDirectory(outdir, recursive: true); |
66 | 66 |
67 // Copy over the static files. | 67 // Copy over the static files. |
68 for (final file in ['interact.js', 'styles.css']) { | 68 for (final file in ['interact.js', 'styles.css']) { |
69 copyStatic(file); | 69 copyStatic(file); |
70 } | 70 } |
71 | 71 |
72 // Generate the docs. | 72 // Generate the docs. |
73 for (final library in world.libraries.getValues()) { | 73 for (final library in world.libraries.getValues()) { |
74 docLibrary(library); | 74 docLibrary(library); |
75 } | 75 } |
76 | 76 |
77 docIndex(world.libraries.getValues()); | 77 docIndex(world.libraries.getValues()); |
78 }); | 78 }); |
79 | 79 |
80 print('Documented $_totalLibraries libraries, $_totalTypes types, and ' + | 80 print('Documented $_totalLibraries libraries, $_totalTypes types, and ' + |
81 '$_totalMembers members in ${elapsed}msec.'); | 81 '$_totalMembers members in ${elapsed}msec.'); |
82 } | 82 } |
83 | 83 |
| 84 void initializeDartDoc() { |
| 85 _comments = <String, Map<int, String>>{}; |
| 86 } |
| 87 |
84 /** Copies the static file at 'static/file' to the output directory. */ | 88 /** Copies the static file at 'static/file' to the output directory. */ |
85 copyStatic(String file) { | 89 copyStatic(String file) { |
86 var contents = files.readAll(joinPaths('static', file)); | 90 var contents = files.readAll(joinPaths('static', file)); |
87 files.writeString(joinPaths(outdir, file), contents); | 91 files.writeString(joinPaths(outdir, file), contents); |
88 } | 92 } |
89 | 93 |
90 num time(callback()) { | 94 num time(callback()) { |
91 // Unlike world.withTiming, returns the elapsed time. | 95 // Unlike world.withTiming, returns the elapsed time. |
92 final watch = new Stopwatch(); | 96 final watch = new Stopwatch(); |
93 watch.start(); | 97 watch.start(); |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 if (line.endsWith('*/')) line = line.substring(0, line.length-2); | 566 if (line.endsWith('*/')) line = line.substring(0, line.length-2); |
563 line = line.trim(); | 567 line = line.trim(); |
564 while (line.startsWith('*')) line = line.substring(1, line.length); | 568 while (line.startsWith('*')) line = line.substring(1, line.length); |
565 line = line.trim(); | 569 line = line.trim(); |
566 buf.add(line); | 570 buf.add(line); |
567 buf.add(' '); | 571 buf.add(' '); |
568 } | 572 } |
569 | 573 |
570 return buf.toString(); | 574 return buf.toString(); |
571 } | 575 } |
OLD | NEW |