From 5a0f7eacc2e5c9bda5ee94a9f753a14938903f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20Guti=C3=A9rrez?= Date: Mon, 28 Jan 2019 11:48:07 +0100 Subject: [PATCH] fixed deprecation links #45 --- gatsby-node.js | 3 +++ src/templates/Typedoc/Entities.jsx | 20 +++++++------------- src/templates/Typedoc/utils.js | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 13 deletions(-) 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 && ( - < + < {typeArguments.map((typeArgument, 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 }) => {
Deprecated: use{' '} - + {deprecatedUse} {' '} @@ -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 => ( { 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 +}