1
0
mirror of https://github.com/oceanprotocol/docs.git synced 2024-11-26 19:49:26 +01:00

fix typedoc cleanup

This commit is contained in:
Matthias Kretschmann 2019-11-06 12:30:44 +01:00
parent db2c3990fe
commit 3e40c3d078
Signed by: m
GPG Key ID: 606EEEF3C479A91F
4 changed files with 60 additions and 30 deletions

View File

@ -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'
]
}
})

View File

@ -18,7 +18,11 @@ const Type = ({ type }) => {
<div className={styles.type}>
<span>
{isInternal && (
<Scroll type="id" element={`${slugify(name)}`} offset={-20}>
<Scroll
type="id"
element={`${name && slugify(name)}`}
offset={-20}
>
{type.name}
</Scroll>
)}
@ -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)}`}
>
<h3 className={styles.propertyName}>{name}</h3>
@ -222,7 +227,7 @@ PropertyWrapper.propTypes = {
const Entities = ({ entities, sourceUrl }) =>
entities.map(({ name, comment, children }) => (
<div key={name} id={slugify(name)}>
<div key={name} id={name && slugify(name)}>
<h2 className={styles.entityName}>
<code>{name}</code>
</h2>
@ -233,14 +238,17 @@ const Entities = ({ entities, sourceUrl }) =>
</div>
)}
{children.filter(filterByKindOfProperty).map(property => (
<PropertyWrapper
key={`${name}/${property.id}`}
property={property}
sourceUrl={sourceUrl}
parentAnchor={slugify(name)}
/>
))}
{children &&
children
.filter(filterByKindOfProperty)
.map(property => (
<PropertyWrapper
key={`${name}/${property.id}`}
property={property}
sourceUrl={sourceUrl}
parentAnchor={name && slugify(name)}
/>
))}
</div>
))

View File

@ -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 {
<li key={name}>
<Scroll
type="id"
element={`${parentName}-${slugify(name)}`}
element={`${parentName}-${name && slugify(name)}`}
data-deprecated={!!deprecation}
offset={-20}
>
@ -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 (
<li key={name}>
<Scroll type="id" element={`${slugify(name)}`} offset={-20}>
<Scroll
type="id"
element={`${name && slugify(name)}`}
offset={-20}
>
<code>{name}</code>
</Scroll>
<Scrollspy

View File

@ -2,17 +2,28 @@ export const cleanTypedocData = (data, useClasses) => {
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 }) => {