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 // Functions for working with files and paths. | 5 // Functions for working with files and paths. |
6 | 6 |
7 /** The path to the file currently being written to, relative to [outdir]. */ | 7 /** The path to the file currently being written to, relative to [outdir]. */ |
8 String _filePath; | 8 String _filePath; |
9 | 9 |
10 /** The file currently being written to. */ | 10 /** The file currently being written to. */ |
11 StringBuffer _file; | 11 StringBuffer _file; |
12 | 12 |
| 13 /** Path to generate HTML files into. */ |
| 14 final _outdir = 'docs'; |
| 15 |
13 startFile(String path) { | 16 startFile(String path) { |
14 _filePath = path; | 17 _filePath = path; |
15 _file = new StringBuffer(); | 18 _file = new StringBuffer(); |
16 } | 19 } |
17 | 20 |
18 write(String s) { | 21 write(String s) { |
19 _file.add(s); | 22 _file.add(s); |
20 } | 23 } |
21 | 24 |
22 writeln(String s) { | 25 writeln(String s) { |
23 write(s); | 26 write(s); |
24 write('\n'); | 27 write('\n'); |
25 } | 28 } |
26 | 29 |
27 endFile() { | 30 endFile() { |
28 String outPath = '$outdir/$_filePath'; | 31 String outPath = '$_outdir/$_filePath'; |
29 world.files.createDirectory(dirname(outPath), recursive: true); | 32 world.files.createDirectory(dirname(outPath), recursive: true); |
30 | 33 |
31 world.files.writeString(outPath, _file.toString()); | 34 world.files.writeString(outPath, _file.toString()); |
32 _filePath = null; | 35 _filePath = null; |
33 _file = null; | 36 _file = null; |
34 } | 37 } |
35 | 38 |
36 /** | 39 /** |
37 * Converts [absolute] which is understood to be a full path from the root of | 40 * Converts [absolute] which is understood to be a full path from the root of |
38 * the generated docs to one relative to the current file. | 41 * the generated docs to one relative to the current file. |
(...skipping 13 matching lines...) Expand all Loading... |
52 // If the type isn't generic, genericType returns `this`, so it works for | 55 // If the type isn't generic, genericType returns `this`, so it works for |
53 // non-generic types too. | 56 // non-generic types too. |
54 return '${sanitize(type.library.name)}/${type.genericType.name}.html'; | 57 return '${sanitize(type.library.name)}/${type.genericType.name}.html'; |
55 } | 58 } |
56 | 59 |
57 /** Gets the URL for the documentation for [member]. */ | 60 /** Gets the URL for the documentation for [member]. */ |
58 memberUrl(Member member) => '${typeUrl(member.declaringType)}#${member.name}'; | 61 memberUrl(Member member) => '${typeUrl(member.declaringType)}#${member.name}'; |
59 | 62 |
60 /** Gets the anchor id for the document for [member]. */ | 63 /** Gets the anchor id for the document for [member]. */ |
61 memberAnchor(Member member) => '${member.name}'; | 64 memberAnchor(Member member) => '${member.name}'; |
OLD | NEW |