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
|
||||
classes: [
|
||||
'ocean/Ocean',
|
||||
'ocean/OceanAccounts',
|
||||
'ocean/OceanAssets',
|
||||
'ocean/OceanAgreements',
|
||||
'ocean/Account',
|
||||
'ocean/DID',
|
||||
'ocean/ServiceAgreements/ServiceAgreement',
|
||||
|
@ -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}`}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user