Render non-member constants
This commit is contained in:
+20
-8
@@ -24,12 +24,8 @@ function getModuleName(longname) {
|
|||||||
return longname.slice(7);
|
return longname.slice(7);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getClassName(longname) {
|
function getName(longname) {
|
||||||
return longname.split('~').pop();
|
return longname.split(/[~\.]/).pop();
|
||||||
}
|
|
||||||
|
|
||||||
function getFunctionName(longname) {
|
|
||||||
return longname.split('.').pop();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function isMember(symbol) {
|
function isMember(symbol) {
|
||||||
@@ -55,6 +51,10 @@ class Docs extends Component {
|
|||||||
{mod.symbols
|
{mod.symbols
|
||||||
.filter(sym => sym.kind === 'function' && !isMember(sym))
|
.filter(sym => sym.kind === 'function' && !isMember(sym))
|
||||||
.map(fn => this.renderFunction(fn, mod))}
|
.map(fn => this.renderFunction(fn, mod))}
|
||||||
|
<h2>Constants</h2>
|
||||||
|
{mod.symbols
|
||||||
|
.filter(sym => sym.kind === 'constant' && !isMember(sym))
|
||||||
|
.map(constant => this.renderConstant(constant, mod))}
|
||||||
</a>
|
</a>
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
@@ -64,7 +64,7 @@ class Docs extends Component {
|
|||||||
return (
|
return (
|
||||||
<p key={cls.name}>
|
<p key={cls.name}>
|
||||||
<code>
|
<code>
|
||||||
import {getClassName(cls.name)} from '{getModuleName(mod.name)}';
|
import {getName(cls.name)} from '{getModuleName(mod.name)}';
|
||||||
</code>
|
</code>
|
||||||
</p>
|
</p>
|
||||||
);
|
);
|
||||||
@@ -74,7 +74,19 @@ class Docs extends Component {
|
|||||||
return (
|
return (
|
||||||
<p key={fn.name}>
|
<p key={fn.name}>
|
||||||
<code>
|
<code>
|
||||||
import {{getFunctionName(fn.name)}} from '{getModuleName(
|
import {{getName(fn.name)}} from '{getModuleName(
|
||||||
|
mod.name
|
||||||
|
)}';
|
||||||
|
</code>
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
renderConstant(constant, mod) {
|
||||||
|
return (
|
||||||
|
<p key={constant.name}>
|
||||||
|
<code>
|
||||||
|
import {{getName(constant.name)}} from '{getModuleName(
|
||||||
mod.name
|
mod.name
|
||||||
)}';
|
)}';
|
||||||
</code>
|
</code>
|
||||||
|
|||||||
Reference in New Issue
Block a user