Skip to content

Commit fcd50e7

Browse files
authored
write out static methods on extensions (#2591)
* write out static methods * fix index json test on windows
1 parent 8b911bc commit fcd50e7

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

lib/dartdoc.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,8 @@ class Dartdoc {
370370
found.add(indexPath);
371371
for (Map<String, dynamic> entry in jsonData) {
372372
if (entry.containsKey('href')) {
373-
var entryPath = path.joinAll([origin, entry['href']]);
373+
var entryPath =
374+
path.joinAll([origin, ...path.posix.split(entry['href'])]);
374375
if (!visited.contains(entryPath)) {
375376
_warn(packageGraph, PackageWarning.brokenLink, entryPath,
376377
path.normalize(origin),

lib/src/generator/generator_frontend.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,14 @@ class GeneratorFrontEnd implements Generator {
153153
_generatorBackend.generateProperty(
154154
writer, packageGraph, lib, extension, staticField);
155155
}
156+
157+
for (var method in filterNonDocumented(extension.staticMethods)) {
158+
if (!method.isCanonical) continue;
159+
160+
indexAccumulator.add(method);
161+
_generatorBackend.generateMethod(
162+
writer, packageGraph, lib, extension, method);
163+
}
156164
}
157165

158166
for (var mixin in filterNonDocumented(lib.mixins)) {

test/end2end/model_test.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,12 +1332,6 @@ void main() {
13321332
contains('<code>ThisIsNotHereNoWay&lt;MyType&gt;</code>'));
13331333
});
13341334

1335-
test('leaves relative href resulting in a broken link', () {
1336-
// Dartdoc does emit a brokenLink warning for this.
1337-
expect(docsAsHtml,
1338-
contains('<a href="SubForDocComments/localMethod.html">link</a>'));
1339-
});
1340-
13411335
test('leaves relative href resulting in a working link', () {
13421336
// Ideally doc comments should not make assumptions about Dartdoc output
13431337
// files, but unfortunately some do...

testing/test_package/dartdoc_options.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ dartdoc:
2020
linux: ['/bin/sh', '-c', 'echo']
2121
windows: ['C:\\Windows\\System32\\cmd.exe', '/c', 'echo']
2222
description: 'Works on everything'
23+
errors:
24+
- broken-link
2325
linkToSource:
2426
root: '.'
2527
uriTemplate: 'https://github.com/dart-lang/dartdoc/blob/master/testing/test_package/%f%#L%l%'

testing/test_package/lib/fake.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -950,8 +950,6 @@ class BaseForDocComments {
950950
///
951951
/// Reference to an inherited member in another library via class name: [ExtendedBaseReexported.action]
952952
///
953-
/// Link to a nonexistent file (erroneously expects base href): [link](SubForDocComments/localMethod.html)
954-
///
955953
/// Link to an existing file: [link](../SubForDocComments/localMethod.html)
956954
String doAwesomeStuff(int value) => null;
957955

0 commit comments

Comments
 (0)