| OLD | NEW |
| 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.models.library; | 5 library docgen.models.library; |
| 6 | 6 |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 | 8 |
| 9 import 'package:markdown/markdown.dart' as markdown; | 9 import 'package:markdown/markdown.dart' as markdown; |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 /// Top-level variables in the library. | 31 /// Top-level variables in the library. |
| 32 Map<String, Variable> variables; | 32 Map<String, Variable> variables; |
| 33 | 33 |
| 34 /// Top-level functions in the library. | 34 /// Top-level functions in the library. |
| 35 Map<String, Method> functions; | 35 Map<String, Method> functions; |
| 36 | 36 |
| 37 String packageName = ''; | 37 String packageName = ''; |
| 38 bool _hasBeenCheckedForPackage = false; | 38 bool _hasBeenCheckedForPackage = false; |
| 39 String packageIntro; | 39 String packageIntro; |
| 40 | 40 |
| 41 Indexable get owner => const _LibraryOwner(); |
| 42 |
| 41 Library get owningLibrary => this; | 43 Library get owningLibrary => this; |
| 42 | 44 |
| 43 /// Returns the [Library] for the given [mirror] if it has already been | 45 /// Returns the [Library] for the given [mirror] if it has already been |
| 44 /// created, else creates it. | 46 /// created, else creates it. |
| 45 factory Library(LibraryMirror mirror) { | 47 factory Library(LibraryMirror mirror) { |
| 46 var library = getDocgenObject(mirror); | 48 var library = getDocgenObject(mirror); |
| 47 if (library is DummyMirror) { | 49 if (library is DummyMirror) { |
| 48 library = new Library._(mirror); | 50 library = new Library._(mirror); |
| 49 } | 51 } |
| 50 return library; | 52 return library; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 var map = {'packageName': packageName}; | 140 var map = {'packageName': packageName}; |
| 139 map.addAll(super.previewMap); | 141 map.addAll(super.previewMap); |
| 140 if (packageIntro != null) { | 142 if (packageIntro != null) { |
| 141 map['packageIntro'] = packageIntro; | 143 map['packageIntro'] = packageIntro; |
| 142 } | 144 } |
| 143 return map; | 145 return map; |
| 144 } | 146 } |
| 145 | 147 |
| 146 String get name => docName; | 148 String get name => docName; |
| 147 | 149 |
| 148 String get docName { | 150 String get docName => getLibraryDocName(mirror); |
| 149 return dart2js_util.qualifiedNameOf(mirror).replaceAll('.', '-'); | |
| 150 } | |
| 151 | 151 |
| 152 /// Generates a map describing the [Library] object. | 152 /// Generates a map describing the [Library] object. |
| 153 Map toMap() => { | 153 Map toMap() => { |
| 154 'name': name, | 154 'name': name, |
| 155 'qualifiedName': qualifiedName, | 155 'qualifiedName': qualifiedName, |
| 156 'comment': comment, | 156 'comment': comment, |
| 157 'variables': recurseMap(variables), | 157 'variables': recurseMap(variables), |
| 158 'functions': expandMethodMap(functions), | 158 'functions': expandMethodMap(functions), |
| 159 'classes': { | 159 'classes': { |
| 160 'class': classes.values.where((c) => c.isVisible) | 160 'class': classes.values.where((c) => c.isVisible) |
| 161 .map((e) => e.previewMap).toList(), | 161 .map((e) => e.previewMap).toList(), |
| 162 'typedef': recurseMap(typedefs), | 162 'typedef': recurseMap(typedefs), |
| 163 'error': errors.values.where((e) => e.isVisible) | 163 'error': errors.values.where((e) => e.isVisible) |
| 164 .map((e) => e.previewMap).toList() | 164 .map((e) => e.previewMap).toList() |
| 165 }, | 165 }, |
| 166 'packageName': packageName, | 166 'packageName': packageName, |
| 167 'packageIntro': packageIntro | 167 'packageIntro': packageIntro |
| 168 }; | 168 }; |
| 169 | 169 |
| 170 String get typeName => 'library'; | 170 String get typeName => 'library'; |
| 171 | 171 |
| 172 bool isValidMirror(DeclarationMirror mirror) => mirror is LibraryMirror; | 172 bool isValidMirror(DeclarationMirror mirror) => mirror is LibraryMirror; |
| 173 } | 173 } |
| 174 |
| 175 /// Dummy implementation of Indexable to represent the owner of a Library. |
| 176 class _LibraryOwner implements Indexable { |
| 177 const _LibraryOwner(); |
| 178 |
| 179 String get docName => ''; |
| 180 |
| 181 bool get isPrivate => false; |
| 182 |
| 183 Indexable get owner => null; |
| 184 |
| 185 // This is a known incomplete implementation of Indexable |
| 186 // overriding noSuchMethod to remove static warnings |
| 187 noSuchMethod(Invocation invocation) { |
| 188 throw new UnimplementedError(invocation.memberName.toString()); |
| 189 } |
| 190 } |
| OLD | NEW |