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

Unified Diff: pkg/dartdoc/client-shared.dart

Issue 10829361: 'Find-as-you-type'-search in dartdoc/apidoc. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 8 years, 4 months 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 | « pkg/dartdoc/client-live-nav.dart ('k') | pkg/dartdoc/client-static.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/dartdoc/client-shared.dart
diff --git a/pkg/dartdoc/client-shared.dart b/pkg/dartdoc/client-shared.dart
index 7d9db1576d5528740b8d11d9bbcaec29c7759fb5..41ebe288d6c6635f0bb4116d18ae0ae398cf7abb 100644
--- a/pkg/dartdoc/client-shared.dart
+++ b/pkg/dartdoc/client-shared.dart
@@ -4,6 +4,21 @@
// Code shared between the different client-side libraries.
+// The names of the library and type that this page documents.
+String currentLibrary = null;
+String currentType = null;
+
+// What we need to prefix relative URLs with to get them to work.
+String prefix = '';
+
+void setupLocation() {
+ // Figure out where we are.
+ final body = document.query('body');
+ currentLibrary = body.dataAttributes['library'];
+ currentType = body.dataAttributes['type'];
+ prefix = (currentType != null) ? '../' : '';
+}
+
/**
* Finds all code blocks and makes them toggleable. Syntax highlights each
* code block the first time it's shown.
@@ -30,6 +45,30 @@ enableCodeBlocks() {
pre.classes.add('expanded');
}
});
-
}
}
+
+
+/** Turns [name] into something that's safe to use as a file name. */
+String sanitize(String name) => name.replaceAll(':', '_').replaceAll('/', '_');
+
+String getTypeName(Map typeInfo) =>
+ typeInfo.containsKey('args')
+ ? '${typeInfo[NAME]}<${typeInfo[NAME]}>'
+ : typeInfo[NAME];
+
+String getLibraryUrl(String libraryName) =>
+ '$prefix${sanitize(libraryName)}.html';
+
+String getTypeUrl(String libraryName, Map typeInfo) =>
+ '$prefix${sanitize(libraryName)}/${sanitize(typeInfo[NAME])}.html';
+
+String getLibraryMemberUrl(String libraryName, Map memberInfo) =>
+ '$prefix${sanitize(libraryName)}.html#${getMemberAnchor(memberInfo)}';
+
+String getTypeMemberUrl(String libraryName, String typeName, Map memberInfo) =>
+ '$prefix${sanitize(libraryName)}/${sanitize(typeName)}.html#'
+ '${getMemberAnchor(memberInfo)}';
+
+String getMemberAnchor(Map memberInfo) => memberInfo.containsKey(LINK_NAME)
+ ? memberInfo[LINK_NAME] : memberInfo[NAME];
« no previous file with comments | « pkg/dartdoc/client-live-nav.dart ('k') | pkg/dartdoc/client-static.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698