mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-11-26 19:49:26 +01:00
read-the-docs: Resolve merge conflicts
This commit is contained in:
commit
ade83ba58b
@ -175,7 +175,8 @@ exports.createPages = ({ graphql, actions }) => {
|
|||||||
//
|
//
|
||||||
const createTypeDocPage = async (createPage, name, downloadUrl) => {
|
const createTypeDocPage = async (createPage, name, downloadUrl) => {
|
||||||
try {
|
try {
|
||||||
const typedoc = await fetch(downloadUrl)
|
const typedoc = require('./ocean.js.json')
|
||||||
|
// const typedoc = await fetch(downloadUrl)
|
||||||
const typedocTemplate = path.resolve('./src/templates/Typedoc/index.jsx')
|
const typedocTemplate = path.resolve('./src/templates/Typedoc/index.jsx')
|
||||||
const slug = `/references/${name}/`
|
const slug = `/references/${name}/`
|
||||||
|
|
||||||
@ -184,39 +185,8 @@ const createTypeDocPage = async (createPage, name, downloadUrl) => {
|
|||||||
component: typedocTemplate,
|
component: typedocTemplate,
|
||||||
context: {
|
context: {
|
||||||
slug,
|
slug,
|
||||||
typedoc: await typedoc.json(),
|
typedoc
|
||||||
// We define the classes here so the data object passed as page context
|
// typedoc: await typedoc.json()
|
||||||
// is as small as possible.
|
|
||||||
// Caveat: no live update during development when these values are changed.
|
|
||||||
//
|
|
||||||
// TODO: defining these classes for inclusion
|
|
||||||
// needs to be handled somewhere else to keep
|
|
||||||
// it generic for all TypeDoc specs
|
|
||||||
classes: [
|
|
||||||
'ocean/Ocean',
|
|
||||||
'ocean/Account',
|
|
||||||
'ocean/Assets',
|
|
||||||
'ocean/Compute',
|
|
||||||
'ocean/Versions',
|
|
||||||
'ocean/DID',
|
|
||||||
'ddo/DDO',
|
|
||||||
'metadatacache/MetadataCache',
|
|
||||||
'metadatacache/OnChainMetaDataCache',
|
|
||||||
'provider/Provider',
|
|
||||||
'datatokens/Datatokens',
|
|
||||||
'datatokens/Network',
|
|
||||||
'datatokens/Web3Provider',
|
|
||||||
'balancer/OceanPool',
|
|
||||||
'balancer/Pool',
|
|
||||||
'balancer/PoolFactory',
|
|
||||||
'exchange/FixedRateExchange',
|
|
||||||
'models/Config',
|
|
||||||
'utils/ConfigHelper',
|
|
||||||
'utils/GasUtils',
|
|
||||||
'ocean/utils/OceanUtils',
|
|
||||||
'ocean/utils/WebServiceConnector',
|
|
||||||
'utils/Logger'
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
11616
ocean.js.json
Normal file
11616
ocean.js.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,9 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import PropTypes from 'prop-types'
|
import PropTypes from 'prop-types'
|
||||||
import slugify from 'slugify'
|
import slugify from 'slugify'
|
||||||
import shortid from 'shortid'
|
|
||||||
import Scroll from '../../components/Scroll'
|
import Scroll from '../../components/Scroll'
|
||||||
import styles from './Entities.module.scss'
|
import styles from './Entities.module.scss'
|
||||||
import { filterByKindOfProperty } from './utils'
|
import shortid from 'shortid'
|
||||||
|
|
||||||
const Type = ({ type }) => {
|
const Type = ({ type }) => {
|
||||||
let isArray = false
|
let isArray = false
|
||||||
@ -33,7 +32,7 @@ const Type = ({ type }) => {
|
|||||||
{typeArguments.map((typeArgument, i) => (
|
{typeArguments.map((typeArgument, i) => (
|
||||||
<span key={shortid.generate()}>
|
<span key={shortid.generate()}>
|
||||||
{i !== 0 && <span className={styles.typeSymbol}>, </span>}
|
{i !== 0 && <span className={styles.typeSymbol}>, </span>}
|
||||||
<Type type={typeArgument} />
|
{typeArgument.name}
|
||||||
</span>
|
</span>
|
||||||
))}
|
))}
|
||||||
</span>
|
</span>
|
||||||
@ -50,19 +49,6 @@ Type.propTypes = {
|
|||||||
type: PropTypes.object.isRequired
|
type: PropTypes.object.isRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
const PropertyDetails = ({ property }) => {
|
|
||||||
const { type } = property
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<Type type={type} />
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
PropertyDetails.propTypes = {
|
|
||||||
property: PropTypes.object
|
|
||||||
}
|
|
||||||
|
|
||||||
const MethodDetails = ({ property }) => {
|
const MethodDetails = ({ property }) => {
|
||||||
const signature = property.signatures[0]
|
const signature = property.signatures[0]
|
||||||
const { parameters, type } = signature
|
const { parameters, type } = signature
|
||||||
@ -78,7 +64,7 @@ const MethodDetails = ({ property }) => {
|
|||||||
const description = comment && (comment.text || comment.shortText)
|
const description = comment && (comment.text || comment.shortText)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.parameters} key={shortid.generate()}>
|
<div className={styles.parameters} key={name}>
|
||||||
<h5>
|
<h5>
|
||||||
<code>{name}</code>
|
<code>{name}</code>
|
||||||
{isOptional && (
|
{isOptional && (
|
||||||
@ -119,7 +105,6 @@ const PropertyWrapper = ({ property, sourceUrl, parentAnchor }) => {
|
|||||||
const { isPublic, isStatic } = flags
|
const { isPublic, isStatic } = flags
|
||||||
const signature = signatures && signatures[0]
|
const signature = signatures && signatures[0]
|
||||||
const comment = (signature && signature.comment) || property.comment
|
const comment = (signature && signature.comment) || property.comment
|
||||||
const { fileName, line } = sources[0]
|
|
||||||
const deprecation = (decorators || []).filter(
|
const deprecation = (decorators || []).filter(
|
||||||
({ name }) => name === 'deprecated'
|
({ name }) => name === 'deprecated'
|
||||||
)[0] // Assuming deprecated annotation
|
)[0] // Assuming deprecated annotation
|
||||||
@ -129,7 +114,10 @@ const PropertyWrapper = ({ property, sourceUrl, parentAnchor }) => {
|
|||||||
deprecatedSlug = deprecatedUse && slugify(deprecatedUse.replace('.', '-'))
|
deprecatedSlug = deprecatedUse && slugify(deprecatedUse.replace('.', '-'))
|
||||||
}
|
}
|
||||||
|
|
||||||
const sourceLink = `${sourceUrl}${fileName}#L${line}`
|
const sourceLink =
|
||||||
|
sources && sources[0]
|
||||||
|
? `${sourceUrl}${sources[0].fileName}#L${sources[0].line}`
|
||||||
|
: ''
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@ -175,18 +163,22 @@ const PropertyWrapper = ({ property, sourceUrl, parentAnchor }) => {
|
|||||||
case 'Method':
|
case 'Method':
|
||||||
return <MethodDetails property={property} />
|
return <MethodDetails property={property} />
|
||||||
case 'Property':
|
case 'Property':
|
||||||
return <PropertyDetails property={property} />
|
return (
|
||||||
|
<div>
|
||||||
|
<Type type={property} />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
})()}
|
})()}
|
||||||
|
|
||||||
{fileName && (
|
{sources && sources[0] && (
|
||||||
<a
|
<a
|
||||||
className={styles.sourceLink}
|
className={styles.sourceLink}
|
||||||
href={sourceLink}
|
href={sourceLink}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener noreferrer"
|
rel="noopener noreferrer"
|
||||||
>
|
>
|
||||||
{`${fileName}#L${line}`}
|
{`${sources[0].fileName}#L${sources[0].line}`}
|
||||||
</a>
|
</a>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@ -201,7 +193,7 @@ PropertyWrapper.propTypes = {
|
|||||||
|
|
||||||
const Entities = ({ entities, sourceUrl }) =>
|
const Entities = ({ entities, sourceUrl }) =>
|
||||||
entities.map(({ name, comment, children }) => (
|
entities.map(({ name, comment, children }) => (
|
||||||
<div key={shortid.generate()} id={name && 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>
|
||||||
@ -213,16 +205,14 @@ const Entities = ({ entities, sourceUrl }) =>
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{children &&
|
{children &&
|
||||||
children
|
children.map((property) => (
|
||||||
.filter(filterByKindOfProperty)
|
<PropertyWrapper
|
||||||
.map((property) => (
|
key={property.id}
|
||||||
<PropertyWrapper
|
property={property}
|
||||||
key={shortid.generate()}
|
sourceUrl={sourceUrl}
|
||||||
property={property}
|
parentAnchor={name && slugify(name)}
|
||||||
sourceUrl={sourceUrl}
|
/>
|
||||||
parentAnchor={name && slugify(name)}
|
))}
|
||||||
/>
|
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
))
|
))
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import slugify from 'slugify'
|
|||||||
import shortid from 'shortid'
|
import shortid from 'shortid'
|
||||||
import Scrollspy from 'react-scrollspy'
|
import Scrollspy from 'react-scrollspy'
|
||||||
import Scroll from '../../components/Scroll'
|
import Scroll from '../../components/Scroll'
|
||||||
import { filterByKindOfProperty } from './utils'
|
|
||||||
import stylesSidebar from '../../components/Sidebar.module.scss'
|
import stylesSidebar from '../../components/Sidebar.module.scss'
|
||||||
|
|
||||||
export default class Toc extends PureComponent {
|
export default class Toc extends PureComponent {
|
||||||
@ -14,13 +13,13 @@ export default class Toc extends PureComponent {
|
|||||||
|
|
||||||
subItems = (children, parentName) =>
|
subItems = (children, parentName) =>
|
||||||
children &&
|
children &&
|
||||||
children.filter(filterByKindOfProperty).map(({ name, decorators }) => {
|
children.map(({ name, decorators }) => {
|
||||||
const deprecation = (decorators || []).filter(
|
const deprecation = (decorators || []).filter(
|
||||||
({ name }) => name === 'deprecated'
|
({ name }) => name === 'deprecated'
|
||||||
)[0] // Assuming deprecated annotation
|
)[0] // Assuming deprecated annotation
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li key={shortid.generate()}>
|
<li key={name}>
|
||||||
<Scroll
|
<Scroll
|
||||||
type="id"
|
type="id"
|
||||||
element={`${parentName}-${name && slugify(name)}`}
|
element={`${parentName}-${name && slugify(name)}`}
|
||||||
@ -39,7 +38,7 @@ export default class Toc extends PureComponent {
|
|||||||
|
|
||||||
subIds.push(
|
subIds.push(
|
||||||
children &&
|
children &&
|
||||||
children.filter(filterByKindOfProperty).map(({ name }) => {
|
children.map(({ name }) => {
|
||||||
return `${parentName}-${name && slugify(name)}`
|
return `${parentName}-${name && slugify(name)}`
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
@ -8,7 +8,6 @@ import HeaderSection from '../../components/HeaderSection'
|
|||||||
import Sidebar from '../../components/Sidebar'
|
import Sidebar from '../../components/Sidebar'
|
||||||
import DocHeader from '../../components/DocHeader'
|
import DocHeader from '../../components/DocHeader'
|
||||||
import Seo from '../../components/Seo'
|
import Seo from '../../components/Seo'
|
||||||
import { cleanTypedocData } from './utils'
|
|
||||||
|
|
||||||
import Entities from './Entities'
|
import Entities from './Entities'
|
||||||
import Toc from './Toc'
|
import Toc from './Toc'
|
||||||
@ -22,11 +21,6 @@ export default class TypedocTemplate extends Component {
|
|||||||
pageContext: PropTypes.object.isRequired
|
pageContext: PropTypes.object.isRequired
|
||||||
}
|
}
|
||||||
|
|
||||||
typedocCleaned = cleanTypedocData(
|
|
||||||
this.props.pageContext.typedoc,
|
|
||||||
this.props.pageContext.classes
|
|
||||||
)
|
|
||||||
|
|
||||||
// output section title as defined in sections.yml
|
// output section title as defined in sections.yml
|
||||||
sectionTitle = this.props.data.allSectionsYaml.edges.map(({ node }) => {
|
sectionTitle = this.props.data.allSectionsYaml.edges.map(({ node }) => {
|
||||||
// compare section against section title from sections.yml
|
// compare section against section title from sections.yml
|
||||||
@ -38,8 +32,7 @@ export default class TypedocTemplate extends Component {
|
|||||||
render() {
|
render() {
|
||||||
const { location, pageContext } = this.props
|
const { location, pageContext } = this.props
|
||||||
const { typedoc } = pageContext
|
const { typedoc } = pageContext
|
||||||
const { info } = typedoc
|
const { title, description, version, sourceUrl } = typedoc.info
|
||||||
const { title, description, version, sourceUrl } = info
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -66,7 +59,7 @@ export default class TypedocTemplate extends Component {
|
|||||||
sidebar="references"
|
sidebar="references"
|
||||||
collapsed
|
collapsed
|
||||||
toc
|
toc
|
||||||
tocComponent={<Toc data={this.typedocCleaned} />}
|
tocComponent={<Toc data={typedoc.children} />}
|
||||||
/>
|
/>
|
||||||
</aside>
|
</aside>
|
||||||
<article className={stylesDoc.main}>
|
<article className={stylesDoc.main}>
|
||||||
@ -76,10 +69,7 @@ export default class TypedocTemplate extends Component {
|
|||||||
prepend={<span className={stylesDoc.version}>{version}</span>}
|
prepend={<span className={stylesDoc.version}>{version}</span>}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Entities
|
<Entities entities={typedoc.children} sourceUrl={sourceUrl} />
|
||||||
entities={this.typedocCleaned}
|
|
||||||
sourceUrl={sourceUrl}
|
|
||||||
/>
|
|
||||||
</article>
|
</article>
|
||||||
</main>
|
</main>
|
||||||
</Content>
|
</Content>
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
export const cleanTypedocData = (data, useClasses) => {
|
|
||||||
const nodes = data.children
|
|
||||||
|
|
||||||
const cleanData = nodes
|
|
||||||
.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 && node.children && node.children.sort((a, b) => a.id - b.id)
|
|
||||||
}))
|
|
||||||
|
|
||||||
return cleanData
|
|
||||||
}
|
|
||||||
|
|
||||||
// more kinds: 'Property', 'Enumeration'
|
|
||||||
const showKindOfProperty = {
|
|
||||||
Method: { onlyPublic: true },
|
|
||||||
Property: { onlyPublic: true }
|
|
||||||
}
|
|
||||||
|
|
||||||
export const filterByKindOfProperty = ({ kindString, flags }) => {
|
|
||||||
const config = showKindOfProperty[kindString]
|
|
||||||
if (!config) return
|
|
||||||
|
|
||||||
// filter out static methods by default
|
|
||||||
if (flags.isStatic) return
|
|
||||||
|
|
||||||
if (config.onlyPublic && !flags.isPublic) return
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user