mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-11-26 19:49:26 +01:00
fixed deprecation links #45
This commit is contained in:
parent
09c8d41608
commit
5a0f7eacc2
@ -226,6 +226,9 @@ exports.createPages = ({ graphql, actions }) => {
|
|||||||
// it generic for all TypeDoc specs
|
// it generic for all TypeDoc specs
|
||||||
classes: [
|
classes: [
|
||||||
'ocean/Ocean',
|
'ocean/Ocean',
|
||||||
|
'ocean/OceanAccounts',
|
||||||
|
'ocean/OceanAssets',
|
||||||
|
'ocean/OceanAgreements',
|
||||||
'ocean/Account',
|
'ocean/Account',
|
||||||
'ocean/DID',
|
'ocean/DID',
|
||||||
'ocean/ServiceAgreements/ServiceAgreement',
|
'ocean/ServiceAgreements/ServiceAgreement',
|
||||||
|
@ -2,9 +2,7 @@ import React from 'react'
|
|||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import slugify from 'slugify'
|
import slugify from 'slugify'
|
||||||
import styles from './Entities.module.scss'
|
import styles from './Entities.module.scss'
|
||||||
|
import { filterByKindOfProperty } from './utils'
|
||||||
// more kinds: 'Property', 'Class'
|
|
||||||
const showKindOfProperty = ['Method']
|
|
||||||
|
|
||||||
const Type = ({ type }) => {
|
const Type = ({ type }) => {
|
||||||
let isArray = false
|
let isArray = false
|
||||||
@ -24,7 +22,7 @@ const Type = ({ type }) => {
|
|||||||
|
|
||||||
{typeArguments && (
|
{typeArguments && (
|
||||||
<span>
|
<span>
|
||||||
<span className={styles.typeSymbol}> <</span>
|
<span className={styles.typeSymbol}><</span>
|
||||||
<span>
|
<span>
|
||||||
{typeArguments.map((typeArgument, i) => (
|
{typeArguments.map((typeArgument, i) => (
|
||||||
<span key={i}>
|
<span key={i}>
|
||||||
@ -134,9 +132,10 @@ const PropertyWrapper = ({ property, sourceUrl, parentAnchor }) => {
|
|||||||
const deprecation = (decorators || []).filter(
|
const deprecation = (decorators || []).filter(
|
||||||
({ name }) => name === 'deprecated'
|
({ name }) => name === 'deprecated'
|
||||||
)[0] // Assuming deprecated annotation
|
)[0] // Assuming deprecated annotation
|
||||||
let deprecatedUse
|
let deprecatedUse, deprecatedSlug
|
||||||
if (deprecation) {
|
if (deprecation) {
|
||||||
deprecatedUse = deprecation.arguments.alternative.replace(/'/g, '')
|
deprecatedUse = deprecation.arguments.alternative.replace(/('|")/g, '')
|
||||||
|
deprecatedSlug = slugify(deprecatedUse.replace('.', '-'))
|
||||||
}
|
}
|
||||||
|
|
||||||
const sourceLink = `${sourceUrl}${fileName}#L${line}`
|
const sourceLink = `${sourceUrl}${fileName}#L${line}`
|
||||||
@ -174,7 +173,7 @@ const PropertyWrapper = ({ property, sourceUrl, parentAnchor }) => {
|
|||||||
<div className={styles.deprecation}>
|
<div className={styles.deprecation}>
|
||||||
<strong>Deprecated</strong>: use{' '}
|
<strong>Deprecated</strong>: use{' '}
|
||||||
<code>
|
<code>
|
||||||
<a href={`#${parentAnchor}-${slugify(deprecatedUse)}`}>
|
<a href={`#${deprecatedSlug}`}>
|
||||||
{deprecatedUse}
|
{deprecatedUse}
|
||||||
</a>
|
</a>
|
||||||
</code>{' '}
|
</code>{' '}
|
||||||
@ -226,12 +225,7 @@ const Entities = ({ entities, sourceUrl }) =>
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{children
|
{children
|
||||||
// TODO: this filter neeeds to be added in utils.js
|
.filter(filterByKindOfProperty)
|
||||||
// cleanTypedocData function to make content and
|
|
||||||
// sidebar TOC consistent
|
|
||||||
.filter(({ kindString }) =>
|
|
||||||
showKindOfProperty.includes(kindString)
|
|
||||||
)
|
|
||||||
.map(property => (
|
.map(property => (
|
||||||
<PropertyWrapper
|
<PropertyWrapper
|
||||||
key={`${name}/${property.id}`}
|
key={`${name}/${property.id}`}
|
||||||
|
@ -17,3 +17,19 @@ export const cleanTypedocData = (data, useClasses) => {
|
|||||||
|
|
||||||
return cleanData
|
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
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user