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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « utils/dartdoc/dartdoc.dart ('k') | utils/dartdoc/static/class.png » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: utils/dartdoc/files.dart
diff --git a/utils/dartdoc/files.dart b/utils/dartdoc/files.dart
new file mode 100644
index 0000000000000000000000000000000000000000..a75744c17756468091ea226355ee3711d671a64c
--- /dev/null
+++ b/utils/dartdoc/files.dart
@@ -0,0 +1,63 @@
+// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+// Functions for working with files and paths.
+
+/** The path to the file currently being written to, relative to [outdir]. */
+String _filePath;
+
+/** The file currently being written to. */
+StringBuffer _file;
+
+FileSystem files;
+
+startFile(String path) {
+ _filePath = path;
+ _file = new StringBuffer();
+}
+
+write(String s) {
+ _file.add(s);
+}
+
+writeln(String s) {
+ write(s);
+ write('\n');
+}
+
+endFile() {
+ String outPath = '$outdir/$_filePath';
+ files.createDirectory(dirname(outPath), recursive: true);
+
+ world.files.writeString(outPath, _file.toString());
+ _filePath = null;
+ _file = null;
+}
+
+/**
+ * Converts [absolute] which is understood to be a full path from the root of
+ * the generated docs to one relative to the current file.
+ */
+String relativePath(String absolute) {
+ // TODO(rnystrom): Walks all the way up to root each time. Shouldn't do this
+ // if the paths overlap.
+ return repeat('../', countOccurrences(_filePath, '/')) + absolute;
+}
+
+/** Gets the URL to the documentation for [library]. */
+libraryUrl(Library library) => '${sanitize(library.name)}.html';
+
+/** Gets the URL for the documentation for [type]. */
+typeUrl(Type type) {
+ // Always get the generic type to strip off any type parameters or arguments.
+ // If the type isn't generic, genericType returns `this`, so it works for
+ // non-generic types too.
+ return '${sanitize(type.library.name)}/${type.genericType.name}.html';
+}
+
+/** Gets the URL for the documentation for [member]. */
+memberUrl(Member member) => '${typeUrl(member.declaringType)}#${member.name}';
+
+/** Gets the anchor id for the document for [member]. */
+memberAnchor(Member member) => '${member.name}';
« 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