mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-11-26 19:49:26 +01:00
tinkering
This commit is contained in:
parent
5674d78974
commit
79acdfaee6
@ -145,7 +145,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}/`
|
||||||
|
|
||||||
@ -154,7 +155,8 @@ const createTypeDocPage = async (createPage, name, downloadUrl) => {
|
|||||||
component: typedocTemplate,
|
component: typedocTemplate,
|
||||||
context: {
|
context: {
|
||||||
slug,
|
slug,
|
||||||
typedoc: await typedoc.json()
|
typedoc
|
||||||
|
// typedoc: await typedoc.json()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
3555
ocean.js.json
3555
ocean.js.json
File diff suppressed because it is too large
Load Diff
@ -4,7 +4,6 @@ import slugify from 'slugify'
|
|||||||
import shortid from 'shortid'
|
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'
|
|
||||||
|
|
||||||
const Type = ({ type }) => {
|
const Type = ({ type }) => {
|
||||||
let isArray = false
|
let isArray = false
|
||||||
@ -213,16 +212,14 @@ const Entities = ({ entities, sourceUrl }) =>
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{children &&
|
{children &&
|
||||||
children
|
children.map((property) => (
|
||||||
.filter(filterByKindOfProperty)
|
<PropertyWrapper
|
||||||
.map((property) => (
|
key={shortid.generate()}
|
||||||
<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 {
|
||||||
|
@ -8,15 +8,12 @@ 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'
|
||||||
|
|
||||||
import stylesDoc from '../Doc.module.scss'
|
import stylesDoc from '../Doc.module.scss'
|
||||||
|
|
||||||
import typedocSpecMock from '../../../ocean.js.json'
|
|
||||||
|
|
||||||
export default class TypedocTemplate extends Component {
|
export default class TypedocTemplate extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
data: PropTypes.object.isRequired,
|
data: PropTypes.object.isRequired,
|
||||||
@ -34,9 +31,8 @@ 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 } = typedocSpecMock
|
const { title, description, version, sourceUrl } = typedoc.info
|
||||||
const { title, description, version, sourceUrl } = info
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@ -63,7 +59,7 @@ export default class TypedocTemplate extends Component {
|
|||||||
sidebar="references"
|
sidebar="references"
|
||||||
collapsed
|
collapsed
|
||||||
toc
|
toc
|
||||||
tocComponent={<Toc data={typedocSpecMock.children} />}
|
tocComponent={<Toc data={typedoc.children} />}
|
||||||
/>
|
/>
|
||||||
</aside>
|
</aside>
|
||||||
<article className={stylesDoc.main}>
|
<article className={stylesDoc.main}>
|
||||||
@ -73,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={typedocSpecMock.children}
|
|
||||||
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…
Reference in New Issue
Block a user