Skip to content
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

Add documentation, e.g. around bloom usage. #818

Merged
merged 3 commits into from
Apr 10, 2020

Conversation

xStrom
Copy link
Member

@xStrom xStrom commented Apr 8, 2020

These are the simpler parts of #811 so that they can go on the merge train without waiting for more work there.

Copy link
Collaborator

@luleyleo luleyleo left a comment

Choose a reason for hiding this comment

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

I did some nitpicking and questioning 😅

druid/src/widget/widget.rs Outdated Show resolved Hide resolved
druid/src/widget/widget.rs Outdated Show resolved Hide resolved
druid/src/contexts.rs Outdated Show resolved Hide resolved
druid/src/contexts.rs Show resolved Hide resolved
@@ -446,7 +446,9 @@ impl<T: Data, W: Widget<T>> WidgetPod<T, W> {
Target::Window(_) => Event::Command(cmd.clone()),
Target::Widget(id) if *id == child_ctx.widget_id() => Event::Command(cmd.clone()),
Target::Widget(id) => {
recurse = child_ctx.base_state.children.contains(id);
// Recurse when the target widget could be our descendant.
// The bloom filter we're checking can return false positives.
Copy link
Collaborator

Choose a reason for hiding this comment

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

The bloom filter we're checking can return false positives.

I think the renaming to may_contain should make it clear enough, as this comment has to be applied to too many places to stay consistent (and those were definitly to many tos 😅 ).

Copy link
Member Author

Choose a reason for hiding this comment

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

Just the name may_contain will make it clear enough to someone who already knows the function or will go read its docs. Others who are just glancing at the code at the call site won't necessarily know.

I also don't think the three places this comment was added to is too many. Once we're up to 10 or something we can reconsider.

Copy link
Collaborator

@luleyleo luleyleo left a comment

Choose a reason for hiding this comment

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

Looks all good to me now, thanks!

@xStrom
Copy link
Member Author

xStrom commented Apr 8, 2020

On further thinking I moved the WidgetId docs into a more basic internal comment. It's useful info for druid internal development but can be viewed as an implementation detail and we shouldn't advertise this as something people can do, because then we'll have to support it.

@luleyleo
Copy link
Collaborator

luleyleo commented Apr 8, 2020

The force-pushing makes it a bit difficult to see what you've changed 😓
Did you remove your changes to the WidgetId docs? (except for the not-doc comment)
I think the chain explanation you had there was quite useful to understand the internal use.
Making it an internal comment is better than nothing even though I'm kinda sure I would miss it when looking for an explanation 😅 . Wish Rust had an 'implementation-doc` feature.

@xStrom
Copy link
Member Author

xStrom commented Apr 8, 2020

Yeah I removed the public doc changes for WidgetId and replaced it with an internal code comment that's quite brief.

@xStrom xStrom added the S-needs-review waits for review label Apr 9, 2020
Copy link
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

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

Commented with some clarifications; feel free to incorporate this however you think is appropriate.

druid/src/widget/widget.rs Outdated Show resolved Hide resolved
druid/src/widget/widget.rs Outdated Show resolved Hide resolved
///
/// This can return false positives, but never false negatives.
pub fn contains(&self, item: &T) -> bool {
/// Thus `true` means that the item may have been added - or not,
/// while `false` means that the item has definitely not been added.
Copy link
Member

Choose a reason for hiding this comment

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

I think these two lines are a strict restating of the preceding line; I think between the changed method name and the changed first line comment, this should be clear to our expected audience.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it's worth stating it twice with different wording. The mistakes that result from not understanding this are extremely subtle and hard to catch.

druid/src/contexts.rs Outdated Show resolved Hide resolved
@xStrom xStrom added S-waiting-on-author waits for changes from the submitter and removed S-needs-review waits for review labels Apr 9, 2020
@xStrom
Copy link
Member Author

xStrom commented Apr 10, 2020

I removed the note I originally had added to WidgetId about multiple use. Instead I may look into improving the implementation in the future, but for documentation I think it's good to promote strictly unique usage.

I also rewrote the documentation for focus related methods/variants. Some of that stuff was strictly expired and no longer reflected reality.

@xStrom xStrom added S-needs-review waits for review and removed S-waiting-on-author waits for changes from the submitter labels Apr 10, 2020
Copy link
Collaborator

@luleyleo luleyleo left a comment

Choose a reason for hiding this comment

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

Looks really nice!
I've been thinking about adding doc(hidden) to RouteFocusChanged and RouteWidgetAdded tho.
If I understand correctly, those are never really of interest to the user.
One disadvantage could be that they will still be completed by IDEs like Rust Analyzer, same applies however to the Debug... ones so this problem exists already.
Maybe hiding them and renaming to InternalRoutFocusChanged would be an option?

@cmyr
Copy link
Member

cmyr commented Apr 10, 2020

We could also do something like prefix them with _.

Copy link
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

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

Great, thanks!

@luleyleo
Copy link
Collaborator

I've created a new issue (#826) regarding the internal variants of LifeCycle so that this can get merged.

@cmyr cmyr removed the S-needs-review waits for review label Apr 10, 2020
@xStrom xStrom merged commit 34e4434 into linebender:master Apr 10, 2020
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.

None yet

3 participants