1
0
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:
Akshay 2021-05-31 10:46:57 +02:00
commit ade83ba58b
6 changed files with 11649 additions and 128 deletions

View File

@ -175,7 +175,8 @@ exports.createPages = ({ graphql, actions }) => {
//
const createTypeDocPage = async (createPage, name, downloadUrl) => {
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 slug = `/references/${name}/`
@ -184,39 +185,8 @@ const createTypeDocPage = async (createPage, name, downloadUrl) => {
component: typedocTemplate,
context: {
slug,
typedoc: await typedoc.json(),
// We define the classes here so the data object passed as page context
// 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'
]
typedoc
// typedoc: await typedoc.json()
}
})
} catch (error) {

11616
ocean.js.json Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +1,9 @@
import React from 'react'
import PropTypes from 'prop-types'
import slugify from 'slugify'
import shortid from 'shortid'
import Scroll from '../../components/Scroll'
import styles from './Entities.module.scss'
import { filterByKindOfProperty } from './utils'
import shortid from 'shortid'
const Type = ({ type }) => {
let isArray = false
@ -33,7 +32,7 @@ const Type = ({ type }) => {
{typeArguments.map((typeArgument, i) => (
<span key={shortid.generate()}>
{i !== 0 && <span className={styles.typeSymbol}>, </span>}
<Type type={typeArgument} />
{typeArgument.name}
</span>
))}
</span>
@ -50,19 +49,6 @@ Type.propTypes = {
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 signature = property.signatures[0]
const { parameters, type } = signature
@ -78,7 +64,7 @@ const MethodDetails = ({ property }) => {
const description = comment && (comment.text || comment.shortText)
return (
<div className={styles.parameters} key={shortid.generate()}>
<div className={styles.parameters} key={name}>
<h5>
<code>{name}</code>
{isOptional && (
@ -119,7 +105,6 @@ const PropertyWrapper = ({ property, sourceUrl, parentAnchor }) => {
const { isPublic, isStatic } = flags
const signature = signatures && signatures[0]
const comment = (signature && signature.comment) || property.comment
const { fileName, line } = sources[0]
const deprecation = (decorators || []).filter(
({ name }) => name === 'deprecated'
)[0] // Assuming deprecated annotation
@ -129,7 +114,10 @@ const PropertyWrapper = ({ property, sourceUrl, parentAnchor }) => {
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 (
<div
@ -175,18 +163,22 @@ const PropertyWrapper = ({ property, sourceUrl, parentAnchor }) => {
case 'Method':
return <MethodDetails property={property} />
case 'Property':
return <PropertyDetails property={property} />
return (
<div>
<Type type={property} />
</div>
)
}
})()}
{fileName && (
{sources && sources[0] && (
<a
className={styles.sourceLink}
href={sourceLink}
target="_blank"
rel="noopener noreferrer"
>
{`${fileName}#L${line}`}
{`${sources[0].fileName}#L${sources[0].line}`}
</a>
)}
</div>
@ -201,7 +193,7 @@ PropertyWrapper.propTypes = {
const Entities = ({ entities, sourceUrl }) =>
entities.map(({ name, comment, children }) => (
<div key={shortid.generate()} id={name && slugify(name)}>
<div key={name} id={name && slugify(name)}>
<h2 className={styles.entityName}>
<code>{name}</code>
</h2>
@ -213,16 +205,14 @@ const Entities = ({ entities, sourceUrl }) =>
)}
{children &&
children
.filter(filterByKindOfProperty)
.map((property) => (
<PropertyWrapper
key={shortid.generate()}
property={property}
sourceUrl={sourceUrl}
parentAnchor={name && slugify(name)}
/>
))}
children.map((property) => (
<PropertyWrapper
key={property.id}
property={property}
sourceUrl={sourceUrl}
parentAnchor={name && slugify(name)}
/>
))}
</div>
))

View File

@ -4,7 +4,6 @@ import slugify from 'slugify'
import shortid from 'shortid'
import Scrollspy from 'react-scrollspy'
import Scroll from '../../components/Scroll'
import { filterByKindOfProperty } from './utils'
import stylesSidebar from '../../components/Sidebar.module.scss'
export default class Toc extends PureComponent {
@ -14,13 +13,13 @@ export default class Toc extends PureComponent {
subItems = (children, parentName) =>
children &&
children.filter(filterByKindOfProperty).map(({ name, decorators }) => {
children.map(({ name, decorators }) => {
const deprecation = (decorators || []).filter(
({ name }) => name === 'deprecated'
)[0] // Assuming deprecated annotation
return (
<li key={shortid.generate()}>
<li key={name}>
<Scroll
type="id"
element={`${parentName}-${name && slugify(name)}`}
@ -39,7 +38,7 @@ export default class Toc extends PureComponent {
subIds.push(
children &&
children.filter(filterByKindOfProperty).map(({ name }) => {
children.map(({ name }) => {
return `${parentName}-${name && slugify(name)}`
})
)

View File

@ -8,7 +8,6 @@ import HeaderSection from '../../components/HeaderSection'
import Sidebar from '../../components/Sidebar'
import DocHeader from '../../components/DocHeader'
import Seo from '../../components/Seo'
import { cleanTypedocData } from './utils'
import Entities from './Entities'
import Toc from './Toc'
@ -22,11 +21,6 @@ export default class TypedocTemplate extends Component {
pageContext: PropTypes.object.isRequired
}
typedocCleaned = cleanTypedocData(
this.props.pageContext.typedoc,
this.props.pageContext.classes
)
// output section title as defined in sections.yml
sectionTitle = this.props.data.allSectionsYaml.edges.map(({ node }) => {
// compare section against section title from sections.yml
@ -38,8 +32,7 @@ export default class TypedocTemplate extends Component {
render() {
const { location, pageContext } = this.props
const { typedoc } = pageContext
const { info } = typedoc
const { title, description, version, sourceUrl } = info
const { title, description, version, sourceUrl } = typedoc.info
return (
<>
@ -66,7 +59,7 @@ export default class TypedocTemplate extends Component {
sidebar="references"
collapsed
toc
tocComponent={<Toc data={this.typedocCleaned} />}
tocComponent={<Toc data={typedoc.children} />}
/>
</aside>
<article className={stylesDoc.main}>
@ -76,10 +69,7 @@ export default class TypedocTemplate extends Component {
prepend={<span className={stylesDoc.version}>{version}</span>}
/>
<Entities
entities={this.typedocCleaned}
sourceUrl={sourceUrl}
/>
<Entities entities={typedoc.children} sourceUrl={sourceUrl} />
</article>
</main>
</Content>

View File

@ -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
}