Skip to content
This repository was archived by the owner on Feb 17, 2024. It is now read-only.

Commit 5e5b921

Browse files
Travis UekiTravis Ueki
Travis Ueki
authored and
Travis Ueki
committed
✨ now displaying n/a for empty defaults and args closes #18
1 parent 86e691a commit 5e5b921

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/ui-guide-builder.ts

+27
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,32 @@ export function docsFor(
6161
description: string,
6262
api: ComponentAPI = {inputs: [], outputs: []}
6363
): DopeDoc {
64+
api = addNA(api);
6465
return new DocsBuilder(component, description, api)
6566
}
67+
68+
function addNA(docsObj) {
69+
let { inputs, outputs } = docsObj;
70+
let parsedInputs;
71+
let parsedOutputs;
72+
const defaultString = 'n/a';
73+
if (inputs) {
74+
parsedInputs = inputs.map((val) => {
75+
if (!val.default || val.default.length <= 1){
76+
val.default = defaultString;
77+
}
78+
return val;
79+
})
80+
}
81+
82+
if (outputs) {
83+
parsedOutputs = outputs.map((val) => {
84+
if (!val.args || val.args.length <= 1) {
85+
val.args = defaultString;
86+
}
87+
return val;
88+
})
89+
}
90+
91+
return docsObj = {inputs: parsedInputs, outputs: parsedOutputs};
92+
}

0 commit comments

Comments
 (0)