Skip to content

Use newer function type syntax for parameters. - #4290

Open
munificent wants to merge 1 commit into
mainfrom
use-new-function-type-parameter-syntax
Open

munificent wants to merge 1 commit into
mainfrom
use-new-function-type-parameter-syntax

Conversation

@munificent

Copy link
Copy Markdown
Member

When Dartdoc generates documentation for a function with a parameter whose type is a function type (i.e. a callback), the generated docs use the old pre-Dart-2.0 function-typed parameter syntax. Dartdoc does this even if the function itself uses the newer syntax.

For over five years, we have had a recommended lint telling users not to use the old function-typed parameter syntax. Newer Dart users may not be familiar with it at all. Our generated docs should probably use the same syntax that we recommend that users write. :)

Also, I am working on a proposal to drop support for the old function-typed parameter syntax completely. If that happens, then we should definitely stop using the old non-existent syntax. (See dart-lang/language#4782).

This obviously affects the output of Dartdoc pretty significantly, so I'm not sure what landing this entails, but I figured I'd put together a PR and send it out to start that discussion. If now is not the right time to make a change like this, that's OK too, but I do think we should make this change at some point.

Fix #3671.

When Dartdoc generates documentation for a function with a parameter
whose type is a function type (i.e. a callback), the generated docs use
the old pre-Dart-2.0 function-typed parameter syntax. Dartdoc does this
even if the function itself uses the newer syntax.

For over five years, we have had a recommended lint telling users not to
use the old function-typed parameter syntax. Newer Dart users may not be
familiar with it at all. Our generated docs should probably use the same
syntax that we recommend that users write. :)

Also, I am working on a proposal to drop support for the old
function-typed parameter syntax completely. If that happens, then we
should definitely stop using the old non-existent syntax. (See
dart-lang/language#4782).

This obviously affects the output of Dartdoc pretty significantly, so
I'm not sure what landing this entails, but I figured I'd put together
a PR and send it out to start that discussion. If now is not the right
time to make a change like this, that's OK too, but I do think we should
make this change at some point.

Fix #3671.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the parameter renderer to use the newer function type syntax for parameters whose type is a function, replacing the older "function-typed parameter" syntax. The rendering logic in lib/src/render/parameter_renderer.dart has been simplified, and corresponding tests in test/end2end/model_test.dart and test/parameters_test.dart have been updated and expanded to verify the new output format. There are no review comments to evaluate, so I have no feedback to provide.

@srawlins srawlins left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change the formatting of parameters that are function types.

2 participants