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