aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-03-22 23:52:40 +0800
committerFabio Berger <me@fabioberger.com>2018-03-22 23:52:40 +0800
commit5779ffd01b6925f56778601ff54df4f39289d1c7 (patch)
treeaf7f5435539f2f96b5f88be44d3fae80d20781f7 /packages
parenta7c24a17f4c9a4cba6a8c57cf901449169785489 (diff)
downloaddexon-0x-contracts-5779ffd01b6925f56778601ff54df4f39289d1c7.tar.gz
dexon-0x-contracts-5779ffd01b6925f56778601ff54df4f39289d1c7.tar.zst
dexon-0x-contracts-5779ffd01b6925f56778601ff54df4f39289d1c7.zip
Add assertion to notify any developer trying to render a package with files containing multiple classes
Diffstat (limited to 'packages')
-rw-r--r--packages/react-docs/src/utils/typedoc_utils.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/packages/react-docs/src/utils/typedoc_utils.ts b/packages/react-docs/src/utils/typedoc_utils.ts
index 87b9e44ba..fff27a834 100644
--- a/packages/react-docs/src/utils/typedoc_utils.ts
+++ b/packages/react-docs/src/utils/typedoc_utils.ts
@@ -85,6 +85,16 @@ export const typeDocUtils = {
let entities;
let packageComment = '';
// HACK: We assume 1 exported class per file
+ const numClassChildren = _.reduce(
+ packageDefinitionWithMergedChildren.children,
+ (sum: number, child: TypeDocNode) => {
+ const nextSum = child.kindString === KindString.Class ? sum + 1 : sum;
+ return nextSum;
+ },
+ );
+ if (numClassChildren > 1) {
+ throw new Error('`react-docs` only supports projects with 1 exported class per file');
+ }
const isClassExport = packageDefinitionWithMergedChildren.children[0].kindString === KindString.Class;
if (isClassExport) {
entities = packageDefinitionWithMergedChildren.children[0].children;