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

Side by Side Diff: pkg/docgen/lib/src/library_helpers.dart

Issue 288033010: Add versioning information for packages and the SDK. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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/docgen/lib/src/generator.dart ('k') | pkg/docgen/lib/src/models/library.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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library docgen.library_helpers; 5 library docgen.library_helpers;
6 6
7 import 'package:logging/logging.dart'; 7 import 'package:logging/logging.dart';
8 import 'package:markdown/markdown.dart' as markdown; 8 import 'package:markdown/markdown.dart' as markdown;
9 9
10 import 'exports/source_mirrors.dart'; 10 import 'exports/source_mirrors.dart';
(...skipping 28 matching lines...) Expand all
39 bool isFullChainVisible(Indexable item) { 39 bool isFullChainVisible(Indexable item) {
40 return includePrivateMembers || (!item.isPrivate && (item.owner != null ? 40 return includePrivateMembers || (!item.isPrivate && (item.owner != null ?
41 isFullChainVisible(item.owner) : true)); 41 isFullChainVisible(item.owner) : true));
42 } 42 }
43 43
44 /// Logger for printing out progress of documentation generation. 44 /// Logger for printing out progress of documentation generation.
45 final Logger logger = new Logger('Docgen'); 45 final Logger logger = new Logger('Docgen');
46 46
47 /// The dart:core library, which contains all types that are always available 47 /// The dart:core library, which contains all types that are always available
48 /// without import. 48 /// without import.
49 Library _coreLibrary; 49 Library coreLibrary;
50 50
51 /// Set of libraries declared in the SDK, so libraries that can be accessed 51 /// Set of libraries declared in the SDK, so libraries that can be accessed
52 /// when running dart by default. 52 /// when running dart by default.
53 Iterable<LibraryMirror> get sdkLibraries => _sdkLibraries; 53 Iterable<LibraryMirror> get sdkLibraries => _sdkLibraries;
54 Iterable<LibraryMirror> _sdkLibraries; 54 Iterable<LibraryMirror> _sdkLibraries;
55 55
56 ////// Top level resolution functions 56 ////// Top level resolution functions
57 /// Converts all [foo] references in comments to <a>libraryName.foo</a>. 57 /// Converts all [foo] references in comments to <a>libraryName.foo</a>.
58 markdown.Node globalFixReference(String name) { 58 markdown.Node globalFixReference(String name) {
59 // Attempt the look up the whole name up in the scope. 59 // Attempt the look up the whole name up in the scope.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 if (!added) { 95 if (!added) {
96 accumulatedHtml += token; 96 accumulatedHtml += token;
97 } 97 }
98 } 98 }
99 return new markdown.Text(accumulatedHtml); 99 return new markdown.Text(accumulatedHtml);
100 } 100 }
101 101
102 String findElementInScopeWithPrefix(String name, String packagePrefix) { 102 String findElementInScopeWithPrefix(String name, String packagePrefix) {
103 var lookupFunc = determineLookupFunc(name); 103 var lookupFunc = determineLookupFunc(name);
104 // Look in the dart core library scope. 104 // Look in the dart core library scope.
105 var coreScope = _coreLibrary == null ? null : lookupFunc(_coreLibrary.mirror, 105 var coreScope = coreLibrary == null ? null : lookupFunc(coreLibrary.mirror,
106 name); 106 name);
107 if (coreScope != null) return packagePrefix + _coreLibrary.docName; 107 if (coreScope != null) return packagePrefix + coreLibrary.docName;
108 108
109 // If it's a reference that starts with a another library name, then it 109 // If it's a reference that starts with a another library name, then it
110 // looks for a match of that library name in the other sdk libraries. 110 // looks for a match of that library name in the other sdk libraries.
111 if (name.contains('.')) { 111 if (name.contains('.')) {
112 var index = name.indexOf('.'); 112 var index = name.indexOf('.');
113 var libraryName = name.substring(0, index); 113 var libraryName = name.substring(0, index);
114 var remainingName = name.substring(index + 1); 114 var remainingName = name.substring(index + 1);
115 foundLibraryName(library) => library.uri.pathSegments[0] == libraryName; 115 foundLibraryName(library) => library.uri.pathSegments[0] == libraryName;
116 116
117 if (_sdkLibraries.any(foundLibraryName)) { 117 if (_sdkLibraries.any(foundLibraryName)) {
(...skipping 24 matching lines...) Expand all
142 Map<String, Indexable> docgenObj = lookupIndexableMap(mirror); 142 Map<String, Indexable> docgenObj = lookupIndexableMap(mirror);
143 143
144 if (docgenObj == null) { 144 if (docgenObj == null) {
145 return new DummyMirror(mirror, owner); 145 return new DummyMirror(mirror, owner);
146 } 146 }
147 147
148 var setToExamine = new Set(); 148 var setToExamine = new Set();
149 if (owner != null) { 149 if (owner != null) {
150 var firstSet = docgenObj[owner.docName]; 150 var firstSet = docgenObj[owner.docName];
151 if (firstSet != null) setToExamine.add(firstSet); 151 if (firstSet != null) setToExamine.add(firstSet);
152 if (_coreLibrary != null && docgenObj[_coreLibrary.docName] != null) { 152 if (coreLibrary != null && docgenObj[coreLibrary.docName] != null) {
153 setToExamine.add(docgenObj[_coreLibrary.docName]); 153 setToExamine.add(docgenObj[coreLibrary.docName]);
154 } 154 }
155 } else { 155 } else {
156 setToExamine.addAll(docgenObj.values); 156 setToExamine.addAll(docgenObj.values);
157 } 157 }
158 158
159 Set<Indexable> results = new Set<Indexable>(); 159 Set<Indexable> results = new Set<Indexable>();
160 for (Indexable indexable in setToExamine) { 160 for (Indexable indexable in setToExamine) {
161 if (indexable.mirror.qualifiedName == mirror.qualifiedName && 161 if (indexable.mirror.qualifiedName == mirror.qualifiedName &&
162 indexable.isValidMirror(mirror)) { 162 indexable.isValidMirror(mirror)) {
163 results.add(indexable); 163 results.add(indexable);
164 } 164 }
165 } 165 }
166 166
167 if (results.length > 0) { 167 if (results.length > 0) {
168 // This might occur if we didn't specify an "owner." 168 // This might occur if we didn't specify an "owner."
169 return results.first; 169 return results.first;
170 } 170 }
171 return new DummyMirror(mirror, owner); 171 return new DummyMirror(mirror, owner);
172 } 172 }
173 173
174 void initializeTopLevelLibraries(MirrorSystem mirrorSystem) { 174 void initializeTopLevelLibraries(MirrorSystem mirrorSystem) {
175 _sdkLibraries = mirrorSystem.libraries.values.where( 175 _sdkLibraries = mirrorSystem.libraries.values.where(
176 (each) => each.uri.scheme == 'dart'); 176 (each) => each.uri.scheme == 'dart');
177 _coreLibrary = new Library(_sdkLibraries.singleWhere((lib) => 177 coreLibrary = new Library(_sdkLibraries.singleWhere((lib) =>
178 lib.uri.toString().startsWith('dart:core'))); 178 lib.uri.toString().startsWith('dart:core')));
179 } 179 }
180 180
181 /// For a given name, determine if we need to resolve it as a qualified name 181 /// For a given name, determine if we need to resolve it as a qualified name
182 /// or a simple name in the source mirors. 182 /// or a simple name in the source mirors.
183 LookupFunction determineLookupFunc(String name) => name.contains('.') ? 183 LookupFunction determineLookupFunc(String name) => name.contains('.') ?
184 dart2js_util.lookupQualifiedInScope : 184 dart2js_util.lookupQualifiedInScope :
185 (mirror, name) => mirror.lookupInScope(name); 185 (mirror, name) => mirror.lookupInScope(name);
186 186
187 /// Chunk the provided name into individual parts to be resolved. We take a 187 /// Chunk the provided name into individual parts to be resolved. We take a
(...skipping 23 matching lines...) Expand all
211 append = true; 211 append = true;
212 } 212 }
213 index++; 213 index++;
214 } 214 }
215 } 215 }
216 return tokens; 216 return tokens;
217 } 217 }
218 218
219 // HTML escaped version of '<' character. 219 // HTML escaped version of '<' character.
220 const _LESS_THAN = '&lt;'; 220 const _LESS_THAN = '&lt;';
OLDNEW
« no previous file with comments | « pkg/docgen/lib/src/generator.dart ('k') | pkg/docgen/lib/src/models/library.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698