Render constructor params
This commit is contained in:
@@ -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
@@ -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>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user