Skip to content

write out static methods on extensions #2591

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

Merged
merged 2 commits into from
Mar 29, 2021
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
3 changes: 2 additions & 1 deletion lib/dartdoc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@ class Dartdoc {
found.add(indexPath);
for (Map<String, dynamic> entry in jsonData) {
if (entry.containsKey('href')) {
var entryPath = path.joinAll([origin, entry['href']]);
var entryPath =
path.joinAll([origin, ...path.posix.split(entry['href'])]);
if (!visited.contains(entryPath)) {
_warn(packageGraph, PackageWarning.brokenLink, entryPath,
path.normalize(origin),
Expand Down
8 changes: 8 additions & 0 deletions lib/src/generator/generator_frontend.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,14 @@ class GeneratorFrontEnd implements Generator {
_generatorBackend.generateProperty(
writer, packageGraph, lib, extension, staticField);
}

for (var method in filterNonDocumented(extension.staticMethods)) {
if (!method.isCanonical) continue;

indexAccumulator.add(method);
_generatorBackend.generateMethod(
writer, packageGraph, lib, extension, method);
}
}

for (var mixin in filterNonDocumented(lib.mixins)) {
Expand Down
6 changes: 0 additions & 6 deletions test/end2end/model_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1332,12 +1332,6 @@ void main() {
contains('<code>ThisIsNotHereNoWay&lt;MyType&gt;</code>'));
});

test('leaves relative href resulting in a broken link', () {
// Dartdoc does emit a brokenLink warning for this.
expect(docsAsHtml,
contains('<a href="SubForDocComments/localMethod.html">link</a>'));
});

test('leaves relative href resulting in a working link', () {
// Ideally doc comments should not make assumptions about Dartdoc output
// files, but unfortunately some do...
Expand Down
2 changes: 2 additions & 0 deletions testing/test_package/dartdoc_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ dartdoc:
linux: ['/bin/sh', '-c', 'echo']
windows: ['C:\\Windows\\System32\\cmd.exe', '/c', 'echo']
description: 'Works on everything'
errors:
- broken-link
linkToSource:
root: '.'
uriTemplate: 'https://github.com/dart-lang/dartdoc/blob/master/testing/test_package/%f%#L%l%'
2 changes: 0 additions & 2 deletions testing/test_package/lib/fake.dart
Original file line number Diff line number Diff line change
Expand Up @@ -950,8 +950,6 @@ class BaseForDocComments {
///
/// Reference to an inherited member in another library via class name: [ExtendedBaseReexported.action]
///
/// Link to a nonexistent file (erroneously expects base href): [link](SubForDocComments/localMethod.html)
///
/// Link to an existing file: [link](../SubForDocComments/localMethod.html)
String doAwesomeStuff(int value) => null;

Expand Down