mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-11-26 19:49:26 +01:00
Merge branch 'feature/read-the-docs2' into feature/read-the-docs
This commit is contained in:
commit
c620ff37c7
10
.github/workflows/ci.yml
vendored
10
.github/workflows/ci.yml
vendored
@ -16,16 +16,18 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v1
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '14'
|
||||
|
||||
- name: Cache node modules
|
||||
uses: actions/cache@v1
|
||||
uses: actions/cache@v2
|
||||
env:
|
||||
cache-name: cache-node-modules
|
||||
with:
|
||||
path: ~/.npm
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: ${{ runner.os }}-node-
|
||||
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
|
||||
restore-keys: ${{ runner.os }}-build-${{ env.cache-name }}-
|
||||
|
||||
- run: npm ci
|
||||
- run: npm test
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -7,4 +7,5 @@ yarn-error.log
|
||||
.env
|
||||
.env.*
|
||||
markdowns/
|
||||
.vscode/
|
||||
.vscode/
|
||||
size-plugin.json
|
@ -47,3 +47,8 @@
|
||||
items:
|
||||
- title: API Reference
|
||||
link: https://github.com/oceanprotocol/provider-py
|
||||
|
||||
- group: Ocean Subgraph
|
||||
items:
|
||||
- title: Readme References
|
||||
link: /read-the-docs/ocean-subgraph/
|
||||
|
@ -132,7 +132,10 @@ exports.createPages = ({ graphql, actions }) => {
|
||||
|
||||
// API: ocean.js
|
||||
const lastRelease = result.data.oceanJs.repository.releases.edges.filter(
|
||||
({ node }) => !node.isPrerelease && !node.isDraft
|
||||
({ node }) =>
|
||||
!node.isPrerelease &&
|
||||
!node.isDraft &&
|
||||
node.releaseAssets.edges.length > 0
|
||||
)[0].node.releaseAssets.edges[0].node
|
||||
|
||||
await createTypeDocPage(
|
||||
@ -158,10 +161,12 @@ exports.createPages = ({ graphql, actions }) => {
|
||||
const oceanPyList = filterMarkdownList(markdowns, 'ocean.py')
|
||||
const aquariusList = filterMarkdownList(markdowns, 'aquarius')
|
||||
const providerList = filterMarkdownList(markdowns, 'provider')
|
||||
const subgraphList = filterMarkdownList(markdowns, 'ocean-subgraph')
|
||||
|
||||
await createReadTheDocsPage(createPage, 'ocean-py', oceanPyList)
|
||||
await createReadTheDocsPage(createPage, 'aquarius', aquariusList)
|
||||
await createReadTheDocsPage(createPage, 'provider', providerList)
|
||||
await createReadTheDocsPage(createPage, 'ocean-subgraph', subgraphList)
|
||||
|
||||
resolve()
|
||||
})
|
||||
@ -183,39 +188,7 @@ 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: await typedoc.json()
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
|
1465
package-lock.json
generated
1465
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
19
package.json
19
package.json
@ -10,7 +10,7 @@
|
||||
"ssr": "npm run build && serve -s public/",
|
||||
"format": "prettier --ignore-path .gitignore './**/*.{css,scss,yml,js,jsx,ts,tsx,json}' --write",
|
||||
"lint:js": "eslint --ignore-path .gitignore --ignore-path .prettierignore --ext .js,.jsx .",
|
||||
"lint:md": "markdownlint './**/*.{md,markdown}' --ignore './{node_modules,external,public,.cache}/**/*'",
|
||||
"lint:md": "markdownlint './**/*.{md,markdown}' --ignore './{node_modules,external,public,.cache,markdowns}/**/*'",
|
||||
"lint:yml": "prettier '**/*.{yml,yaml}' --list-different",
|
||||
"lint": "run-p --continue-on-error lint:js lint:md lint:yml",
|
||||
"test": "npm run lint"
|
||||
@ -19,21 +19,20 @@
|
||||
"@oceanprotocol/art": "^3.0.0",
|
||||
"axios": "^0.21.1",
|
||||
"classnames": "^2.3.1",
|
||||
"gatsby": "^2.32.12",
|
||||
"gatsby-image": "^3.3.0",
|
||||
"gatsby": "^2.32.13",
|
||||
"gatsby-image": "^3.5.0",
|
||||
"gatsby-plugin-catch-links": "^2.10.0",
|
||||
"gatsby-plugin-manifest": "^2.12.1",
|
||||
"gatsby-plugin-offline": "^3.10.2",
|
||||
"gatsby-plugin-react-helmet": "^3.10.0",
|
||||
"gatsby-plugin-sass": "^3.2.0",
|
||||
"gatsby-plugin-sharp": "^2.14.3",
|
||||
"gatsby-plugin-sharp": "^2.14.4",
|
||||
"gatsby-plugin-sitemap": "^2.12.0",
|
||||
"gatsby-plugin-svgr": "^2.1.0",
|
||||
"gatsby-plugin-webpack-size": "^2.0.1",
|
||||
"gatsby-remark-autolink-headers": "^2.11.0",
|
||||
"gatsby-remark-code-titles": "^1.1.0",
|
||||
"gatsby-remark-component": "^1.1.3",
|
||||
"gatsby-remark-copy-linked-files": "^2.10.0",
|
||||
"gatsby-remark-embed-video": "^3.1.1",
|
||||
"gatsby-remark-github": "^2.0.0",
|
||||
"gatsby-remark-images": "^3.11.1",
|
||||
@ -58,14 +57,14 @@
|
||||
"remark-github-plugin": "^1.4.0",
|
||||
"remark-react": "^8.0.0",
|
||||
"shortid": "^2.2.16",
|
||||
"slugify": "^1.5.0",
|
||||
"slugify": "^1.5.3",
|
||||
"smoothscroll-polyfill": "^0.4.4",
|
||||
"swagger-client": "^3.13.2"
|
||||
"swagger-client": "^3.13.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@svgr/webpack": "^5.5.0",
|
||||
"dotenv": "^8.2.0",
|
||||
"eslint": "^7.25.0",
|
||||
"dotenv": "^10.0.0",
|
||||
"eslint": "^7.27.0",
|
||||
"eslint-config-oceanprotocol": "^1.5.0",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-prettier": "^3.4.0",
|
||||
@ -74,7 +73,7 @@
|
||||
"markdownlint-cli": "^0.27.1",
|
||||
"node-sass": "^5.0.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prettier": "^2.2.1"
|
||||
"prettier": "^2.3.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -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}src/${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}`}
|
||||
{`src/${sources[0].fileName}#L${sources[0].line}`}
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
@ -199,9 +191,9 @@ PropertyWrapper.propTypes = {
|
||||
parentAnchor: PropTypes.string
|
||||
}
|
||||
|
||||
const Entities = ({ entities, sourceUrl }) =>
|
||||
entities.map(({ name, comment, children }) => (
|
||||
<div key={shortid.generate()} id={name && slugify(name)}>
|
||||
const Entities = ({ entities, sourceUrl }) => {
|
||||
return entities.map(({ name, comment, children }) => (
|
||||
<div key={name} id={name && slugify(name)}>
|
||||
<h2 className={styles.entityName}>
|
||||
<code>{name}</code>
|
||||
</h2>
|
||||
@ -213,19 +205,17 @@ 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>
|
||||
))
|
||||
|
||||
}
|
||||
Entities.propTypes = {
|
||||
entities: PropTypes.array.isRequired,
|
||||
sourceUrl: PropTypes.string
|
||||
|
@ -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)}`
|
||||
})
|
||||
)
|
||||
|
@ -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>
|
||||
|
@ -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