Add links to docs for addons and top level API (#6555)

This makes it easier to figure out where the docs live.

Googling for e.g. `react-addons-update` also works, but this should
make things easier for people that hyperclick directly to the source.
This commit is contained in:
Desmond Brand
2016-05-02 06:14:28 -07:00
committed by Jim
parent 256753b830
commit db175052c0
17 changed files with 76 additions and 7 deletions

View File

@@ -36,6 +36,8 @@ var shallowCompare = require('shallowCompare');
* complex data structures this mixin may have false-negatives for deeper
* differences. Only mixin to components which have simple props and state, or
* use `forceUpdate()` when you know deep data structures have changed.
*
* See https://facebook.github.io/react/docs/pure-render-mixin.html
*/
var ReactComponentWithPureRenderMixin = {
shouldComponentUpdate: function(nextProps, nextState) {

View File

@@ -31,8 +31,11 @@ var numericPropertyRegex = /^\d+$/;
var warnedAboutNumeric = false;
var ReactFragment = {
// Wrap a keyed object in an opaque proxy that warns you if you access any
// of its properties.
/**
* Wrap a keyed object in an opaque proxy that warns you if you access any
* of its properties.
* See https://facebook.github.io/react/docs/create-fragment.html
*/
create: function(object) {
if (typeof object !== 'object' || !object || Array.isArray(object)) {
warning(

View File

@@ -16,6 +16,7 @@ var ReactStateSetters = require('ReactStateSetters');
/**
* A simple mixin around ReactLink.forState().
* See https://facebook.github.io/react/docs/two-way-binding-helpers.html
*/
var LinkedStateMixin = {
/**

View File

@@ -37,6 +37,9 @@
var React = require('React');
/**
* Deprecated: An an easy way to express two-way binding with React.
* See https://facebook.github.io/react/docs/two-way-binding-helpers.html
*
* @param {*} value current value of the link
* @param {function} requestChange callback to request a change
*/

View File

@@ -16,6 +16,7 @@ var shallowEqual = require('shallowEqual');
/**
* Does a shallow comparison for props and state.
* See ReactComponentWithPureRenderMixin
* See also https://facebook.github.io/react/docs/shallow-compare.html
*/
function shallowCompare(instance, nextProps, nextState) {
return (

View File

@@ -41,6 +41,11 @@ function createTransitionTimeoutPropValidator(transitionType) {
};
}
/**
* An easy way to perform CSS transitions and animations when a React component
* enters or leaves the DOM.
* See https://facebook.github.io/react/docs/animation.html#high-level-api-reactcsstransitiongroup
*/
var ReactCSSTransitionGroup = React.createClass({
displayName: 'ReactCSSTransitionGroup',

View File

@@ -16,6 +16,11 @@ var ReactTransitionChildMapping = require('ReactTransitionChildMapping');
var emptyFunction = require('emptyFunction');
/**
* A basis for animatins. When children are declaratively added or removed,
* special lifecycle hooks are called.
* See https://facebook.github.io/react/docs/animation.html#low-level-api-reacttransitiongroup
*/
var ReactTransitionGroup = React.createClass({
displayName: 'ReactTransitionGroup',

View File

@@ -66,6 +66,10 @@ function invariantArrayCase(value, spec, command) {
);
}
/**
* Returns a updated shallow copy of an object without mutating the original.
* See https://facebook.github.io/react/docs/update.html for details.
*/
function update(value, spec) {
invariant(
typeof spec === 'object',

View File

@@ -55,6 +55,8 @@ function forEachSingleChild(bookKeeping, child, name) {
/**
* Iterates through children that are typically specified as `props.children`.
*
* See https://facebook.github.io/react/docs/top-level-api.html#react.children.foreach
*
* The provided forEachFunc(child, index) will be called for each
* leaf child.
*
@@ -146,7 +148,9 @@ function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
/**
* Maps children that are typically specified as `props.children`.
*
* The provided mapFunction(child, index) will be called for each
* See https://facebook.github.io/react/docs/top-level-api.html#react.children.map
*
* The provided mapFunction(child, key, index) will be called for each
* leaf child.
*
* @param {?*} children Children tree container.
@@ -173,6 +177,8 @@ function forEachSingleChildDummy(traverseContext, child, name) {
* Count the number of children that are typically specified as
* `props.children`.
*
* See https://facebook.github.io/react/docs/top-level-api.html#react.children.count
*
* @param {?*} children Children tree container.
* @return {number} The number of children.
*/
@@ -184,6 +190,8 @@ function countChildren(children, context) {
/**
* Flatten a children object (typically specified as `props.children`) and
* return an array with appropriately re-keyed children.
*
* See https://facebook.github.io/react/docs/top-level-api.html#react.children.toarray
*/
function toArray(children) {
var result = [];

View File

@@ -16,10 +16,13 @@ var invariant = require('invariant');
/**
* Returns the first child in a collection of children and verifies that there
* is only one child in the collection. The current implementation of this
* function assumes that a single child gets passed without a wrapper, but the
* purpose of this helper function is to abstract away the particular structure
* of children.
* is only one child in the collection.
*
* See https://facebook.github.io/react/docs/top-level-api.html#react.children.only
*
* The current implementation of this function assumes that a single child gets
* passed without a wrapper, but the purpose of this helper function is to
* abstract away the particular structure of children.
*
* @param {?object} children Child collection structure.
* @return {ReactElement} The first and only `ReactElement` contained in the

View File

@@ -740,6 +740,7 @@ var ReactClass = {
/**
* Creates a composite component class given a class specification.
* See https://facebook.github.io/react/docs/top-level-api.html#react.createclass
*
* @param {object} spec Class specification (which must define `render`).
* @return {function} Component constructor function.

View File

@@ -113,6 +113,10 @@ var ReactElement = function(type, key, ref, self, source, owner, props) {
return element;
};
/**
* Create and return a new ReactElement of the given type.
* See https://facebook.github.io/react/docs/top-level-api.html#react.createelement
*/
ReactElement.createElement = function(type, config, children) {
var propName;
@@ -230,6 +234,10 @@ ReactElement.createElement = function(type, config, children) {
);
};
/**
* Return a function that produces ReactElements of a given type.
* See https://facebook.github.io/react/docs/top-level-api.html#react.createfactory
*/
ReactElement.createFactory = function(type) {
var factory = ReactElement.createElement.bind(null, type);
// Expose the type on the factory and the prototype so that it can be
@@ -255,6 +263,10 @@ ReactElement.cloneAndReplaceKey = function(oldElement, newKey) {
return newElement;
};
/**
* Clone and return a new ReactElement using element as the starting point.
* See https://facebook.github.io/react/docs/top-level-api.html#react.cloneelement
*/
ReactElement.cloneElement = function(element, config, children) {
var propName;
@@ -335,6 +347,8 @@ ReactElement.cloneElement = function(element, config, children) {
};
/**
* Verifies the object is a ReactElement.
* See https://facebook.github.io/react/docs/top-level-api.html#react.isvalidelement
* @param {?object} object
* @return {boolean} True if `object` is a valid component.
* @final

View File

@@ -511,6 +511,7 @@ var ReactMount = {
/**
* Renders a React component into the DOM in the supplied `container`.
* See https://facebook.github.io/react/docs/top-level-api.html#reactdom.render
*
* If the React component was previously rendered into `container`, this will
* perform an update on it and only mutate the DOM as necessary to reflect the
@@ -527,6 +528,7 @@ var ReactMount = {
/**
* Unmounts and destroys the React component rendered in the `container`.
* See https://facebook.github.io/react/docs/top-level-api.html#reactdom.unmountcomponentatnode
*
* @param {DOMElement} container DOM element containing a React component.
* @return {boolean} True if a component was found in and unmounted from

View File

@@ -22,6 +22,8 @@ var warning = require('warning');
/**
* Returns the DOM node rendered by this element.
*
* See https://facebook.github.io/react/docs/top-level-api.html#reactdom.finddomnode
*
* @param {ReactComponent|DOMElement} componentOrElement
* @return {?DOMElement} The root node of this element.
*/

View File

@@ -63,6 +63,11 @@ function renderToStringImpl(element, makeStaticMarkup) {
}
}
/**
* Render a ReactElement to its initial HTML. This should only be used on the
* server.
* See https://facebook.github.io/react/docs/top-level-api.html#reactdomserver.rendertostring
*/
function renderToString(element) {
invariant(
ReactElement.isValidElement(element),
@@ -71,6 +76,11 @@ function renderToString(element) {
return renderToStringImpl(element, false);
}
/**
* Similar to renderToString, except this doesn't create extra DOM attributes
* such as data-react-id that React uses internally.
* See https://facebook.github.io/react/docs/top-level-api.html#reactdomserver.rendertostaticmarkup
*/
function renderToStaticMarkup(element) {
invariant(
ReactElement.isValidElement(element),

View File

@@ -14,6 +14,7 @@
/**
* ReactPerf is a general AOP system designed to measure performance. This
* module only has the hooks: see ReactDefaultPerf for the analysis tool.
* See also https://facebook.github.io/react/docs/perf.html
*/
var ReactPerf = {
/**

View File

@@ -71,6 +71,10 @@ function findAllInRenderedTreeInternal(inst, test) {
}
/**
* Utilities for making it easy to test React components.
*
* See https://facebook.github.io/react/docs/test-utils.html
*
* Todo: Support the entire DOM.scry query syntax. For now, these simple
* utilities will suffice for testing purposes.
* @lends ReactTestUtils