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

Side by Side Diff: pkg/dartdoc/lib/src/client/client-shared.dart

Issue 10985085: Members and comments inherited in dartdoc. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/dartdoc/lib/mirrors_util.dart ('k') | pkg/dartdoc/lib/src/dartdoc/comment_map.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 // Code shared between the different client-side libraries. 5 // Code shared between the different client-side libraries.
6 6
7 // The names of the library and type that this page documents. 7 // The names of the library and type that this page documents.
8 String currentLibrary = null; 8 String currentLibrary = null;
9 String currentType = null; 9 String currentType = null;
10 10
11 // What we need to prefix relative URLs with to get them to work. 11 // What we need to prefix relative URLs with to get them to work.
12 String prefix = ''; 12 String prefix = '';
13 13
14 void setup() { 14 void setup() {
15 setupLocation(); 15 setupLocation();
16 setupShortcuts(); 16 setupShortcuts();
17 enableCodeBlocks(); 17 enableCodeBlocks();
18 enableShowHideInherited();
18 } 19 }
19 20
20 void setupLocation() { 21 void setupLocation() {
21 // Figure out where we are. 22 // Figure out where we are.
22 final body = document.query('body'); 23 final body = document.query('body');
23 currentLibrary = body.dataAttributes['library']; 24 currentLibrary = body.dataAttributes['library'];
24 currentType = body.dataAttributes['type']; 25 currentType = body.dataAttributes['type'];
25 prefix = (currentType != null) ? '../' : ''; 26 prefix = (currentType != null) ? '../' : '';
26 } 27 }
27 28
(...skipping 19 matching lines...) Expand all
47 if (!pre.classes.contains('formatted')) { 48 if (!pre.classes.contains('formatted')) {
48 pre.innerHTML = classifySource(pre.text); 49 pre.innerHTML = classifySource(pre.text);
49 pre.classes.add('formatted'); 50 pre.classes.add('formatted');
50 }; 51 };
51 pre.classes.add('expanded'); 52 pre.classes.add('expanded');
52 } 53 }
53 }); 54 });
54 } 55 }
55 } 56 }
56 57
58 /**
59 * Enables show/hide functionality for inherited members and comments.
60 */
61 void enableShowHideInherited() {
62 var showInherited = document.query('#show-inherited');
63 if (showInherited == null) return;
64 showInherited.dataAttributes.putIfAbsent('show-inherited', () => 'block');
65 showInherited.on.click.add((e) {
66 String display = showInherited.dataAttributes['show-inherited'];
67 if (display == 'block') {
68 display = 'none';
69 showInherited.innerHTML = 'Show inherited';
70 } else {
71 display = 'block';
72 showInherited.innerHTML = 'Hide inherited';
73 }
74 showInherited.dataAttributes['show-inherited'] = display;
75 for (var elem in document.queryAll('.inherited')) {
76 elem.style.display = display;
77 }
78 });
79
80 }
57 81
58 /** Turns [name] into something that's safe to use as a file name. */ 82 /** Turns [name] into something that's safe to use as a file name. */
59 String sanitize(String name) => name.replaceAll(':', '_').replaceAll('/', '_'); 83 String sanitize(String name) => name.replaceAll(':', '_').replaceAll('/', '_');
60 84
61 String getTypeName(Map typeInfo) => 85 String getTypeName(Map typeInfo) =>
62 typeInfo.containsKey('args') 86 typeInfo.containsKey('args')
63 ? '${typeInfo[NAME]}<${typeInfo[NAME]}>' 87 ? '${typeInfo[NAME]}<${typeInfo[NAME]}>'
64 : typeInfo[NAME]; 88 : typeInfo[NAME];
65 89
66 String getLibraryUrl(String libraryName) => 90 String getLibraryUrl(String libraryName) =>
67 '$prefix${sanitize(libraryName)}.html'; 91 '$prefix${sanitize(libraryName)}.html';
68 92
69 String getTypeUrl(String libraryName, Map typeInfo) => 93 String getTypeUrl(String libraryName, Map typeInfo) =>
70 '$prefix${sanitize(libraryName)}/${sanitize(typeInfo[NAME])}.html'; 94 '$prefix${sanitize(libraryName)}/${sanitize(typeInfo[NAME])}.html';
71 95
72 String getLibraryMemberUrl(String libraryName, Map memberInfo) => 96 String getLibraryMemberUrl(String libraryName, Map memberInfo) =>
73 '$prefix${sanitize(libraryName)}.html#${getMemberAnchor(memberInfo)}'; 97 '$prefix${sanitize(libraryName)}.html#${getMemberAnchor(memberInfo)}';
74 98
75 String getTypeMemberUrl(String libraryName, String typeName, Map memberInfo) => 99 String getTypeMemberUrl(String libraryName, String typeName, Map memberInfo) =>
76 '$prefix${sanitize(libraryName)}/${sanitize(typeName)}.html#' 100 '$prefix${sanitize(libraryName)}/${sanitize(typeName)}.html#'
77 '${getMemberAnchor(memberInfo)}'; 101 '${getMemberAnchor(memberInfo)}';
78 102
79 String getMemberAnchor(Map memberInfo) => memberInfo.containsKey(LINK_NAME) 103 String getMemberAnchor(Map memberInfo) => memberInfo.containsKey(LINK_NAME)
80 ? memberInfo[LINK_NAME] : memberInfo[NAME]; 104 ? memberInfo[LINK_NAME] : memberInfo[NAME];
OLDNEW
« no previous file with comments | « pkg/dartdoc/lib/mirrors_util.dart ('k') | pkg/dartdoc/lib/src/dartdoc/comment_map.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698