Skip to content

Commit 82c668a

Browse files
committed
Flatten change
1 parent 41ca816 commit 82c668a

File tree

329 files changed

+7179
-2881
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

329 files changed

+7179
-2881
lines changed

lib/dartdoc.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class DartDoc {
164164
if (config != null && config.autoIncludeDependencies) {
165165
package = Package.withAutoIncludedDependencies(
166166
libraries, packageMeta, warningOptions);
167-
libraries = package.libraries.map((l) => l.element).toList();
167+
libraries = package.publicLibraries.map((l) => l.element).toList();
168168
// remove excluded libraries again, in case they are picked up through
169169
// dependencies.
170170
excludes.forEach((pattern) {
@@ -200,10 +200,10 @@ class DartDoc {
200200

201201
double seconds = _stopwatch.elapsedMilliseconds / 1000.0;
202202
print(
203-
"\ndocumented ${package.libraries.length} librar${package.libraries.length == 1 ? 'y' : 'ies'} "
203+
"\ndocumented ${package.publicLibraries.length} librar${package.publicLibraries.length == 1 ? 'y' : 'ies'} "
204204
"in ${seconds.toStringAsFixed(1)} seconds");
205205

206-
if (package.libraries.isEmpty) {
206+
if (package.publicLibraries.isEmpty) {
207207
throw new DartDocFailure(
208208
"dartdoc could not find any libraries to document. Run `pub get` and try again.");
209209
}

lib/src/element_type.dart

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ class ElementType {
1515
final ModelElement element;
1616
String _linkedName;
1717

18-
ElementType(this._type, this.element);
18+
ElementType(this._type, this.element) {
19+
assert(element != null);
20+
}
21+
22+
DartType get type => _type;
1923

2024
bool get isDynamic => _type.isDynamic;
2125

@@ -56,7 +60,11 @@ class ElementType {
5660
return _linkedName;
5761
}
5862

59-
String get name => _type.name;
63+
String get name {
64+
if (_type.name == null)
65+
return _type.element.name;
66+
return _type.name;
67+
}
6068

6169
ModelElement get returnElement {
6270
Element e;
@@ -129,6 +137,11 @@ class ElementType {
129137
// can happen if element is dynamic
130138
if (f.element.library != null) {
131139
lib = new ModelElement.from(f.element.library, element.library);
140+
} else {
141+
// TODO(jcollins-g): Assigning libraries to dynamics doesn't make sense,
142+
// really, but is needed for .package.
143+
assert(f.element.kind == ElementKind.DYNAMIC);
144+
lib = element.library;
132145
}
133146
return new ElementType(f, new ModelElement.from(f.element, lib));
134147
}

lib/src/html/html_generator_instance.dart

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -96,86 +96,78 @@ class HtmlGeneratorInstance implements HtmlOptions {
9696

9797
generatePackage();
9898

99-
for (var lib in package.libraries) {
99+
for (var lib in package.libraries.where((l) => l.isDocumented)) {
100100
generateLibrary(package, lib);
101101

102-
for (var clazz in lib.allClasses) {
103-
// TODO(jcollins-g): consider refactor so that only the canonical
104-
// ModelElements show up in these lists
105-
if (!clazz.isCanonical) continue;
106-
102+
for (var clazz in lib.allClasses.where((c) => c.isDocumented)) {
107103
generateClass(package, lib, clazz);
108104

109-
for (var constructor in clazz.constructors) {
105+
for (var constructor in clazz.constructors.where((c) => c.isDocumented)) {
110106
if (!constructor.isCanonical) continue;
111107
generateConstructor(package, lib, clazz, constructor);
112108
}
113109

114-
for (var constant in clazz.constants) {
110+
for (var constant in clazz.constants.where((c) => c.isDocumented)) {
115111
if (!constant.isCanonical) continue;
116112
generateConstant(package, lib, clazz, constant);
117113
}
118114

119-
for (var property in clazz.staticProperties) {
115+
for (var property in clazz.staticProperties.where((s) => s.isDocumented)) {
120116
if (!property.isCanonical) continue;
121117
generateProperty(package, lib, clazz, property);
122118
}
123119

124-
for (var property in clazz.propertiesForPages) {
120+
for (var property in clazz.propertiesForPages.where((p) => p.isDocumented)) {
125121
if (!property.isCanonical) continue;
126122
generateProperty(package, lib, clazz, property);
127123
}
128124

129-
for (var method in clazz.methodsForPages) {
125+
for (var method in clazz.methodsForPages.where((m) => m.isDocumented)) {
130126
if (!method.isCanonical) continue;
131127
generateMethod(package, lib, clazz, method);
132128
}
133129

134-
for (var operator in clazz.operatorsForPages) {
130+
for (var operator in clazz.operatorsForPages.where((o) => o.isDocumented)) {
135131
if (!operator.isCanonical) continue;
136132
generateMethod(package, lib, clazz, operator);
137133
}
138134

139-
for (var method in clazz.staticMethods) {
135+
for (var method in clazz.staticMethods.where((s) => s.isDocumented)) {
140136
if (!method.isCanonical) continue;
141137
generateMethod(package, lib, clazz, method);
142138
}
143139
}
144140

145-
for (var eNum in lib.enums) {
146-
if (!eNum.isCanonical) continue;
141+
for (var eNum in lib.enums.where((e) => e.isDocumented)) {
147142
generateEnum(package, lib, eNum);
148-
for (var property in eNum.propertiesForPages) {
149-
if (!property.isCanonical) continue;
143+
for (var property in eNum.propertiesForPages.where((p) => p.isDocumented)) {
150144
generateProperty(package, lib, eNum, property);
151145
}
152-
for (var operator in eNum.operatorsForPages) {
153-
if (!operator.isCanonical) continue;
146+
for (var operator in eNum.operatorsForPages.where((o) => o.isDocumented)) {
154147
generateMethod(package, lib, eNum, operator);
155148
}
156-
for (var method in eNum.methodsForPages) {
157-
if (!method.isCanonical) continue;
149+
for (var method in eNum.methodsForPages.where((m) => m.isDocumented)) {
158150
generateMethod(package, lib, eNum, method);
159151
}
160152
}
161153

162-
for (var constant in lib.constants) {
163-
if (!constant.isCanonical) continue;
154+
for (var constant in lib.constants.where((e) => e.isDocumented)) {
164155
generateTopLevelConstant(package, lib, constant);
165156
}
166157

167-
for (var property in lib.properties) {
168-
if (!property.isCanonical) continue;
158+
for (var property in lib.properties.where((p) => p.isDocumented)) {
159+
if (property.name == 'topLevelVariable')
160+
1+1;
161+
if (property.linkedReturnType == '')
162+
1+1;
169163
generateTopLevelProperty(package, lib, property);
170164
}
171165

172-
for (var function in lib.functions) {
173-
if (!function.isCanonical) continue;
166+
for (var function in lib.functions.where((f) => f.isDocumented)) {
174167
generateFunction(package, lib, function);
175168
}
176169

177-
for (var typeDef in lib.typedefs) {
178-
if (!typeDef.isCanonical) continue;
170+
for (var typeDef in lib.typedefs.where((t) => t.isDocumented)) {
179171
generateTypeDef(package, lib, typeDef);
180172
}
181173
}
@@ -310,7 +302,9 @@ class HtmlGeneratorInstance implements HtmlOptions {
310302
assert(!_writtenFiles.contains(fullName));
311303
_writeFile(fullName, content);
312304
_writtenFiles.add(fullName);
313-
if (data.self is ModelElement) documentedElements.add(data.self);
305+
if (data.self is ModelElement) {
306+
documentedElements.add(data.self);
307+
}
314308
}
315309

316310
void _writeFile(String filename, String content) {

lib/src/html/template_data.dart

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -135,18 +135,18 @@ class LibraryTemplateData extends TemplateData<Library> {
135135
List get navLinks => [package];
136136
@override
137137
Iterable<Subnav> getSubNavItems() sync* {
138-
if (library.hasClasses)
138+
if (library.hasPublicClasses)
139139
yield new Subnav('Classes', '${library.href}#classes');
140-
if (library.hasConstants)
140+
if (library.hasPublicConstants)
141141
yield new Subnav('Constants', '${library.href}#constants');
142-
if (library.hasProperties)
142+
if (library.hasPublicProperties)
143143
yield new Subnav('Properties', '${library.href}#properties');
144-
if (library.hasFunctions)
144+
if (library.hasPublicFunctions)
145145
yield new Subnav('Functions', '${library.href}#functions');
146-
if (library.hasEnums) yield new Subnav('Enums', '${library.href}#enums');
147-
if (library.hasTypedefs)
146+
if (library.hasPublicEnums) yield new Subnav('Enums', '${library.href}#enums');
147+
if (library.hasPublicTypedefs)
148148
yield new Subnav('Typedefs', '${library.href}#typedefs');
149-
if (library.hasExceptions)
149+
if (library.hasPublicExceptions)
150150
yield new Subnav('Exceptions', '${library.href}#exceptions');
151151
}
152152

@@ -188,19 +188,19 @@ class ClassTemplateData extends TemplateData<Class> {
188188
String get htmlBase => '..';
189189
@override
190190
Iterable<Subnav> getSubNavItems() sync* {
191-
if (clazz.hasConstructors)
191+
if (clazz.hasPublicConstructors)
192192
yield new Subnav('Constructors', '${clazz.href}#constructors');
193-
if (clazz.hasProperties)
193+
if (clazz.hasPublicProperties)
194194
yield new Subnav('Properties', '${clazz.href}#instance-properties');
195-
if (clazz.hasMethods)
195+
if (clazz.hasPublicMethods)
196196
yield new Subnav('Methods', '${clazz.href}#instance-methods');
197-
if (clazz.hasOperators)
197+
if (clazz.hasPublicOperators)
198198
yield new Subnav('Operators', '${clazz.href}#operators');
199-
if (clazz.hasStaticProperties)
199+
if (clazz.hasPublicStaticProperties)
200200
yield new Subnav('Static Properties', '${clazz.href}#static-properties');
201-
if (clazz.hasStaticMethods)
201+
if (clazz.hasPublicStaticMethods)
202202
yield new Subnav('Static Methods', '${clazz.href}#static-methods');
203-
if (clazz.hasConstants)
203+
if (clazz.hasPublicConstants)
204204
yield new Subnav('Constants', '${clazz.href}#constants');
205205
}
206206

lib/src/html/templates.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ const _partials = const <String>[
2828
'sidebar_for_enum',
2929
'source_code',
3030
'sidebar_for_library',
31-
'accessor_getter',
32-
'accessor_setter'
3331
];
3432

3533
Future<Map<String, String>> _loadPartials(List<String> headerPaths,

lib/src/markdown_processor.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ Element _findRefElementInLibrary(String codeRef, ModelElement element,
390390
assert(element != null);
391391
assert(element.package.allLibrariesAdded);
392392

393+
393394
String codeRefChomped = codeRef.replaceFirst(isConstructor, '');
394395

395396
final Library library = element.library;
@@ -518,6 +519,7 @@ Element _findRefElementInLibrary(String codeRef, ModelElement element,
518519
}
519520
}
520521
}
522+
results.remove(null);
521523

522524
// This could conceivably be a reference to an enum member. They don't show up in allModelElements.
523525
// TODO(jcollins-g): Put enum members in allModelElements with useful hrefs without blowing up other assumptions about what that means.
@@ -541,10 +543,10 @@ Element _findRefElementInLibrary(String codeRef, ModelElement element,
541543
}
542544
}
543545
}
546+
results.remove(null);
544547

545548
Element result;
546549

547-
results.remove(null);
548550
if (results.length > 1) {
549551
// If this name could refer to a class or a constructor, prefer the class.
550552
if (results.any((r) => r is Class)) {

0 commit comments

Comments
 (0)