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

UIP-2563 Improve some doc comments #97

Merged
merged 1 commit into from Jul 28, 2017

Conversation

aaronlademann-wf
Copy link
Contributor

Misc. documentation improvements I made while doing the memory leak audit.


FYA: @greglittlefield-wf @jacehensley-wf @clairesarsam-wf

@aviary-wf
Copy link

aviary-wf commented Jul 17, 2017

Raven

Number of Findings: 0

@codecov-io
Copy link

codecov-io commented Jul 17, 2017

Codecov Report

Merging #97 into master will not change coverage.
The diff coverage is 100%.

@@           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';
Copy link
Contributor

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?

Copy link
Contributor Author

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:__
Copy link
Contributor

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 */)
Copy link
Contributor

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 */)
/// ];
Copy link
Contributor

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.
Copy link
Contributor

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.

Copy link
Contributor

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.
Copy link
Contributor

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.

@@ -20,7 +20,7 @@ import 'dart:collection';
///
/// Example usage:
///
/// var valuePropKey = getPropKey((props) => props.value, TextInput);
/// var valuePropKey = getPropKey((props) => props.value, Dom.input);
Copy link
Contributor

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

@@ -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.
Copy link
Contributor

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

/// 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.
Copy link
Contributor

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.

@@ -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,
Copy link
Contributor

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.

@@ -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])_.
Copy link
Contributor

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

@aaronlademann-wf
Copy link
Contributor Author

@greglittlefield-wf feedback addressed.

@rmconsole-wf
Copy link

@aaronlademann-wf This pull request has merge conflicts, please resolve.

Copy link
Contributor

@greglittlefield-wf greglittlefield-wf left a 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].
Copy link
Contributor

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].
Copy link
Contributor

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).

/// 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.
Copy link
Contributor

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.

@@ -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].
Copy link
Contributor

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
@aaronlademann-wf
Copy link
Contributor Author

@greglittlefield-wf all feedback addressed.

@greglittlefield-wf
Copy link
Contributor

+1

/// UiFactory<FooProps> Foo;
///
/// @Component(subtypeOf: FooComponent)
/// class BarComponent extends UiComponent<BarProps> {
Copy link
Contributor

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

@clairesarsam-wf
Copy link
Contributor

+1

@rmconsole2-wf rmconsole2-wf changed the title Improve some doc comments UIP-2563 Improve some doc comments Jul 28, 2017
@jayudey-wf
Copy link
Contributor

QA +1, doc change only

Merging into master

@jayudey-wf jayudey-wf merged commit 4a149e3 into Workiva:master Jul 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants