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/OceanAccounts',
'ocean/OceanAssets', 'ocean/OceanAssets',
'ocean/OceanAgreements', 'ocean/OceanAgreements',
'ocean/OceanAgreementsConditions',
'ocean/OceanSecretStore',
'ocean/OceanVersions', 'ocean/OceanVersions',
'ocean/Account', 'ocean/Account',
'ocean/DID', 'ocean/DID',
'ocean/ServiceAgreements/ServiceAgreement',
'ddo/DDO', 'ddo/DDO',
'ddo/Service', 'ddo/Service',
'aquarius/AquariusProvider',
'aquarius/Aquarius', 'aquarius/Aquarius',
'aquarius/query/SearchQuery',
'brizo/BrizoProvider',
'brizo/Brizo', 'brizo/Brizo',
'keeper/Keeper', 'keeper/Keeper',
'keeper/ContractHandler',
'keeper/EventHandler',
'keeper/Web3Provider', 'keeper/Web3Provider',
'secretstore/SecretStoreProvider',
'models/Config', '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}> <div className={styles.type}>
<span> <span>
{isInternal && ( {isInternal && (
<Scroll type="id" element={`${slugify(name)}`} offset={-20}> <Scroll
type="id"
element={`${name && slugify(name)}`}
offset={-20}
>
{type.name} {type.name}
</Scroll> </Scroll>
)} )}
@ -140,7 +144,8 @@ const PropertyWrapper = ({ property, sourceUrl, parentAnchor }) => {
let deprecatedUse, deprecatedSlug let deprecatedUse, deprecatedSlug
if (deprecation) { if (deprecation) {
deprecatedUse = deprecation.arguments.alternative.replace(/('|")/g, '') deprecatedUse = deprecation.arguments.alternative.replace(/('|")/g, '')
deprecatedSlug = slugify(deprecatedUse.replace('.', '-')) deprecatedSlug =
deprecatedUse && slugify(deprecatedUse.replace('.', '-'))
} }
const sourceLink = `${sourceUrl}${fileName}#L${line}` const sourceLink = `${sourceUrl}${fileName}#L${line}`
@ -150,7 +155,7 @@ const PropertyWrapper = ({ property, sourceUrl, parentAnchor }) => {
className={styles.property} className={styles.property}
data-private={!isPublic} data-private={!isPublic}
data-deprecated={!!deprecation} data-deprecated={!!deprecation}
id={`${parentAnchor}-${slugify(name)}`} id={`${parentAnchor}-${name && slugify(name)}`}
> >
<h3 className={styles.propertyName}>{name}</h3> <h3 className={styles.propertyName}>{name}</h3>
@ -222,7 +227,7 @@ PropertyWrapper.propTypes = {
const Entities = ({ entities, sourceUrl }) => const Entities = ({ entities, sourceUrl }) =>
entities.map(({ name, comment, children }) => ( entities.map(({ name, comment, children }) => (
<div key={name} id={slugify(name)}> <div key={name} id={name && slugify(name)}>
<h2 className={styles.entityName}> <h2 className={styles.entityName}>
<code>{name}</code> <code>{name}</code>
</h2> </h2>
@ -233,12 +238,15 @@ const Entities = ({ entities, sourceUrl }) =>
</div> </div>
)} )}
{children.filter(filterByKindOfProperty).map(property => ( {children &&
children
.filter(filterByKindOfProperty)
.map(property => (
<PropertyWrapper <PropertyWrapper
key={`${name}/${property.id}`} key={`${name}/${property.id}`}
property={property} property={property}
sourceUrl={sourceUrl} sourceUrl={sourceUrl}
parentAnchor={slugify(name)} parentAnchor={name && slugify(name)}
/> />
))} ))}
</div> </div>

View File

@ -12,6 +12,7 @@ export default class Toc extends PureComponent {
} }
subItems = (children, parentName) => subItems = (children, parentName) =>
children &&
children.filter(filterByKindOfProperty).map(({ name, decorators }) => { children.filter(filterByKindOfProperty).map(({ name, decorators }) => {
const deprecation = (decorators || []).filter( const deprecation = (decorators || []).filter(
({ name }) => name === 'deprecated' ({ name }) => name === 'deprecated'
@ -21,7 +22,7 @@ export default class Toc extends PureComponent {
<li key={name}> <li key={name}>
<Scroll <Scroll
type="id" type="id"
element={`${parentName}-${slugify(name)}`} element={`${parentName}-${name && slugify(name)}`}
data-deprecated={!!deprecation} data-deprecated={!!deprecation}
offset={-20} offset={-20}
> >
@ -36,14 +37,19 @@ export default class Toc extends PureComponent {
const parentName = name const parentName = name
subIds.push( subIds.push(
children &&
children.filter(filterByKindOfProperty).map(({ name }) => { children.filter(filterByKindOfProperty).map(({ name }) => {
return `${parentName}-${slugify(name)}` return `${parentName}-${name && slugify(name)}`
}) })
) )
return ( return (
<li key={name}> <li key={name}>
<Scroll type="id" element={`${slugify(name)}`} offset={-20}> <Scroll
type="id"
element={`${name && slugify(name)}`}
offset={-20}
>
<code>{name}</code> <code>{name}</code>
</Scroll> </Scroll>
<Scrollspy <Scrollspy

View File

@ -2,17 +2,28 @@ export const cleanTypedocData = (data, useClasses) => {
const nodes = data.children const nodes = data.children
const cleanData = nodes const cleanData = nodes
.map(node => ({ .map(node => {
const child =
node.children &&
node.children.filter(
({ kindString }) => kindString === 'Class'
)[0]
return {
...node, ...node,
name: node.name.replace(/"/g, '').replace('src/', ''), name: node.name.replace(/"/g, '').replace('src/', ''),
child: node.children && node.children[0] child
})) }
})
.filter(({ name }) => (useClasses || []).includes(name)) .filter(({ name }) => (useClasses || []).includes(name))
.sort((a, b) => useClasses.indexOf(a.name) - useClasses.indexOf(b.name)) .sort((a, b) => useClasses.indexOf(a.name) - useClasses.indexOf(b.name))
.map(({ child }) => child) .map(({ child }) => child)
.map(node => ({ .map(node => ({
...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 return cleanData
@ -21,7 +32,9 @@ export const cleanTypedocData = (data, useClasses) => {
// more kinds: 'Property', 'Class' // more kinds: 'Property', 'Class'
const showKindOfProperty = { const showKindOfProperty = {
Method: { onlyPublic: true }, Method: { onlyPublic: true },
Property: { onlyPublic: true } Property: { onlyPublic: true },
Class: { onlyPublic: true },
Interface: { onlyPublic: false }
} }
export const filterByKindOfProperty = ({ kindString, flags }) => { export const filterByKindOfProperty = ({ kindString, flags }) => {