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) => {
|
||||
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}/`
|
||||
|
||||
@ -154,7 +155,8 @@ const createTypeDocPage = async (createPage, name, downloadUrl) => {
|
||||
component: typedocTemplate,
|
||||
context: {
|
||||
slug,
|
||||
typedoc: await typedoc.json()
|
||||
typedoc
|
||||
// typedoc: await typedoc.json()
|
||||
}
|
||||
})
|
||||
} 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 Scroll from '../../components/Scroll'
|
||||
import styles from './Entities.module.scss'
|
||||
import { filterByKindOfProperty } from './utils'
|
||||
|
||||
const Type = ({ type }) => {
|
||||
let isArray = false
|
||||
@ -213,16 +212,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={shortid.generate()}
|
||||
property={property}
|
||||
sourceUrl={sourceUrl}
|
||||
parentAnchor={name && slugify(name)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
))
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -8,15 +8,12 @@ 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'
|
||||
|
||||
import stylesDoc from '../Doc.module.scss'
|
||||
|
||||
import typedocSpecMock from '../../../ocean.js.json'
|
||||
|
||||
export default class TypedocTemplate extends Component {
|
||||
static propTypes = {
|
||||
data: PropTypes.object.isRequired,
|
||||
@ -34,9 +31,8 @@ export default class TypedocTemplate extends Component {
|
||||
|
||||
render() {
|
||||
const { location, pageContext } = this.props
|
||||
// const { typedoc } = pageContext
|
||||
const { info } = typedocSpecMock
|
||||
const { title, description, version, sourceUrl } = info
|
||||
const { typedoc } = pageContext
|
||||
const { title, description, version, sourceUrl } = typedoc.info
|
||||
|
||||
return (
|
||||
<>
|
||||
@ -63,7 +59,7 @@ export default class TypedocTemplate extends Component {
|
||||
sidebar="references"
|
||||
collapsed
|
||||
toc
|
||||
tocComponent={<Toc data={typedocSpecMock.children} />}
|
||||
tocComponent={<Toc data={typedoc.children} />}
|
||||
/>
|
||||
</aside>
|
||||
<article className={stylesDoc.main}>
|
||||
@ -73,10 +69,7 @@ export default class TypedocTemplate extends Component {
|
||||
prepend={<span className={stylesDoc.version}>{version}</span>}
|
||||
/>
|
||||
|
||||
<Entities
|
||||
entities={typedocSpecMock.children}
|
||||
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…
Reference in New Issue
Block a user