-
Notifications
You must be signed in to change notification settings - Fork 58
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
UIP-2563 Improve some doc comments #97
UIP-2563 Improve some doc comments #97
Conversation
RavenNumber of Findings: 0 |
1a0d6bc
to
674ea62
Compare
Codecov Report
@@ Coverage Diff @@
## master #97 +/- ##
=======================================
Coverage 94.87% 94.87%
=======================================
Files 31 31
Lines 1537 1537
=======================================
Hits 1458 1458
Misses 79 79 |
@@ -14,7 +14,9 @@ | |||
|
|||
library over_react.prop_errors; | |||
|
|||
/// Error thrown dues to a prop being set incorrectly. | |||
import 'package:over_react/over_react.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this only imported for comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep
/// | ||
/// Extends [react.Component]. | ||
/// __Forwarding when your component renders a composite component:__ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Forwarding/Prop and CSS classname forwarding
/// | ||
/// Related: [UiStatefulComponent] | ||
/// get consumedProps => const [ | ||
/// const $Props(/* Some class containing props you wish to not forward */) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be confusing, since the props in the associated props class are automatically forwarded. I think we should only reference this with respect to advanced component examples
/// | ||
/// get consumedProps => const [ | ||
/// const $Props(/* Some class containing props you wish to not forward */) | ||
/// ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above note above about consumedProps
@@ -403,28 +474,30 @@ abstract class UiProps extends Object | |||
@override Map get _map => this.props; | |||
@override String toString() => '$runtimeType: ${prettyPrintMap(_map)}'; | |||
|
|||
/// Adds an arbitrary prop key-value pair if [shouldAdd] is true, otherwise, does nothing. | |||
/// Adds an arbitrary prop key-value pair to [props] if [shouldAdd] is true, otherwise, does nothing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should include to [props]
, since it's not relevant to the readers, and could cause confusion around whether the pair is added to the UiProps
instance itself.
I'd say leave it as-is, or change it to to this map
or to the backing map
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it might be even better to just change the implementation, to reinforce that the current object is a Map
.
void addProp(propKey, value, [bool shouldAdd = true]) {
if (!shouldAdd) return;
this[propKey] = value;
}
void addProp(propKey, value, [bool shouldAdd = true]) { | ||
if (!shouldAdd) return; | ||
|
||
props[propKey] = value; | ||
} | ||
|
||
/// Adds a Map of arbitrary props if [shouldAdd] is true and [propMap] is not null. | ||
/// Adds a Map of arbitrary props to [props] if [shouldAdd] is true and [propMap] is not null. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above comment about referencing props
.
lib/src/util/prop_key_util.dart
Outdated
@@ -20,7 +20,7 @@ import 'dart:collection'; | |||
/// | |||
/// Example usage: | |||
/// | |||
/// var valuePropKey = getPropKey((props) => props.value, TextInput); | |||
/// var valuePropKey = getPropKey((props) => props.value, Dom.input); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be good to show a custom component here, since that's the main use-case
lib/src/util/prop_key_util.dart
Outdated
@@ -35,7 +35,7 @@ dynamic _getKey(void accessKey(Map keySpy)) { | |||
return keySpy.key; | |||
} | |||
|
|||
/// Helper class that stores the key accessed while getting a value of a map. | |||
/// Helper class that stores the key accessed while getting the value of a map. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be a value within a map
lib/src/util/react_wrappers.dart
Outdated
/// merged into existing props. | ||
/// | ||
/// Handles both Dart and JS React components, returning the appropriate props structure for each type: | ||
/// | ||
/// * For Dart components, existing props are read from [InteropProps.internal], which are then merged with | ||
/// the new [newProps] and saved in a new [InteropProps] with the expected [ReactDartComponentInternal] structure. | ||
/// Children are likewise copied/overwritten as expected. | ||
/// [newChildren] are likewise copied/overwritten as expected. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be:
Children are likewise copied and potentially overwritten with [newChildren] as expected.
lib/src/util/react_wrappers.dart
Outdated
@@ -277,7 +274,8 @@ ReactElement cloneElement(ReactElement element, [Map props, Iterable children]) | |||
} | |||
} | |||
|
|||
/// Returns the native Dart component associated with a React JS component instance, or null if the component is not Dart-based. | |||
/// Returns the native Dart [ReactComponent.dartComponent] associated with a [ReactComponent] instance, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ReactComponent.dartComponent
refers to an API that's on a react-dart branch and not yet merged in.
lib/src/util/react_wrappers.dart
Outdated
@@ -277,7 +274,8 @@ ReactElement cloneElement(ReactElement element, [Map props, Iterable children]) | |||
} | |||
} | |||
|
|||
/// Returns the native Dart component associated with a React JS component instance, or null if the component is not Dart-based. | |||
/// Returns the native Dart [ReactComponent.dartComponent] associated with a [ReactComponent] instance, | |||
/// or `null` if the component is not Dart-based _(an [Element])_. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/an [Element]/an [Element] or a JS composite component
674ea62
to
b866700
Compare
@greglittlefield-wf feedback addressed. |
@aaronlademann-wf This pull request has merge conflicts, please resolve. |
b866700
to
2fa1651
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple small things, otherwise looks great.
@@ -200,7 +245,7 @@ abstract class UiComponent<TProps extends UiProps> extends react.Component imple | |||
|
|||
/// A typed props object corresponding to the current untyped props Map ([unwrappedProps]). | |||
/// | |||
/// Created using [typedPropsFactory] and cached for each Map instance. | |||
/// Created using [typedPropsFactory] and cached for each Map instance within [_typedPropsCache]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#nit within [_typedPropsCache]
is an implementation detail not relevant to consumers of this API (and is also evident by looking at the code).
@@ -307,7 +370,7 @@ abstract class UiStatefulComponent<TProps extends UiProps, TState extends UiStat | |||
|
|||
/// A typed state object corresponding to the current untyped state Map ([unwrappedState]). | |||
/// | |||
/// Created using [typedStateFactory] and cached for each Map instance. | |||
/// Created using [typedStateFactory] and cached for each Map instance within [_typedStateCache]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#nit within [_typedStateCache]
is an implementation detail not relevant to consumers of this API (and is also evident by looking at the code).
lib/src/util/class_names.dart
Outdated
/// populated from the return values of [toClassName] and [toClassNameBlacklist], respectively. | ||
/// | ||
/// This method, along with [addFromProps], is useful for merging sets of className/blacklist props. | ||
/// > This method, along with [addFromProps], are useful for merging sets of className/blacklist props. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe "is" is correct here, since "along with [addFromProps]" is a separate clause and does not affect the subject of the sentence.
Alternatively, "This method and [addFromProps] are useful" would also be correct.
lib/src/util/react_wrappers.dart
Outdated
@@ -120,7 +117,7 @@ final bool _canUseExpandoOnReactElement = (() { | |||
return true; | |||
})(); | |||
|
|||
/// A cache of props for a given [ReactElement]. | |||
/// A cache of [UiComponent.props] for a given [ReactElement]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a little misleading, since not all ReactElement
doesn't always have a associated UiComponent
(only when it's mounted).
+ That were discovered while doing the memory leak audit
2fa1651
to
2867a22
Compare
@greglittlefield-wf all feedback addressed. |
+1 |
/// UiFactory<FooProps> Foo; | ||
/// | ||
/// @Component(subtypeOf: FooComponent) | ||
/// class BarComponent extends UiComponent<BarProps> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be useful to show BarProps
extending FooProps
here as well
+1 |
QA +1, doc change only Merging into master |
Misc. documentation improvements I made while doing the memory leak audit.
FYA: @greglittlefield-wf @jacehensley-wf @clairesarsam-wf