Skip to content

Commit ef5c4bf

Browse files
committed
Merge pull request #626 from keertip/names
change names for library and class files
2 parents d4c508c + baca7f7 commit ef5c4bf

File tree

4 files changed

+28
-26
lines changed

4 files changed

+28
-26
lines changed

lib/src/html_generator.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ class HtmlGeneratorInstance {
259259
'layoutTitle': _layoutTitle(lib.name, 'library', lib.isDeprecated)
260260
};
261261

262-
_build(path.join(lib.nameForFile, 'index.html'), _templates.libraryTemplate,
263-
data);
262+
_build(path.join(lib.dirName, '${lib.fileName}'),
263+
_templates.libraryTemplate, data);
264264
}
265265

266266
Class get objectType {

lib/src/model.dart

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,9 @@ class Library extends ModelElement {
507507

508508
String get path => _library.definingCompilationUnit.name;
509509

510-
String get nameForFile => name.replaceAll(':', '-');
510+
String get dirName => name.replaceAll(':', '-');
511+
512+
String get fileName => '$dirName-library.html';
511513

512514
bool get isInSdk => _library.isInSdk;
513515

@@ -649,7 +651,7 @@ class Library extends ModelElement {
649651
}
650652

651653
@override
652-
String get _href => '$nameForFile/index.html';
654+
String get _href => '$dirName/$fileName';
653655
}
654656

655657
class Class extends ModelElement {
@@ -728,7 +730,7 @@ class Class extends ModelElement {
728730

729731
String get kind => 'class';
730732

731-
String get fileName => "${name}_class.html";
733+
String get fileName => "${name}-class.html";
732734

733735
bool get isAbstract => _cls.isAbstract;
734736

@@ -1018,7 +1020,7 @@ class Class extends ModelElement {
10181020
name.hashCode, library.name.hashCode, library.package.name.hashCode);
10191021

10201022
@override
1021-
String get _href => '${library.nameForFile}/$fileName';
1023+
String get _href => '${library.dirName}/$fileName';
10221024
}
10231025

10241026
class Enum extends Class {
@@ -1061,7 +1063,7 @@ class ModelFunction extends ModelElement {
10611063
String get fileName => "$name.html";
10621064

10631065
@override
1064-
String get _href => '${library.nameForFile}/$fileName';
1066+
String get _href => '${library.dirName}/$fileName';
10651067
}
10661068

10671069
class Typedef extends ModelElement {
@@ -1081,7 +1083,7 @@ class Typedef extends ModelElement {
10811083
? modelType.createLinkedReturnTypeName()
10821084
: _typedef.returnType.name;
10831085

1084-
String get _href => '${library.nameForFile}/$fileName';
1086+
String get _href => '${library.dirName}/$fileName';
10851087
}
10861088

10871089
class Field extends ModelElement {
@@ -1146,9 +1148,9 @@ class Field extends ModelElement {
11461148

11471149
String get _href {
11481150
if (element.enclosingElement is ClassElement) {
1149-
return '${library.nameForFile}/${element.enclosingElement.name}/$name.html';
1151+
return '${library.dirName}/${element.enclosingElement.name}/$name.html';
11501152
} else if (element.enclosingElement is LibraryElement) {
1151-
return '${library.nameForFile}/$name.html';
1153+
return '${library.dirName}/$name.html';
11521154
} else {
11531155
throw new StateError(
11541156
'$name is not in a class or library, instead a ${element.enclosingElement}');
@@ -1194,7 +1196,7 @@ class Constructor extends ModelElement {
11941196

11951197
@override
11961198
String get _href =>
1197-
'${library.nameForFile}/${_constructor.enclosingElement.name}/$name.html';
1199+
'${library.dirName}/${_constructor.enclosingElement.name}/$name.html';
11981200

11991201
bool get isConst => _constructor.isConst;
12001202

@@ -1248,7 +1250,7 @@ class Method extends ModelElement {
12481250

12491251
@override
12501252
String get _href =>
1251-
'${library.nameForFile}/${_method.enclosingElement.name}/${fileName}';
1253+
'${library.dirName}/${_method.enclosingElement.name}/${fileName}';
12521254

12531255
bool get isInherited => _isInherited;
12541256
}
@@ -1315,7 +1317,7 @@ class Accessor extends ModelElement {
13151317

13161318
@override
13171319
String get _href =>
1318-
'${library.nameForFile}/${_accessor.enclosingElement.name}/${name}.html';
1320+
'${library.dirName}/${_accessor.enclosingElement.name}/${name}.html';
13191321
}
13201322

13211323
/// Top-level variables. But also picks up getters and setters?
@@ -1360,7 +1362,7 @@ class TopLevelVariable extends ModelElement {
13601362
bool get hasSetter => _variable.setter != null;
13611363

13621364
@override
1363-
String get _href => '${library.nameForFile}/${name}.html';
1365+
String get _href => '${library.dirName}/${name}.html';
13641366
}
13651367

13661368
class Parameter extends ModelElement {
@@ -1404,13 +1406,13 @@ class Parameter extends ModelElement {
14041406
var p = _parameter.enclosingElement;
14051407

14061408
if (p is FunctionElement) {
1407-
return '${library.nameForFile}/${p.name}.html';
1409+
return '${library.dirName}/${p.name}.html';
14081410
} else {
14091411
// TODO: why is this logic here?
14101412
var name = Operator.friendlyNames.containsKey(p.name)
14111413
? Operator.friendlyNames[p.name]
14121414
: p.name;
1413-
return '${library.nameForFile}/${p.enclosingElement.name}/' +
1415+
return '${library.dirName}/${p.enclosingElement.name}/' +
14141416
'${name}.html#${htmlId}';
14151417
}
14161418
}
@@ -1435,7 +1437,7 @@ class TypeParameter extends ModelElement {
14351437

14361438
@override
14371439
String get _href =>
1438-
'${library.nameForFile}/${_typeParameter.enclosingElement.name}/$name';
1440+
'${library.dirName}/${_typeParameter.enclosingElement.name}/$name';
14391441
}
14401442

14411443
class ElementType {

lib/templates/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ <h2>Libraries</h2>
99
<dl>
1010
{{#package.libraries}}
1111
<dt>
12-
<span class="name {{#isDeprecated}}deprecated{{/isDeprecated}}"><a href="{{nameForFile}}/index.html">{{ name }}</a></span>
12+
<span class="name {{#isDeprecated}}deprecated{{/isDeprecated}}"><a href="{{href}}">{{ name }}</a></span>
1313
</dt>
1414
<dd>
1515
{{#isNotDocumented}}<span class="undocumented">Library not documented.</span>{{/isNotDocumented}}

test/model_test.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ void main() {
9595

9696
test('sdk library names', () {
9797
expect(dartAsyncLib.name, 'dart:async');
98-
expect(dartAsyncLib.nameForFile, 'dart-async');
99-
expect(dartAsyncLib.href, 'dart-async/index.html');
98+
expect(dartAsyncLib.dirName, 'dart-async');
99+
expect(dartAsyncLib.href, 'dart-async/dart-async-library.html');
100100
});
101101

102102
test('documentation', () {
@@ -194,7 +194,7 @@ void main() {
194194

195195
test('single ref to class', () {
196196
expect(B.documentationAsHtml,
197-
'<p>Extends class <a href="ex/Apple_class.html">Apple</a>, use <a href="ex/Apple/Apple.html">new Apple</a> or <a href="ex/Apple/Apple.fromString.html">new Apple.fromString</a></p>');
197+
'<p>Extends class <a href="ex/Apple-class.html">Apple</a>, use <a href="ex/Apple/Apple.html">new Apple</a> or <a href="ex/Apple/Apple.fromString.html">new Apple.fromString</a></p>');
198198
});
199199

200200
test('doc ref to class in SDK does not render as link', () {
@@ -208,14 +208,14 @@ void main() {
208208
String resolved = extendedClass.documentationAsHtml;
209209
expect(resolved, isNotNull);
210210
expect(resolved,
211-
contains('<a href="two_exports/BaseClass_class.html">BaseClass</a>'));
211+
contains('<a href="two_exports/BaseClass-class.html">BaseClass</a>'));
212212
expect(resolved, contains('linking over to Apple.'));
213213
});
214214

215215
test('references to class and constructors', () {
216216
String comment = B.documentationAsHtml;
217217
expect(comment,
218-
contains('Extends class <a href="ex/Apple_class.html">Apple</a>'));
218+
contains('Extends class <a href="ex/Apple-class.html">Apple</a>'));
219219
expect(
220220
comment, contains('use <a href="ex/Apple/Apple.html">new Apple</a>'));
221221
expect(comment, contains(
@@ -229,7 +229,7 @@ void main() {
229229
if (!Platform.isWindows) {
230230
test('reference to class from another library', () {
231231
String comment = superAwesomeClass.documentationAsHtml;
232-
expect(comment, contains('<a href="ex/Apple_class.html">Apple</a>'));
232+
expect(comment, contains('<a href="ex/Apple-class.html">Apple</a>'));
233233
});
234234

235235
test('reference to method', () {
@@ -533,7 +533,7 @@ void main() {
533533

534534
test('MY_CAT is linked', () {
535535
expect(cat.constantValue,
536-
'const <a href="ex/ConstantCat_class.html">ConstantCat</a>(\'tabby\')');
536+
'const <a href="ex/ConstantCat-class.html">ConstantCat</a>(\'tabby\')');
537537
});
538538
});
539539

@@ -690,7 +690,7 @@ void main() {
690690

691691
test('has the right annotation', () {
692692
expect(forAnnotation.annotations.first, equals(
693-
'<a href="ex/ForAnnotation_class.html">ForAnnotation</a>(\'my value\')'));
693+
'<a href="ex/ForAnnotation-class.html">ForAnnotation</a>(\'my value\')'));
694694
});
695695

696696
test('methods has the right annotation', () {

0 commit comments

Comments
 (0)