Skip to content

Commit

Permalink
Append the href of each library with a slash (#3940)
Browse files Browse the repository at this point in the history
  • Loading branch information
srawlins authored Dec 4, 2024
1 parent 7444b39 commit e3ecb4d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lib/resources/docs.dart.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/src/model/library.dart
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ class Library extends ModelElement
// The file name for a library is 'index.html', so we just link to the
// directory name. This keeps the URL looking short, _without_ the
// 'index.html' in the URL.
return '${package.baseHref}$dirName';
return '${package.baseHref}$dirName/';
}

/// The previous value of [filePath].
Expand Down
14 changes: 11 additions & 3 deletions test/end2end/model_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1194,17 +1194,25 @@ void main() async {
expect(
aFunctionUsingRenamedLib.documentationAsHtml,
contains(
'Link to library: <a href="${htmlBasePlaceholder}mylibpub">renamedLib</a>'),
'Link to library: '
'<a href="${htmlBasePlaceholder}mylibpub/">renamedLib</a>',
),
);
expect(
aFunctionUsingRenamedLib.documentationAsHtml,
contains(
'Link to constructor (implied, no new): <a href="${htmlBasePlaceholder}mylibpub/YetAnotherHelper/YetAnotherHelper.html">renamedLib.YetAnotherHelper()</a>'),
'Link to constructor (implied, no new): '
'<a href="${htmlBasePlaceholder}mylibpub/YetAnotherHelper/YetAnotherHelper.html">'
'renamedLib.YetAnotherHelper()</a>',
),
);
expect(
aFunctionUsingRenamedLib.documentationAsHtml,
contains(
'Link to class: <a href="${htmlBasePlaceholder}mylibpub/YetAnotherHelper-class.html">renamedLib.YetAnotherHelper</a>'),
'Link to class: '
'<a href="${htmlBasePlaceholder}mylibpub/YetAnotherHelper-class.html">'
'renamedLib.YetAnotherHelper</a>',
),
);
expect(
aFunctionUsingRenamedLib.documentationAsHtml,
Expand Down
14 changes: 7 additions & 7 deletions test/libraries_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ A doc comment.
var dartAsyncLib = sdkPackage.libraries.named('dart:async');
expect(dartAsyncLib.name, 'dart:async');
expect(dartAsyncLib.dirName, 'dart-async');
expect(dartAsyncLib.href, '${htmlBasePlaceholder}dart-async');
expect(dartAsyncLib.href, '${htmlBasePlaceholder}dart-async/');
});
}

Expand All @@ -191,7 +191,7 @@ class LibrariesTest extends DartdocTestBase {

expect(library.name, 'libraries');
expect(library.qualifiedName, 'libraries');
expect(library.href, '${placeholder}libraries');
expect(library.href, '${placeholder}libraries/');
}

void test_library_containsClassWithSameNameAsDartSdk() async {
Expand All @@ -212,7 +212,7 @@ class LibrariesTest extends DartdocTestBase {

expect(library.name, 'lib1');
expect(library.qualifiedName, 'lib1');
expect(library.href, '${placeholder}lib1');
expect(library.href, '${placeholder}lib1/');
expect(library.redirectingPath, 'lib1/lib1-library.html');
}

Expand All @@ -230,7 +230,7 @@ export 'src/library.dart';
);
expect(library.qualifiedName, 'libraries');
expect(library.name, 'libraries');
expect(library.href, '${placeholder}public');
expect(library.href, '${placeholder}public/');
}
}

Expand Down Expand Up @@ -278,7 +278,7 @@ version: 0.0.1

expect(library.name, 'lib2');
expect(library.qualifiedName, 'lib2');
expect(library.href, '${placeholder}package-two_lib2');
expect(library.href, '${placeholder}package-two_lib2/');
expect(
library.redirectingPath,
'package-two_lib2/package-two_lib2-library.html',
Expand All @@ -292,7 +292,7 @@ version: 0.0.1

expect(library.name, 'lib2');
expect(library.qualifiedName, 'lib2');
expect(library.href, '${placeholder}package-two_lib2');
expect(library.href, '${placeholder}package-two_lib2/');
expect(
library.redirectingPath,
'package-two_lib2/package-two_lib2-library.html',
Expand All @@ -306,7 +306,7 @@ version: 0.0.1

expect(library.name, 'lib2');
expect(library.qualifiedName, 'lib2');
expect(library.href, '${placeholder}lib2');
expect(library.href, '${placeholder}lib2/');
expect(library.redirectingPath, 'lib2/lib2-library.html');
}
}
2 changes: 1 addition & 1 deletion test/prefixes_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ int x = 0;
var x = library.properties.named('x');
expect(
x.documentationAsHtml,
'<p>Text <a href="$dartAsyncUrlPrefix">async</a>.</p>',
'<p>Text <a href="$dartAsyncUrlPrefix/">async</a>.</p>',
);
}

Expand Down
2 changes: 1 addition & 1 deletion test/search_index_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class C {}
equals({
'name': 'index_json',
'kind': Kind.library.index,
'href': '%%__HTMLBASE_dartdoc_internal__%%index_json',
'href': '%%__HTMLBASE_dartdoc_internal__%%index_json/',
}),
);
}
Expand Down

0 comments on commit e3ecb4d

Please sign in to comment.