dart-lang/dartdoc

`@template` on extension don't work

dickermoshe opened this issue · 6 comments

A template tag placed within an extension doesn't get picked up and can't be used elsewhere:
As you can see here, the baz macro doesn't work, because it was declared in the extension

class Foo {
  /// {@macro baz}
  ///
  /// {@macro pink}
  ///
  ///
  ///
  ///
  ///
  ///
  ///
  void bar() {}

  /// {@template pink}
  /// this works
  /// {@endtemplate}
  void pink() {}
}

extension on Foo {
  /// {@template baz}
  /// This does not work
  /// {@endtemplate}
  void baz() {}
}
image

Thanks for the narrow repo and bug report!

@srawlins When building a site, the template works
image

I guess this is an issue with the extension

This is actually an SDK issue. I didn't realise it was raised here too and worked on a fix https://dart-review.googlesource.com/c/sdk/+/386840 - hope I didn't duplicate any effort if you were looking at this @srawlins!

I've been sick so no wasted time on my side 😅 . Thanks Danny and @dickermoshe for following up!

np, hope you're feeling better (now/soon)!