Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Append the href of each library with a slash #3940

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading