Skip to content

Commit 0c11634

Browse files
committed
reverted back to path instead of pathos and use explicit package root, just like buildbot
R=rnystrom@google.com Review URL: https://codereview.chromium.org//19309004 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@25062 260f80e4-7a28-3924-810f-c04153c831b5
1 parent cd82c36 commit 0c11634

File tree

3 files changed

+83
-63
lines changed

3 files changed

+83
-63
lines changed

pkg/docgen/lib/dart2yaml.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,11 @@ void _addLevel(StringBuffer yaml, Map documentData, int level) {
5252
* Returns an escaped String form of the inputted element.
5353
*/
5454
String _processElement(var element) {
55-
return "\"${element.toString().replaceAll('\\', '\\\\')
56-
.replaceAll("\"", "\\\"")}\"\n";
55+
var contents = element.toString()
56+
.replaceAll('\\', r'\\')
57+
.replaceAll('"', r'\"')
58+
.replaceAll('\n', r'\n');
59+
return '"$contents"\n';
5760
}
5861

5962
/**

pkg/docgen/lib/docgen.dart

Lines changed: 68 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,9 @@ String _getComment(DeclarationMirror mirror) {
266266
}
267267
}
268268
});
269-
commentText = commentText == null ? '' :
270-
markdown.markdownToHtml(commentText.trim(), linkResolver: linkResolver)
271-
.replaceAll('\n', ' ');
269+
270+
commentText = commentText == null ? '' :
271+
markdown.markdownToHtml(commentText.trim(), linkResolver: linkResolver);
272272
return commentText;
273273
}
274274

@@ -300,9 +300,9 @@ Map<String, Variable> _getVariables(Map<String, VariableMirror> mirrorMap,
300300
mirrorMap.forEach((String mirrorName, VariableMirror mirror) {
301301
if (includePrivate || !mirror.isPrivate) {
302302
_currentMember = mirror;
303-
data[mirrorName] = new Variable(mirrorName, mirror.qualifiedName,
304-
mirror.isFinal, mirror.isStatic, mirror.type.qualifiedName,
305-
_getComment(mirror), _getAnnotations(mirror));
303+
data[mirrorName] = new Variable(mirrorName, mirror.isFinal,
304+
mirror.isStatic, mirror.type.qualifiedName, _getComment(mirror),
305+
_getAnnotations(mirror));
306306
}
307307
});
308308
return data;
@@ -311,21 +311,42 @@ Map<String, Variable> _getVariables(Map<String, VariableMirror> mirrorMap,
311311
/**
312312
* Returns a map of [Method] objects constructed from inputted mirrors.
313313
*/
314-
Map<String, Method> _getMethods(Map<String, MethodMirror> mirrorMap,
315-
bool includePrivate) {
316-
var data = {};
314+
Map<String, Map<String, Method>> _getMethods
315+
(Map<String, MethodMirror> mirrorMap, bool includePrivate) {
316+
317+
var setters = {};
318+
var getters = {};
319+
var constructors = {};
320+
var operators = {};
321+
var methods = {};
322+
317323
mirrorMap.forEach((String mirrorName, MethodMirror mirror) {
318324
if (includePrivate || !mirror.isPrivate) {
325+
var method = new Method(mirrorName, mirror.isStatic,
326+
mirror.returnType.qualifiedName, _getComment(mirror),
327+
_getParameters(mirror.parameters), _getAnnotations(mirror));
319328
_currentMember = mirror;
320-
data[mirrorName] = new Method(mirrorName, mirror.qualifiedName,
321-
mirror.isSetter, mirror.isGetter, mirror.isConstructor,
322-
mirror.isOperator, mirror.isStatic, mirror.returnType.qualifiedName,
323-
_getComment(mirror), _getParameters(mirror.parameters),
324-
_getAnnotations(mirror));
329+
if (mirror.isSetter) {
330+
setters[mirrorName] = method;
331+
} else if (mirror.isGetter) {
332+
getters[mirrorName] = method;
333+
} else if (mirror.isConstructor) {
334+
constructors[mirrorName] = method;
335+
} else if (mirror.isOperator) {
336+
operators[mirrorName] = method;
337+
} else if (mirror.isRegularMethod) {
338+
methods[mirrorName] = method;
339+
} else {
340+
throw new StateError('${mirror.qualifiedName} - no method type match');
341+
}
325342
}
326343
});
327-
return data;
328-
}
344+
return {'setters' : setters,
345+
'getters' : getters,
346+
'constructors' : constructors,
347+
'operators' : operators,
348+
'methods' : methods};
349+
}
329350

330351
/**
331352
* Returns a map of [Class] objects constructed from inputted mirrors.
@@ -340,9 +361,8 @@ Map<String, Class> _getClasses(Map<String, ClassMirror> mirrorMap,
340361
mirror.superclass.qualifiedName : '';
341362
var interfaces =
342363
mirror.superinterfaces.map((interface) => interface.qualifiedName);
343-
data[mirrorName] = new Class(mirrorName, mirror.qualifiedName,
344-
superclass, mirror.isAbstract, mirror.isTypedef,
345-
_getComment(mirror), interfaces.toList(),
364+
data[mirrorName] = new Class(mirrorName, superclass, mirror.isAbstract,
365+
mirror.isTypedef, _getComment(mirror), interfaces.toList(),
346366
_getVariables(mirror.variables, includePrivate),
347367
_getMethods(mirror.methods, includePrivate),
348368
_getAnnotations(mirror));
@@ -358,10 +378,10 @@ Map<String, Parameter> _getParameters(List<ParameterMirror> mirrorList) {
358378
var data = {};
359379
mirrorList.forEach((ParameterMirror mirror) {
360380
_currentMember = mirror;
361-
data[mirror.simpleName] = new Parameter(mirror.simpleName,
362-
mirror.qualifiedName, mirror.isOptional, mirror.isNamed,
363-
mirror.hasDefaultValue, mirror.type.qualifiedName,
364-
mirror.defaultValue, _getAnnotations(mirror));
381+
data[mirror.simpleName] = new Parameter(mirror.simpleName,
382+
mirror.isOptional, mirror.isNamed, mirror.hasDefaultValue,
383+
mirror.type.qualifiedName, mirror.defaultValue,
384+
_getAnnotations(mirror));
365385
});
366386
return data;
367387
}
@@ -388,7 +408,11 @@ void _writeToFile(String text, String filename) {
388408
Map recurseMap(Map inputMap) {
389409
var outputMap = {};
390410
inputMap.forEach((key, value) {
391-
outputMap[key] = value.toMap();
411+
if (value is Map) {
412+
outputMap[key] = recurseMap(value);
413+
} else {
414+
outputMap[key] = value.toMap();
415+
}
392416
});
393417
return outputMap;
394418
}
@@ -405,8 +429,8 @@ class Library {
405429
Map<String, Variable> variables;
406430

407431
/// Top-level functions in the library.
408-
Map<String, Method> functions;
409-
432+
Map<String, Map<String, Method>> functions;
433+
410434
/// Classes defined within the library
411435
Map<String, Class> classes;
412436

@@ -443,26 +467,24 @@ class Class {
443467
Map<String, Variable> variables;
444468

445469
/// Methods in the class.
446-
Map<String, Method> methods;
447-
470+
Map<String, Map<String, Method>> methods;
471+
448472
String name;
449-
String qualifiedName;
450473
String superclass;
451474
bool isAbstract;
452475
bool isTypedef;
453476

454477
/// List of the meta annotations on the class.
455478
List<String> annotations;
456-
457-
Class(this.name, this.qualifiedName, this.superclass, this.isAbstract,
458-
this.isTypedef, this.comment, this.interfaces, this.variables,
459-
this.methods, this.annotations);
479+
480+
Class(this.name, this.superclass, this.isAbstract, this.isTypedef,
481+
this.comment, this.interfaces, this.variables, this.methods,
482+
this.annotations);
460483

461484
/// Generates a map describing the [Class] object.
462485
Map toMap() {
463486
var classMap = {};
464487
classMap['name'] = name;
465-
classMap['qualifiedname'] = qualifiedName;
466488
classMap['comment'] = comment;
467489
classMap['superclass'] = superclass;
468490
classMap['abstract'] = isAbstract.toString();
@@ -484,22 +506,20 @@ class Variable {
484506
String comment;
485507

486508
String name;
487-
String qualifiedName;
488509
bool isFinal;
489510
bool isStatic;
490511
String type;
491512

492513
/// List of the meta annotations on the variable.
493514
List<String> annotations;
494-
495-
Variable(this.name, this.qualifiedName, this.isFinal, this.isStatic,
496-
this.type, this.comment, this.annotations);
497-
515+
516+
Variable(this.name, this.isFinal, this.isStatic, this.type, this.comment,
517+
this.annotations);
518+
498519
/// Generates a map describing the [Variable] object.
499520
Map toMap() {
500521
var variableMap = {};
501522
variableMap['name'] = name;
502-
variableMap['qualifiedname'] = qualifiedName;
503523
variableMap['comment'] = comment;
504524
variableMap['final'] = isFinal.toString();
505525
variableMap['static'] = isStatic.toString();
@@ -521,29 +541,20 @@ class Method {
521541
Map<String, Parameter> parameters;
522542

523543
String name;
524-
String qualifiedName;
525-
bool isSetter;
526-
bool isGetter;
527-
bool isConstructor;
528-
bool isOperator;
529544
bool isStatic;
530545
String returnType;
531546

532547
/// List of the meta annotations on the method.
533548
List<String> annotations;
534-
535-
Method(this.name, this.qualifiedName, this.isSetter, this.isGetter,
536-
this.isConstructor, this.isOperator, this.isStatic, this.returnType,
537-
this.comment, this.parameters, this.annotations);
538-
549+
550+
Method(this.name, this.isStatic, this.returnType, this.comment,
551+
this.parameters, this.annotations);
552+
539553
/// Generates a map describing the [Method] object.
540554
Map toMap() {
541555
var methodMap = {};
542556
methodMap['name'] = name;
543-
methodMap['qualifiedname'] = qualifiedName;
544557
methodMap['comment'] = comment;
545-
methodMap['type'] = isSetter ? 'setter' : isGetter ? 'getter' :
546-
isOperator ? 'operator' : isConstructor ? 'constructor' : 'method';
547558
methodMap['static'] = isStatic.toString();
548559
methodMap['return'] = returnType;
549560
methodMap['parameters'] = recurseMap(parameters);
@@ -558,7 +569,6 @@ class Method {
558569
class Parameter {
559570

560571
String name;
561-
String qualifiedName;
562572
bool isOptional;
563573
bool isNamed;
564574
bool hasDefaultValue;
@@ -567,15 +577,14 @@ class Parameter {
567577

568578
/// List of the meta annotations on the parameter.
569579
List<String> annotations;
570-
571-
Parameter(this.name, this.qualifiedName, this.isOptional, this.isNamed,
572-
this.hasDefaultValue, this.type, this.defaultValue, this.annotations);
573-
580+
581+
Parameter(this.name, this.isOptional, this.isNamed, this.hasDefaultValue,
582+
this.type, this.defaultValue, this.annotations);
583+
574584
/// Generates a map describing the [Parameter] object.
575585
Map toMap() {
576586
var parameterMap = {};
577587
parameterMap['name'] = name;
578-
parameterMap['qualifiedname'] = qualifiedName;
579588
parameterMap['optional'] = isOptional.toString();
580589
parameterMap['named'] = isNamed.toString();
581590
parameterMap['default'] = hasDefaultValue.toString();

pkg/docgen/test/single_library_test.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ main() {
5757
var classes = library.classes.values;
5858
expect(classes.every((e) => e is Class), isTrue);
5959

60+
var classMethodTypes = [];
61+
classes.forEach((e) => classMethodTypes.addAll(e.methods.values));
62+
expect(classMethodTypes.every((e) => e is Map), isTrue);
63+
6064
var classMethods = [];
61-
classes.forEach((e) => classMethods.addAll(e.methods.values));
65+
classMethodTypes.forEach((e) => classMethods.addAll(e.values));
6266
expect(classMethods.every((e) => e is Method), isTrue);
6367

6468
var methodParameters = [];
@@ -67,7 +71,11 @@ main() {
6771
});
6872
expect(methodParameters.every((e) => e is Parameter), isTrue);
6973

70-
var functions = library.functions.values;
74+
var functionTypes = library.functions.values;
75+
expect(functionTypes.every((e) => e is Map), isTrue);
76+
77+
var functions = [];
78+
functionTypes.forEach((e) => functions.addAll(e.values));
7179
expect(functions.every((e) => e is Method), isTrue);
7280

7381
var functionParameters = [];

0 commit comments

Comments
 (0)