Skip to content

Commit

Permalink
write out static methods on extensions (#2591)
Browse files Browse the repository at this point in the history
* write out static methods

* fix index json test on windows
  • Loading branch information
jcollins-g committed Mar 29, 2021
1 parent 8b911bc commit fcd50e7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 9 deletions.
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

0 comments on commit fcd50e7

Please sign in to comment.