From 3e40c3d0780e9401fef6b82e620d40fab02f3883 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 6 Nov 2019 12:30:44 +0100 Subject: [PATCH] fix typedoc cleanup --- gatsby-node.js | 15 ++++++++------ src/templates/Typedoc/Entities.jsx | 32 +++++++++++++++++++----------- src/templates/Typedoc/Toc.jsx | 16 ++++++++++----- src/templates/Typedoc/utils.js | 27 ++++++++++++++++++------- 4 files changed, 60 insertions(+), 30 deletions(-) diff --git a/gatsby-node.js b/gatsby-node.js index a3d97268..bb4e0ad0 100755 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -220,22 +220,25 @@ const createTypeDocPage = async (createPage, name, downloadUrl) => { 'ocean/OceanAccounts', 'ocean/OceanAssets', 'ocean/OceanAgreements', + 'ocean/OceanAgreementsConditions', + 'ocean/OceanSecretStore', 'ocean/OceanVersions', 'ocean/Account', 'ocean/DID', - 'ocean/ServiceAgreements/ServiceAgreement', 'ddo/DDO', 'ddo/Service', - 'aquarius/AquariusProvider', 'aquarius/Aquarius', - 'aquarius/query/SearchQuery', - 'brizo/BrizoProvider', 'brizo/Brizo', 'keeper/Keeper', + 'keeper/ContractHandler', + 'keeper/EventHandler', 'keeper/Web3Provider', - 'secretstore/SecretStoreProvider', 'models/Config', - 'models/Balance' + 'models/Balance', + 'ocean/utils/OceanUtils', + 'ocean/utils/ServiceAgreement', + 'ocean/utils/WebServiceConnector', + 'utils/Logger' ] } }) diff --git a/src/templates/Typedoc/Entities.jsx b/src/templates/Typedoc/Entities.jsx index d2b0da69..b6991be3 100644 --- a/src/templates/Typedoc/Entities.jsx +++ b/src/templates/Typedoc/Entities.jsx @@ -18,7 +18,11 @@ const Type = ({ type }) => {
{isInternal && ( - + {type.name} )} @@ -140,7 +144,8 @@ const PropertyWrapper = ({ property, sourceUrl, parentAnchor }) => { let deprecatedUse, deprecatedSlug if (deprecation) { deprecatedUse = deprecation.arguments.alternative.replace(/('|")/g, '') - deprecatedSlug = slugify(deprecatedUse.replace('.', '-')) + deprecatedSlug = + deprecatedUse && slugify(deprecatedUse.replace('.', '-')) } const sourceLink = `${sourceUrl}${fileName}#L${line}` @@ -150,7 +155,7 @@ const PropertyWrapper = ({ property, sourceUrl, parentAnchor }) => { className={styles.property} data-private={!isPublic} data-deprecated={!!deprecation} - id={`${parentAnchor}-${slugify(name)}`} + id={`${parentAnchor}-${name && slugify(name)}`} >

{name}

@@ -222,7 +227,7 @@ PropertyWrapper.propTypes = { const Entities = ({ entities, sourceUrl }) => entities.map(({ name, comment, children }) => ( -
+

{name}

@@ -233,14 +238,17 @@ const Entities = ({ entities, sourceUrl }) =>
)} - {children.filter(filterByKindOfProperty).map(property => ( - - ))} + {children && + children + .filter(filterByKindOfProperty) + .map(property => ( + + ))}
)) diff --git a/src/templates/Typedoc/Toc.jsx b/src/templates/Typedoc/Toc.jsx index 47acfa66..7d1954ce 100644 --- a/src/templates/Typedoc/Toc.jsx +++ b/src/templates/Typedoc/Toc.jsx @@ -12,6 +12,7 @@ export default class Toc extends PureComponent { } subItems = (children, parentName) => + children && children.filter(filterByKindOfProperty).map(({ name, decorators }) => { const deprecation = (decorators || []).filter( ({ name }) => name === 'deprecated' @@ -21,7 +22,7 @@ export default class Toc extends PureComponent {
  • @@ -36,14 +37,19 @@ export default class Toc extends PureComponent { const parentName = name subIds.push( - children.filter(filterByKindOfProperty).map(({ name }) => { - return `${parentName}-${slugify(name)}` - }) + children && + children.filter(filterByKindOfProperty).map(({ name }) => { + return `${parentName}-${name && slugify(name)}` + }) ) return (
  • - + {name} { const nodes = data.children const cleanData = nodes - .map(node => ({ - ...node, - name: node.name.replace(/"/g, '').replace('src/', ''), - child: node.children && node.children[0] - })) + .map(node => { + const child = + node.children && + node.children.filter( + ({ kindString }) => kindString === 'Class' + )[0] + + return { + ...node, + name: node.name.replace(/"/g, '').replace('src/', ''), + child + } + }) .filter(({ name }) => (useClasses || []).includes(name)) .sort((a, b) => useClasses.indexOf(a.name) - useClasses.indexOf(b.name)) .map(({ child }) => child) .map(node => ({ ...node, - children: node.children.sort((a, b) => a.id - b.id) + children: + node && + node.children && + node.children.sort((a, b) => a.id - b.id) })) return cleanData @@ -21,7 +32,9 @@ export const cleanTypedocData = (data, useClasses) => { // more kinds: 'Property', 'Class' const showKindOfProperty = { Method: { onlyPublic: true }, - Property: { onlyPublic: true } + Property: { onlyPublic: true }, + Class: { onlyPublic: true }, + Interface: { onlyPublic: false } } export const filterByKindOfProperty = ({ kindString, flags }) => {