From a7d180047ac4ac6b0fc711666e710e6de82f8a9c Mon Sep 17 00:00:00 2001 From: ahocevar Date: Sun, 20 May 2018 14:33:40 +0200 Subject: [PATCH] Render class import with constructor conditionally --- site/src/pages/docs.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/site/src/pages/docs.js b/site/src/pages/docs.js index ff3520bfe3..48a38bcc35 100644 --- a/site/src/pages/docs.js +++ b/site/src/pages/docs.js @@ -82,15 +82,22 @@ class Docs extends Component { ); } + renderConstructor(cls, mod) { + if (cls in mod.classes && cls in mod.classes[cls]) { + return ( +
+

{this.renderImport(cls, mod)}

+

new {getName(cls)}()

+
+ ); + } + } + renderClass(cls, mod) { - return cls in mod.classes && cls in mod.classes[cls] ? ( -
-

{this.renderImport(cls, mod)}

-

new {getName(cls)}()

-
- ) : ( + return (

{getName(cls)}

+ {this.renderConstructor(cls, mod)}
); }