Skip to content

[go_router] Add documentation to some methods in matching.dart #3462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 20, 2023

Conversation

ValentinVignal
Copy link
Contributor

I was investigating how to fix flutter/flutter#113032 (I will soon public a design proposition as I think the entire RouteMatchList structure needs to be changed from a list to a tree). It is a bit hard to understand what each method was supposed to do so I added some documentation to help future contributors.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@ValentinVignal
Copy link
Contributor Author

I would think this is a version exempt ?

@@ -76,8 +83,11 @@ class RouteMatchList {

final List<RouteMatch> _matches;

/// the full path pattern that matches the uri.
/// /family/:fid/person/:pid
/// the full path pattern that matches the uri. For example:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// the full path pattern that matches the uri. For example:
/// The full path pattern that matches the uri.
///
/// For example:

Comment on lines 172 to 174
/// Returns the list of `RouteMatch` corresponding to the given [loc]. For
/// example, for a given [loc] `/a/b/c/d`, this function will return the list of
/// [RouteBase] `[GoRouteA(), GoRouterB(), GoRouteC(), GoRouterD()]`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Returns the list of `RouteMatch` corresponding to the given [loc]. For
/// example, for a given [loc] `/a/b/c/d`, this function will return the list of
/// [RouteBase] `[GoRouteA(), GoRouterB(), GoRouteC(), GoRouterD()]`.
/// Returns the list of `RouteMatch` corresponding to the given [loc].
///
/// For example, for a given [loc] `/a/b/c/d`, this function will return the list of
/// [RouteBase] `[GoRouteA(), GoRouterB(), GoRouteC(), GoRouterD()]`.

/// Generate the full path (ex: `'/family/:fid/person/:pid'`) of a list of
/// [RouteMatch].
///
/// This methods considers that [matches] is ordered accorresponding to how
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't quite parse this sentence

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hope docs: Better documentation makes it clearer

///
/// - [loc] is the complete URL to match (without the query parameters). For
/// example, for the URL `/a/b?c=0`, [loc] will be `/a/b`.
/// - [restBloc] is the remaining part of the URL to match while [parentBloc] is
Copy link
Contributor

Choose a reason for hiding this comment

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

restLoc and parenetLoc?

@ValentinVignal ValentinVignal requested a review from chunhtai March 16, 2023 01:26
@ValentinVignal
Copy link
Contributor Author

I would think this is a version exempt ?

Should the label "override: no versioning needed" be added to this PR ? Or should I create a new version?

@chunhtai chunhtai added the override: no versioning needed Override the check requiring version bumps for most changes label Mar 16, 2023
Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

LGTM, just some more nits

@@ -58,6 +60,34 @@ class RouteMatchList {
static RouteMatchList empty =
RouteMatchList(<RouteMatch>[], Uri.parse(''), const <String, String>{});

/// Generate the full path (ex: `'/family/:fid/person/:pid'`) of a list of
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// Generate the full path (ex: `'/family/:fid/person/:pid'`) of a list of
/// Generates the full path (ex: `'/family/:fid/person/:pid'`) of a list of

/// Generate the full path (ex: `'/family/:fid/person/:pid'`) of a list of
/// [RouteMatch].
///
/// This methods considers that [matches]'s elements verify the go route
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe:

The [matches] must be the in same order of how GoRoutes are matched.

For example, if the routes structure is ...

@@ -159,6 +194,18 @@ class MatcherError extends Error {
}
}

/// Returns the list of `RouteMatch` corresponding to the given [loc].
Copy link
Contributor

Choose a reason for hiding this comment

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

The input parameters should be in quote instead of square bracket.

Suggested change
/// Returns the list of `RouteMatch` corresponding to the given [loc].
/// Returns the list of `RouteMatch` corresponding to the given `loc`.

@@ -159,6 +194,18 @@ class MatcherError extends Error {
}
}

/// Returns the list of `RouteMatch` corresponding to the given [loc].
///
/// For example, for a given [loc] `/a/b/c/d`, this function will return the
Copy link
Contributor

@chunhtai chunhtai Mar 16, 2023

Choose a reason for hiding this comment

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

same here and below

@chunhtai chunhtai requested a review from johnpryan March 16, 2023 16:11
@chunhtai
Copy link
Contributor

cc @johnpryan for secondary review

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 20, 2023
@auto-submit auto-submit bot merged commit cfc5d62 into flutter:main Mar 20, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Mar 21, 2023
nploi pushed a commit to nploi/packages that referenced this pull request Jul 16, 2023
…er#3462)

[go_router] Add documentation to some methods in matching.dart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App override: no versioning needed Override the check requiring version bumps for most changes p: go_router
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ go_router ] Nested ShellRoute does not show when pushing new route
3 participants