Render constructor params

This commit is contained in:
ahocevar
2018-05-21 13:19:59 +02:00
committed by Tim Schaub
parent a7d180047a
commit 54c438997f
2 changed files with 24 additions and 2 deletions
+2 -1
View File
@@ -92,7 +92,8 @@ exports.publish = function(data, opts) {
const params = []; const params = [];
doc.params.forEach(function(param) { doc.params.forEach(function(param) {
const paramInfo = { const paramInfo = {
name: param.name name: param.name,
description: param.description
}; };
params.push(paramInfo); params.push(paramInfo);
paramInfo.types = getTypes(param.type.names); paramInfo.types = getTypes(param.type.names);
+22 -1
View File
@@ -82,12 +82,33 @@ class Docs extends Component {
); );
} }
renderParams(params) {
//TODO Render types in a more structured way (like in default template?)
//TODO Use markdown for description
return (
<ul>
{params.map(param => (
<li key={param.name}>
{param.name}: {param.types.join('|')}
<br />
{param.description}
</li>
))}
</ul>
);
}
renderConstructor(cls, mod) { renderConstructor(cls, mod) {
if (cls in mod.classes && cls in mod.classes[cls]) { if (cls in mod.classes && cls in mod.classes[cls]) {
const params = mod.classes[cls][cls].params;
return ( return (
<div> <div>
<p>{this.renderImport(cls, mod)}</p> <p>{this.renderImport(cls, mod)}</p>
<h4>new {getName(cls)}()</h4> <h4>
new {getName(cls)}({params.map(p => p.name).join(', ')})
</h4>
<h5>Parameters</h5>
{this.renderParams(params)}
</div> </div>
); );
} }