Skip to content

Commit

Permalink
doc(connectors): ensure usage message is the same format
Browse files Browse the repository at this point in the history
  • Loading branch information
iam4x committed Mar 27, 2017
1 parent 01219f1 commit ebff87b
Show file tree
Hide file tree
Showing 18 changed files with 95 additions and 48 deletions.
13 changes: 7 additions & 6 deletions src/connectors/clear-all/connectClearAll.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ var customClearAll = connectClearAll(function render(params, isFirstRendering) {
// hasRefinements,
// createURL,
// instantSearchInstance,
// widgetParams,
// }
});
search.addWidget(
customClearAll({
[excludeAttributes = []]
});
[ excludeAttributes = [] ]
})
);
Full documentation available at https://community.algolia.com/instantsearch.js/connectors/connectClearAll.html
`;
Expand All @@ -35,10 +36,10 @@ const clearAll = ({helper, clearAttributes, hasRefinements}) => () => {

/**
* @typedef {Object} ClearAllRenderingOptions
* @property {function} clearAll
* @property {boolean} hasRefinements
* @property {function} createURL
* @property {InstantSearch} instantSearchInstance
* @property {function} clearAll function to trigger the clear of all the currently refined values
* @property {boolean} hasRefinements boolean to indicate if search state is refined
* @property {function} createURL function that create a url for the next state
* @property {InstantSearch} instantSearchInstance the instance of instantsearch on which the widget is attached
* @property {Object} widgetParams all original options forwarded to rendering
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,37 @@ import reduce from 'lodash/reduce';
import filter from 'lodash/filter';

const usage = `Usage:
connectCurrentRefinedValues({
[ attributes: [{name[, label, template, transformData]}] ],
[ onlyListedAttributes = false ],
[ clearAll = 'before' ] // One of ['before', 'after', false]
})`;
var customCurrentRefinedValues = connectCurrentRefinedValues(function renderFn(params, isFirstRendering) {
// params = {
// attributes,
// clearAllClick,
// clearAllPosition,
// clearAllURL,
// clearRefinementClicks,
// clearRefinementURLs,
// refinements,
// instantSearchInstance,
// widgetParams,
// }
});
search.addWidget(
customCurrentRefinedValues({
[ attributes = [] ],
[ onlyListedAttributes = false ],
})
);
Full documentation available at https://community.algolia.com/instantsearch.js/connectors/connectCurrentRefinedValues.html
`;

/**
* @typedef {Object} CurrentRefinedValuesRenderingOptions
* @property {Object.<string, object>} attributes attributes mapped by keys
* @property {function} clearAllClick function to trigger the clear of all the currently refined values
* @property {string} clearAllPosition position of the 'clear all' button
* @property {function} clearAllURL url which leads to a state where all the refinements have been cleared
* @property {function[]} clearRefinementClicks,individual clearing function per refinement
* @property {string[]} clearRefinementURLs,individual url where a single refinement is cleared
* @property {Refinements[]} refinements,all the current refinements
* @property {function[]} clearRefinementClicks individual clearing function per refinement
* @property {string[]} clearRefinementURLs individual url where a single refinement is cleared
* @property {Refinements[]} refinements all the current refinements
* @property {InstantsSearch} instantSearchInstance the instance of instantsearch.js
* @property {Object} widgetParams all original options forwarded to rendering
*/
Expand All @@ -40,15 +56,14 @@ connectCurrentRefinedValues({
* @typedef {Object} CurrentRefinedValuesAttributes
* @property {string} name mandatory field which is the name of the attribute
* @property {string} label the label to apply on a refinement per attribute
* @property {(string|function)} template the template to apply
* @property {string|function} template the template to apply
* @property {function} transformData function to transform the content of the refinement before rendering the template
*/

/**
* @typedef {Object} CurrentRefinedValuesWidgetOptions
* @property {CurrentRefinedValuesAttributes[]} attributes specification for the display of refinements per attribute
* @property {boolean} onlyListedAttributes limit the displayed refinement to the list specified
* @property {boolean|string} clearAll position of the clear all button
*/

/**
Expand Down
5 changes: 3 additions & 2 deletions src/connectors/hierarchical-menu/connectHierarchicalMenu.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import {checkRendering} from '../../lib/utils.js';

const usage = `Usage:
var customToggle = connectHierarchicalMenu(function render(params, isFirstRendering) {
var customToggle = connectHierarchicalMenu(function renderFn(params, isFirstRendering) {
// params = {
// createURL,
// items,
// refine,
// instantSearchInstance,
// widgetParams,
// }
});
search.addWidget(
Expand All @@ -17,7 +18,7 @@ search.addWidget(
[ showParentLevel = true ],
[ limit = 10 ],
[ sortBy = ['isRefined', 'count:desc'] ],
});
})
);
Full documentation available at https://community.algolia.com/instantsearch.js/connectors/connectHierarchicalMenu.html
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ var customHitsPerPage = connectHitsPerPageSelector(function render(params, isFir
// }
});
search.addWidget(
options: [
{value: 10, label: '10 results per page'},
{value: 42, label: '42 results per page'},
],
customHitsPerPage({
options: [
{value: 10, label: '10 results per page'},
{value: 42, label: '42 results per page'},
],
})
);
Full documentation available at https://community.algolia.com/instantsearch.js/connectors/connectHitsPerPageSelector.html
`;
Expand Down
3 changes: 2 additions & 1 deletion src/connectors/hits/connectHits.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ var customHits = connectHits(function render(params, isFirstRendering) {
// hits,
// results,
// instantSearchInstance,
// widgetParams,
// }
});
search.addWidget(
customHits({
[ hitsPerPage = 20 ]
});
})
);
Full documentation available at https://community.algolia.com/instantsearch.js/connectors/connectHits.html
`;
Expand Down
7 changes: 4 additions & 3 deletions src/connectors/infinite-hits/connectInfiniteHits.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ var customInfiniteHits = connectInfiniteHits(function render(params, isFirstRend
// showMore,
// isLastPage,
// instantSearchInstance,
// widgetParams,
// }
});
search.addWidget(
customInfiniteHits({
[hitsPerPage = 20]
});
[ hitsPerPage = 20 ]
})
);
Full documentation available at https://community.algolia.com/instantsearch.js/connectors/connectInfiniteHits.html
`;

/**
* @typedef {Object} CustomInfiniteHitsWidgetOptions
* @param {number} hitsPerPage The number of hits to display per page
* @param {number} [hitsPerPage = 20] The number of hits to display per page
*/

/**
Expand Down
3 changes: 2 additions & 1 deletion src/connectors/menu/connectMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@ var customMenu = connectMenu(function render(params, isFirstRendering) {
// helper,
// instantSearchInstance,
// canRefine,
// widgetParams,
// }
});
search.addWidget(
customMenu({
attributeName,
[ limit ],
[ sortBy = ['isRefined', 'count:desc'] ]
});
})
);
Full documentation available at https://community.algolia.com/instantsearch.js/connectors/connectMenu.html
`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,25 @@ import includes from 'lodash/includes';
import {checkRendering} from '../../lib/utils.js';

const usage = `Usage:
connectNumericRefinementList(renderer)({
attributeName,
options
})`;
var customNumericRefinementList = connectNumericRefinementList(function renderFn(params, isFirstRendering) {
// params = {
// createURL,
// facetValues,
// hasNoResults,
// toggleRefinement,
// instantSearchInstance,
// widgetParams,
// }
});
search.addWidget(
customNumericRefinementList({
attributeName,
options,
})
);
Full documentation available at https://community.algolia.com/instantsearch.js/connectors/connectNumericRefinementList.html
`;

/**
* @typedef {Object} NumericRefinementListWidgetOptions
* @property {string} attributeName Name of the attribute for filtering
Expand Down
3 changes: 2 additions & 1 deletion src/connectors/numeric-selector/connectNumericSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@ var customNumericSelector = connectNumericSelector(function renderFn(params, isF
// setValue,
// hasNoResults,
// instantSearchInstance,
// widgetParams,
// }
});
search.addWidget(
customNumericSelector({
attributeName,
options,
[ operator = '=' ]
});
})
);
Full documentation available at https://community.algolia.com/instantsearch.js/connectors/connectNumericSelector.html
`;
Expand Down
5 changes: 3 additions & 2 deletions src/connectors/pagination/connectPagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ var customPagination = connectPagination(function render(params, isFirstRenderin
// nbHits,
// nbPages,
// setPage,
// widgetParams,
// }
});
search.addWidget(
customPagination({
[maxPages]
[ maxPages ]
})
);
Full documentation available at https://community.algolia.com/instantsearch.js/connectors/connectPagination.html
`;

/**
* @typedef CustomPaginationWidgetOptions
* @param {number} maxPages The max number of pages to browse
* @param {number} [maxPages] The max number of pages to browse
*/

/**
Expand Down
3 changes: 2 additions & 1 deletion src/connectors/price-ranges/connectPriceRanges.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ var customPriceRanges = connectToggle(function render(params, isFirstRendering)
// items,
// refine,
// instantSearchInstance,
// widgetParams,
// }
});
search.addWidget(
customPriceRanges({
attributeName,
});
})
);
Full documentation available at https://community.algolia.com/instantsearch.js/connectors/connectPriceRanges.html
`;
Expand Down
11 changes: 6 additions & 5 deletions src/connectors/range-slider/connectRangeSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ var customRangeSlider = connectRangeSlider(function render(params, isFirstRender
// start,
// format,
// instantSearchInstance,
// widgetParams,
// }
});
search.addWidget(
customRangeSlider({
attributeName,
min,
max,
precision
});
[ min ],
[ max ],
[ precision = 2 ],
})
);
Full documentation available at https://community.algolia.com/instantsearch.js/connectors/connectRangeSlider.html
`;
Expand All @@ -26,7 +27,7 @@ Full documentation available at https://community.algolia.com/instantsearch.js/c
* @param {string} attributeName Name of the attribute for faceting.
* @param {number} [min] Minimal slider value, default to automatically computed from the result set
* @param {number} [max] Maximal slider value, defaults to automatically computed from the result set
* @param {number} [precision = 2]
* @param {number} [precision = 2] Number of digits after decimal point to display.
*/

/**
Expand Down
5 changes: 3 additions & 2 deletions src/connectors/refinement-list/connectRefinementList.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@ var customRefinementList = connectRefinementList(function render(params) {
// searchForItems,
// instantSearchInstance,
// canRefine,
// widgetParams,
// }
});
search.addWidget(
customRefinementList({
attributeName,
[ operator = 'or' ],
[ limit ],
[ sortBy = ['isRefined', 'count:desc'] ]
});
[ sortBy = ['isRefined', 'count:desc'] ],
})
);
Full documentation available at https://community.algolia.com/instantsearch.js/connectors/connectRefinementList.html
`;
Expand Down
7 changes: 4 additions & 3 deletions src/connectors/search-box/connectSearchBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ var customSearchBox = connectMenu(function render(params, isFirstRendering) {
// query,
// onHistoryChange,
// search,
// instantSearchInstance
// instantSearchInstance,
// widgetParams,
// }
});
search.addWidget(
customSearchBox({
[ onQueryHook ]
});
[ onQueryHook ],
})
);
Full documentation available at https://community.algolia.com/instantsearch.js/connectors/connectSearchBox.html
`;
Expand Down
3 changes: 2 additions & 1 deletion src/connectors/sort-by-selector/connectSortBySelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ var customSortBySelector = connectSortBySelector(function render(params, isFirst
// options,
// refine,
// hasNoResults,
// instantSearchInstance
// instantSearchInstance,
// widgetParams,
// }
});
search.addWidget(
Expand Down
3 changes: 2 additions & 1 deletion src/connectors/star-rating/connectStarRating.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ var customStarRating = connectStarRating(function render(params, isFirstRenderin
// refine,
// instantSearchInstance,
// hasNoResults,
// widgetParams,
// }
});
search.addWidget(
customStarRatingI({
attributeName,
[ max=5 ],
});
})
);
Full documentation available at https://community.algolia.com/instantsearch.js/connectors/connectStarRating.html
`;
Expand Down
1 change: 1 addition & 0 deletions src/connectors/stats/connectStats.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ var customStats = connectState(function render(params, isFirstRendering) {
// page,
// processingTimeMS,
// query,
// widgetParams,
// }
});
search.addWidget(customStats());
Expand Down
3 changes: 2 additions & 1 deletion src/connectors/toggle/connectToggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ var customToggle = connectToggle(function render(params, isFirstRendering) {
// createURL,
// refine,
// instantSearchInstance,
// widgetParams,
// }
});
search.addWidget(
customToggle({
attributeName,
label,
[ values = {on: true, off: undefined} ]
});
})
);
Full documentation available at https://community.algolia.com/instantsearch.js/connectors/connectToggle.html
`;
Expand Down

0 comments on commit ebff87b

Please sign in to comment.