UNPKG

builddocs

Version:

Build documentation files from commented source code

72 lines (70 loc) 3.21 kB
<<do $in = processType($in) let undocumentedProps = null if ($in.properties) for (let n in $in.properties) { let p = $in.properties[n] if (!hasDescription(p)) (undocumentedProps || (undocumentedProps = [])).push([n, p]) } >> <<if $in.type == "Function">> <span class=fn>fn</span><<fntype $in.signatures[0]>> <<elif $in.type == "Array">> <<typeParens $in.typeArgs[0]>>[] <<elif $in.type == "ReadonlyArray">> <span class=keyword>readonly</span> <<typeParens $in.typeArgs[0]>>[] <<elif $in.type == "tuple">> [<<for elt $in.typeArgs || []>><<if $i>>, <</if>><<type elt>><</for>>] <<elif $in.type == "union" || $in.type == "intersection">> <<do let op = $in.type == "union" ? "|" : "&", mustBreak = breakType($in.typeArgs)>> <<for elt $in.typeArgs>> <<if $i>> <<t op>> <</if>> <<if $i > 1 && mustBreak>></div><</if>> <<if $i && mustBreak>><div class=breaktype><</if>> <<type elt>> <</for>> <<if $in.typeArgs.length > 1 && mustBreak>></div><</if>> <<elif $in.type == "indexed">> <<for elt $in.typeArgs>><<if $i>>[<</if>><<type elt>><<if $i>>]<</if>><</for>> <<elif $in.type == "conditional">> <<type $in.typeArgs[0]>> <span class=keyword>extends</span> <<type $in.typeArgs[1]>> ? <<type $in.typeArgs[2]>> : <<type $in.typeArgs[3]>> <<elif $in.type == "mapped">> <<do let mustBreak = breakType([$in.key.implements[0], $in.typeArgs[0]])>> {<<if mustBreak>><div class=breaktype><</if>> [<a id="<<t prefix + $in.key.id>>" href="#<<t prefix + $in.key.id>>"> <<t $in.key.name>></a> in <<type $in.key.implements[0]>>]:  <<type $in.typeArgs[0]>> <<if mustBreak>></div><</if>>} <<elif $in.type == "keyof">> <span class=keyword>keyof</span> <<typeParens $in.typeArgs[0]>> <<elif $in.type == "typeof">> <span class=keyword>typeof</span> <<typeParens $in.typeArgs[0]>> <<elif undocumentedProps || $in.signatures>> <<do let mustBreak = breakType((undocumentedProps || []).map(p => p[1]).concat($in.signatures ? $in.signatures[0].params : []))>> {<<if $in.signatures>> <<if mustBreak>><div class=breaktype><</if>> <<if $in.signatures[0].type == "constructor">><span class=keyword>new</span> <</if>><<fntype $in.signatures[0]>> <<if undocumentedProps>>, <</if>> <<if mustBreak>></div><</if>> <</if>> <<for prop undocumentedProps || []>> <<if mustBreak>><div class=breaktype><</if>> <span class=prop><<t prop[0]>></span><<if prop[1].optional>>&#8288;?<</if>>: <<type prop[1]>> <<if $i < undocumentedProps.length - 1>>, <</if>> <<if mustBreak>></div><</if>> <</for>>} <<else>> <<do let found = linkType($in) let cls = /^"/.test($in.type) ? "string" : /^(number|string|boolean|symbol|null|undefined)$/.test($in.type) ? "prim" : "type" >> <<if found>><a href="<<t found>>"><</if>> <span class="<<t cls>>"><<t $in.type == "interface" ? "Object" : $in.type>></span> <<if found>></a><</if>> <<if $in.typeArgs>> <<do let mustBreak = breakType($in.typeArgs)>> &lt;<<for elt $in.typeArgs>> <<if mustBreak>><div class=breaktype><</if>> <<type elt>> <<if $i != $in.typeArgs.length - 1>>, <</if>> <<if mustBreak>></div><</if>> <</for>>&gt; <</if>> <</if>>