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

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: Rebased. 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
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() {
15 setupLocation();
16 enableCodeBlocks();
17 enableShowHideInherited();
18 }
19
14 void setupLocation() { 20 void setupLocation() {
15 // Figure out where we are. 21 // Figure out where we are.
16 final body = document.query('body'); 22 final body = document.query('body');
17 currentLibrary = body.dataAttributes['library']; 23 currentLibrary = body.dataAttributes['library'];
18 currentType = body.dataAttributes['type']; 24 currentType = body.dataAttributes['type'];
19 prefix = (currentType != null) ? '../' : ''; 25 prefix = (currentType != null) ? '../' : '';
20 } 26 }
21 27
22 /** 28 /**
23 * Finds all code blocks and makes them toggleable. Syntax highlights each 29 * Finds all code blocks and makes them toggleable. Syntax highlights each
(...skipping 17 matching lines...) Expand all
41 if (!pre.classes.contains('formatted')) { 47 if (!pre.classes.contains('formatted')) {
42 pre.innerHTML = classifySource(pre.text); 48 pre.innerHTML = classifySource(pre.text);
43 pre.classes.add('formatted'); 49 pre.classes.add('formatted');
44 }; 50 };
45 pre.classes.add('expanded'); 51 pre.classes.add('expanded');
46 } 52 }
47 }); 53 });
48 } 54 }
49 } 55 }
50 56
57 /**
58 * Enables show/hide functionality for inherited members and comments.
59 */
60 void enableShowHideInherited() {
61 var showInherited = document.query('.show-inherited');
Lasse Reichstein Nielsen 2012/10/04 07:41:19 Why is show-inherited a class and not an id? Do yo
Johnni Winther 2012/10/04 12:46:21 Done.
62 if (showInherited == null) return;
63 showInherited.dataAttributes.putIfAbsent('show-inherited', () => 'block');
64 showInherited.on.click.add((e) {
65 String display = showInherited.dataAttributes['show-inherited'];
66 if (display == 'block') {
67 display = 'none';
68 showInherited.innerHTML = 'Show inherited';
69 } else {
70 display = 'block';
71 showInherited.innerHTML = 'Hide inherited';
72 }
73 showInherited.dataAttributes['show-inherited'] = display;
74 for (var elem in document.queryAll('.inherited')) {
75 elem.style.display = display;
76 }
77 });
78
79 }
51 80
52 /** Turns [name] into something that's safe to use as a file name. */ 81 /** Turns [name] into something that's safe to use as a file name. */
53 String sanitize(String name) => name.replaceAll(':', '_').replaceAll('/', '_'); 82 String sanitize(String name) => name.replaceAll(':', '_').replaceAll('/', '_');
54 83
55 String getTypeName(Map typeInfo) => 84 String getTypeName(Map typeInfo) =>
56 typeInfo.containsKey('args') 85 typeInfo.containsKey('args')
57 ? '${typeInfo[NAME]}<${typeInfo[NAME]}>' 86 ? '${typeInfo[NAME]}<${typeInfo[NAME]}>'
58 : typeInfo[NAME]; 87 : typeInfo[NAME];
59 88
60 String getLibraryUrl(String libraryName) => 89 String getLibraryUrl(String libraryName) =>
61 '$prefix${sanitize(libraryName)}.html'; 90 '$prefix${sanitize(libraryName)}.html';
62 91
63 String getTypeUrl(String libraryName, Map typeInfo) => 92 String getTypeUrl(String libraryName, Map typeInfo) =>
64 '$prefix${sanitize(libraryName)}/${sanitize(typeInfo[NAME])}.html'; 93 '$prefix${sanitize(libraryName)}/${sanitize(typeInfo[NAME])}.html';
65 94
66 String getLibraryMemberUrl(String libraryName, Map memberInfo) => 95 String getLibraryMemberUrl(String libraryName, Map memberInfo) =>
67 '$prefix${sanitize(libraryName)}.html#${getMemberAnchor(memberInfo)}'; 96 '$prefix${sanitize(libraryName)}.html#${getMemberAnchor(memberInfo)}';
68 97
69 String getTypeMemberUrl(String libraryName, String typeName, Map memberInfo) => 98 String getTypeMemberUrl(String libraryName, String typeName, Map memberInfo) =>
70 '$prefix${sanitize(libraryName)}/${sanitize(typeName)}.html#' 99 '$prefix${sanitize(libraryName)}/${sanitize(typeName)}.html#'
71 '${getMemberAnchor(memberInfo)}'; 100 '${getMemberAnchor(memberInfo)}';
72 101
73 String getMemberAnchor(Map memberInfo) => memberInfo.containsKey(LINK_NAME) 102 String getMemberAnchor(Map memberInfo) => memberInfo.containsKey(LINK_NAME)
74 ? memberInfo[LINK_NAME] : memberInfo[NAME]; 103 ? memberInfo[LINK_NAME] : memberInfo[NAME];
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698