Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(253)

Side by Side Diff: utils/dartdoc/files.dart

Issue 8772067: Navigation in generated docs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Respond to review. Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « utils/dartdoc/dartdoc.dart ('k') | utils/dartdoc/static/class.png » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // Functions for working with files and paths.
6
7 /** The path to the file currently being written to, relative to [outdir]. */
8 String _filePath;
9
10 /** The file currently being written to. */
11 StringBuffer _file;
12
13 FileSystem files;
14
15 startFile(String path) {
16 _filePath = path;
17 _file = new StringBuffer();
18 }
19
20 write(String s) {
21 _file.add(s);
22 }
23
24 writeln(String s) {
25 write(s);
26 write('\n');
27 }
28
29 endFile() {
30 String outPath = '$outdir/$_filePath';
31 files.createDirectory(dirname(outPath), recursive: true);
32
33 world.files.writeString(outPath, _file.toString());
34 _filePath = null;
35 _file = null;
36 }
37
38 /**
39 * Converts [absolute] which is understood to be a full path from the root of
40 * the generated docs to one relative to the current file.
41 */
42 String relativePath(String absolute) {
43 // TODO(rnystrom): Walks all the way up to root each time. Shouldn't do this
44 // if the paths overlap.
45 return repeat('../', countOccurrences(_filePath, '/')) + absolute;
46 }
47
48 /** Gets the URL to the documentation for [library]. */
49 libraryUrl(Library library) => '${sanitize(library.name)}.html';
50
51 /** Gets the URL for the documentation for [type]. */
52 typeUrl(Type type) {
53 // Always get the generic type to strip off any type parameters or arguments.
54 // If the type isn't generic, genericType returns `this`, so it works for
55 // non-generic types too.
56 return '${sanitize(type.library.name)}/${type.genericType.name}.html';
57 }
58
59 /** Gets the URL for the documentation for [member]. */
60 memberUrl(Member member) => '${typeUrl(member.declaringType)}#${member.name}';
61
62 /** Gets the anchor id for the document for [member]. */
63 memberAnchor(Member member) => '${member.name}';
OLDNEW
« no previous file with comments | « utils/dartdoc/dartdoc.dart ('k') | utils/dartdoc/static/class.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698