Skip to content

Commit b62cbc7

Browse files
author
Alexandre Stanislawski
committed
fix(documentationjs): fixed default value parameter
1 parent e838033 commit b62cbc7

File tree

10 files changed

+50
-38
lines changed

10 files changed

+50
-38
lines changed

docgen/layouts/mixins/documentationjs/widget-usage.pug

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
mixin widgetUsage(fnSymbol)
2-
- const paramsTypeName = fnSymbol.params[0].type.name;
3-
if paramsTypeName && paramsTypeName !== 'Object'
4-
- const paramsType = fnSymbol.relatedTypes && fnSymbol.relatedTypes.find(t => t.name === paramsTypeName);
2+
- const paramTag = fnSymbol.tags.find(tag => tag.title === 'param' && tag.name === '$0');
3+
if paramTag && paramTag.type
4+
- const paramTypeName = paramTag.type.name;
5+
- const paramsType = fnSymbol.relatedTypes && fnSymbol.relatedTypes.find(t => t.name === paramTypeName);
6+
- if(!paramsType) console.log(fnSymbol.relatedTypes.map(t => t.name));
57
- const properties = '\n' + paramsType.properties.map(p => ` ${p.name}: ${p.type.name}`).join(',\n');
68
pre.CodeMirror.cm-s-mdn-like
79
code

docgen/plugins/documentationjs-data.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,14 @@ function mapWidgets(widgets, symbols, files) {
8383
// console.log(symbol.name);
8484
const fileName = `widgets/${symbol.name}.html`;
8585

86+
const relatedTypes = findRelatedTypes(symbol, symbols);
87+
8688
const symbolWithRelatedType = {
8789
...symbol,
88-
relatedTypes: findRelatedTypes(symbol, symbols),
90+
relatedTypes,
8991
};
9092

93+
9194
files[fileName] = {
9295
mode: '0764',
9396
contents: '',

src/widgets/price-ranges/price-ranges.js

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -67,34 +67,41 @@ priceRanges({
6767
})`;
6868

6969
/**
70-
* Instantiate a price ranges on a numerical facet
70+
* @typedef {Object} PriceRangeClasses
71+
* @property {string|string[]} [root] CSS class to add to the root element
72+
* @property {string|string[]} [header] CSS class to add to the header element
73+
* @property {string|string[]} [body] CSS class to add to the body element
74+
* @property {string|string[]} [list] CSS class to add to the wrapping list element
75+
* @property {string|string[]} [item] CSS class to add to each item element
76+
* @property {string|string[]} [active] CSS class to add to the active item element
77+
* @property {string|string[]} [link] CSS class to add to each link element
78+
* @property {string|string[]} [form] CSS class to add to the form element
79+
* @property {string|string[]} [label] CSS class to add to each wrapping label of the form
80+
* @property {string|string[]} [input] CSS class to add to each input of the form
81+
* @property {string|string[]} [currency] CSS class to add to each currency element of the form
82+
* @property {string|string[]} [separator] CSS class to add to the separator of the form
83+
* @property {string|string[]} [button] CSS class to add to the submit button of the form
84+
* @property {string|string[]} [footer] CSS class to add to the footer element
85+
*/
86+
87+
/**
88+
* @typedef {Object} PriceRangeWidgetOptions
89+
* @property {string|DOMElement} container Valid CSS Selector as a string or DOMElement
90+
* @property {string} attributeName Name of the attribute for faceting
91+
* @property {Object} [templates] Templates to use for the widget
92+
* @property {string|Function} [templates.item] Item template. Template data: `from`, `to` and `currency`
93+
* @property {string} [currency='$'] The currency to display
94+
* @property {Object} [labels] Labels to use for the widget
95+
* @property {string|Function} [labels.separator] Separator label, between min and max
96+
* @property {string|Function} [labels.button] Button label
97+
* @property {boolean} [autoHideContainer=true] Hide the container when no refinements available
98+
* @property {PriceRangeClasses} [cssClasses] CSS classes to add
99+
* @property {{collapsed: boolean}|boolean} [collapsible=false] Hide the widget body and footer when clicking on header
100+
*/
101+
102+
/**
71103
* @type {WidgetFactory}
72-
* @param {string|DOMElement} $0.container Valid CSS Selector as a string or DOMElement
73-
* @param {string} $0.attributeName Name of the attribute for faceting
74-
* @param {Object} [$0.templates] Templates to use for the widget
75-
* @param {string|Function} [$0.templates.item] Item template. Template data: `from`, `to` and `currency`
76-
* @param {string} [$0.currency='$'] The currency to display
77-
* @param {Object} [$0.labels] Labels to use for the widget
78-
* @param {string|Function} [$0.labels.separator] Separator label, between min and max
79-
* @param {string|Function} [$0.labels.button] Button label
80-
* @param {boolean} [$0.autoHideContainer=true] Hide the container when no refinements available
81-
* @param {Object} [$0.cssClasses] CSS classes to add
82-
* @param {string|string[]} [$0.cssClasses.root] CSS class to add to the root element
83-
* @param {string|string[]} [$0.cssClasses.header] CSS class to add to the header element
84-
* @param {string|string[]} [$0.cssClasses.body] CSS class to add to the body element
85-
* @param {string|string[]} [$0.cssClasses.list] CSS class to add to the wrapping list element
86-
* @param {string|string[]} [$0.cssClasses.item] CSS class to add to each item element
87-
* @param {string|string[]} [$0.cssClasses.active] CSS class to add to the active item element
88-
* @param {string|string[]} [$0.cssClasses.link] CSS class to add to each link element
89-
* @param {string|string[]} [$0.cssClasses.form] CSS class to add to the form element
90-
* @param {string|string[]} [$0.cssClasses.label] CSS class to add to each wrapping label of the form
91-
* @param {string|string[]} [$0.cssClasses.input] CSS class to add to each input of the form
92-
* @param {string|string[]} [$0.cssClasses.currency] CSS class to add to each currency element of the form
93-
* @param {string|string[]} [$0.cssClasses.separator] CSS class to add to the separator of the form
94-
* @param {string|string[]} [$0.cssClasses.button] CSS class to add to the submit button of the form
95-
* @param {string|string[]} [$0.cssClasses.footer] CSS class to add to the footer element
96-
* @param {object|boolean} [$0.collapsible=false] Hide the widget body and footer when clicking on header
97-
* @param {boolean} [$0.collapsible.collapsed] Initial collapsed state of a collapsible widget
104+
* @param {PriceRangeWidgetOptions} $0 The price ranges widget options.
98105
* @return {Object} widget
99106
*/
100107
export default function priceRanges({

src/widgets/range-slider/range-slider.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ export default function rangeSlider({
149149
min,
150150
max,
151151
precision = 2,
152-
}) {
152+
} = {}) {
153153
if (!container) {
154154
throw new Error(usage);
155155
}

src/widgets/refinement-list/refinement-list.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ export default function refinementList({
189189
autoHideContainer = true,
190190
showMore = false,
191191
searchForFacetValues = false,
192-
}) {
192+
} = {}) {
193193
if (!container) {
194194
throw new Error(usage);
195195
}

src/widgets/search-box/search-box.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export default function searchBox({
167167
autofocus = 'auto',
168168
searchOnEnterKeyPressOnly = false,
169169
queryHook,
170-
}) {
170+
} = {}) {
171171
if (!container) {
172172
throw new Error(usage);
173173
}

src/widgets/sort-by-selector/sort-by-selector.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export default function sortBySelector({
7676
indices,
7777
cssClasses: userCssClasses = {},
7878
autoHideContainer = false,
79-
}) {
79+
} = {}) {
8080
if (!container) {
8181
throw new Error(usage);
8282
}

src/widgets/star-rating/star-rating.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export default function starRating({
141141
collapsible = false,
142142
transformData,
143143
autoHideContainer = true,
144-
}) {
144+
} = {}) {
145145
if (!container) {
146146
throw new Error(usage);
147147
}

src/widgets/stats/stats.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export default function stats({
130130
collapsible = false,
131131
transformData,
132132
templates = defaultTemplates,
133-
}) {
133+
} = {}) {
134134
if (!container) {
135135
throw new Error(usage);
136136
}

src/widgets/toggle/toggle.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ export default function toggle({
148148
autoHideContainer = true,
149149
collapsible = false,
150150
values: userValues = {on: true, off: undefined},
151-
}) {
151+
} = {}) {
152152
if (!container) {
153153
throw new Error(usage);
154154
}

0 commit comments

Comments
 (0)