Skip to content

Comment references to unnamed constructors do not match Dart code #1850

Closed
@jamesderlin

Description

@jamesderlin

A specific case for #1663: The Effective Dart guidelines claim:

The dot syntax can also be used to refer to named constructors. For the unnamed constructor, put parentheses after the class name:

/// To create a point, call [Point()] or use [Point.polar()] to ...

I just tested this with dartdoc 0.24.1 from the Dart 2.1 SDK, and the unnamed constructor reference doesn't seem to work; it links to the class instead.

https://github.com/dart-lang/dartdoc/wiki/dartdoc-comment-references instead says to use [MyClass.MyClass] to reference the unnamed constructor. That does work, but the generated documentation literally has MyClass.MyClass, which looks weird since that's not what anybody uses in code. Can we do one (or both) of:

  • Make [MyClass()] refer to the unnamed constructor as claimed by Effective Dart? (Or, less desirably, fix the false claim by Effective Dart.)
  • Make [MyClass.MyClass] show up as MyClass (or MyClass()) in the generated documentation?

?

The motivation for this was my attempt at removing lingering new usage in Flutter API documentation, which was used to disambiguate references to classes from references to constructors (flutter/flutter#24625).

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work ontype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions