diff --git a/gatsby-node.js b/gatsby-node.js index c38c0f59..800a633f 100755 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -226,6 +226,9 @@ exports.createPages = ({ graphql, actions }) => { // it generic for all TypeDoc specs classes: [ 'ocean/Ocean', + 'ocean/OceanAccounts', + 'ocean/OceanAssets', + 'ocean/OceanAgreements', 'ocean/Account', 'ocean/DID', 'ocean/ServiceAgreements/ServiceAgreement', diff --git a/src/templates/Typedoc/Entities.jsx b/src/templates/Typedoc/Entities.jsx index 51f3a21e..11dbd5a7 100644 --- a/src/templates/Typedoc/Entities.jsx +++ b/src/templates/Typedoc/Entities.jsx @@ -2,9 +2,7 @@ import React from 'react' import PropTypes from 'prop-types' import slugify from 'slugify' import styles from './Entities.module.scss' - -// more kinds: 'Property', 'Class' -const showKindOfProperty = ['Method'] +import { filterByKindOfProperty } from './utils' const Type = ({ type }) => { let isArray = false @@ -24,7 +22,7 @@ const Type = ({ type }) => { {typeArguments && ( <span> - <span className={styles.typeSymbol}> <</span> + <span className={styles.typeSymbol}><</span> <span> {typeArguments.map((typeArgument, i) => ( <span key={i}> @@ -134,9 +132,10 @@ const PropertyWrapper = ({ property, sourceUrl, parentAnchor }) => { const deprecation = (decorators || []).filter( ({ name }) => name === 'deprecated' )[0] // Assuming deprecated annotation - let deprecatedUse + let deprecatedUse, deprecatedSlug if (deprecation) { - deprecatedUse = deprecation.arguments.alternative.replace(/'/g, '') + deprecatedUse = deprecation.arguments.alternative.replace(/('|")/g, '') + deprecatedSlug = slugify(deprecatedUse.replace('.', '-')) } const sourceLink = `${sourceUrl}${fileName}#L${line}` @@ -174,7 +173,7 @@ const PropertyWrapper = ({ property, sourceUrl, parentAnchor }) => { <div className={styles.deprecation}> <strong>Deprecated</strong>: use{' '} <code> - <a href={`#${parentAnchor}-${slugify(deprecatedUse)}`}> + <a href={`#${deprecatedSlug}`}> {deprecatedUse} </a> </code>{' '} @@ -226,12 +225,7 @@ const Entities = ({ entities, sourceUrl }) => )} {children - // TODO: this filter neeeds to be added in utils.js - // cleanTypedocData function to make content and - // sidebar TOC consistent - .filter(({ kindString }) => - showKindOfProperty.includes(kindString) - ) + .filter(filterByKindOfProperty) .map(property => ( <PropertyWrapper key={`${name}/${property.id}`} diff --git a/src/templates/Typedoc/utils.js b/src/templates/Typedoc/utils.js index ec4fd515..bd5adfd1 100644 --- a/src/templates/Typedoc/utils.js +++ b/src/templates/Typedoc/utils.js @@ -17,3 +17,19 @@ export const cleanTypedocData = (data, useClasses) => { return cleanData } + +// more kinds: 'Property', 'Class' +const showKindOfProperty = { + Method: true, + Property: {onlyPublic: true}, +} +export const filterByKindOfProperty = ({ kindString, flags }) => { + const config = showKindOfProperty[kindString] + if (!config) { + return + } + if (config.onlyPublic && !flags.isPublic) { + return + } + return true +}