From 3472bdcfd4ea0a6145dd68972f563e483baf7e6b Mon Sep 17 00:00:00 2001
From: Fabio Berger <me@fabioberger.com>
Date: Tue, 28 Nov 2017 11:16:35 -0600
Subject: Refactor docs to be more declarative, put all hard-coded doc-related
 data in one place so it easier to add new doc pages

---
 packages/website/ts/pages/documentation/type.tsx | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

(limited to 'packages/website/ts/pages/documentation/type.tsx')

diff --git a/packages/website/ts/pages/documentation/type.tsx b/packages/website/ts/pages/documentation/type.tsx
index b7d56f360..acd46ab72 100644
--- a/packages/website/ts/pages/documentation/type.tsx
+++ b/packages/website/ts/pages/documentation/type.tsx
@@ -3,6 +3,7 @@ import {colors} from 'material-ui/styles';
 import * as React from 'react';
 import {Link as ScrollLink} from 'react-scroll';
 import * as ReactTooltip from 'react-tooltip';
+import {DocsInfo} from 'ts/pages/documentation/docs_info';
 import {TypeDefinition} from 'ts/pages/documentation/type_definition';
 import {Type as TypeDef, TypeDefinitionByName, TypeDocTypes} from 'ts/types';
 import {constants} from 'ts/utils/constants';
@@ -38,6 +39,7 @@ const typeToSection: {[typeName: string]: string} = {
 
 interface TypeProps {
     type: TypeDef;
+    docsInfo: DocsInfo;
     typeDefinitionByName?: TypeDefinitionByName;
 }
 
@@ -70,6 +72,7 @@ export function Type(props: TypeProps): any {
                                 key={key}
                                 type={arg.elementType}
                                 typeDefinitionByName={props.typeDefinitionByName}
+                                docsInfo={props.docsInfo}
                             />[]
                         </span>
                     );
@@ -79,6 +82,7 @@ export function Type(props: TypeProps): any {
                             key={`type-${arg.name}-${arg.value}-${arg.typeDocType}`}
                             type={arg}
                             typeDefinitionByName={props.typeDefinitionByName}
+                            docsInfo={props.docsInfo}
                         />
                     );
                     return subType;
@@ -102,6 +106,7 @@ export function Type(props: TypeProps): any {
                         key={`type-${t.name}-${t.value}-${t.typeDocType}`}
                         type={t}
                         typeDefinitionByName={props.typeDefinitionByName}
+                        docsInfo={props.docsInfo}
                     />
                 );
             });
@@ -141,7 +146,7 @@ export function Type(props: TypeProps): any {
             </a>
         );
     } else if ((isReference || isArray) &&
-                (typeDocUtils.isPublicType(typeName as string) ||
+                (props.docsInfo.isPublicType(typeName as string) ||
                 !_.isUndefined(sectionNameIfExists))) {
         const id = Math.random().toString();
         const typeDefinitionAnchorId = _.isUndefined(sectionNameIfExists) ? typeName : sectionNameIfExists;
@@ -176,7 +181,11 @@ export function Type(props: TypeProps): any {
                         id={id}
                         className="typeTooltip"
                     >
-                        <TypeDefinition customType={typeDefinition} shouldAddId={false} />
+                        <TypeDefinition
+                            customType={typeDefinition}
+                            shouldAddId={false}
+                            docsInfo={props.docsInfo}
+                        />
                     </ReactTooltip>
                 </span>
             }
-- 
cgit v1.2.3

