+const Entities = ({ entities, sourceUrl }) => {
+ return entities.map(({ name, comment, children }) => (
+
{name}
@@ -213,19 +209,17 @@ const Entities = ({ entities, sourceUrl }) =>
)}
{children &&
- children
- .filter(filterByKindOfProperty)
- .map((property) => (
-
- ))}
+ children.map((property) => (
+
+ ))}
))
-
+}
Entities.propTypes = {
entities: PropTypes.array.isRequired,
sourceUrl: PropTypes.string
diff --git a/src/templates/Typedoc/Toc.jsx b/src/templates/Typedoc/Toc.jsx
index 6845df72..0104a40f 100644
--- a/src/templates/Typedoc/Toc.jsx
+++ b/src/templates/Typedoc/Toc.jsx
@@ -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 (
-
+
{
+ children.map(({ name }) => {
return `${parentName}-${name && slugify(name)}`
})
)
diff --git a/src/templates/Typedoc/index.jsx b/src/templates/Typedoc/index.jsx
index 791c7c5d..caca3988 100644
--- a/src/templates/Typedoc/index.jsx
+++ b/src/templates/Typedoc/index.jsx
@@ -1,92 +1,40 @@
-import React, { Component } from 'react'
-import PropTypes from 'prop-types'
+import React from 'react'
import { graphql } from 'gatsby'
-import { Helmet } from 'react-helmet'
-import Layout from '../../components/Layout'
-import Content from '../../components/Content'
-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 PropTypes from 'prop-types'
import Entities from './Entities'
import Toc from './Toc'
-import stylesDoc from '../Doc.module.scss'
+import ContentWrapperTemplate from '../ContentWrapperTemplate'
-export default class TypedocTemplate extends Component {
- static propTypes = {
- data: PropTypes.object.isRequired,
- location: PropTypes.object.isRequired,
- pageContext: PropTypes.object.isRequired
- }
+export default function TypedocTemplate({ data, path, location, pageContext }) {
+ const { typedoc } = pageContext
+ const { sourceUrl } = typedoc.info
- typedocCleaned = cleanTypedocData(
- this.props.pageContext.typedoc,
- this.props.pageContext.classes
+ return (
+ <>
+ }
+ >
+
+
+ >
)
+}
- // output section title as defined in sections.yml
- sectionTitle = this.props.data.allSectionsYaml.edges.map(({ node }) => {
- // compare section against section title from sections.yml
- if (node.title.toLowerCase().includes('references')) {
- return node.title
- }
- })
-
- render() {
- const { location, pageContext } = this.props
- const { typedoc } = pageContext
- const { info } = typedoc
- const { title, description, version, sourceUrl } = info
-
- return (
- <>
-
-
-
-
-
-
-
-
-
-
-
-
-
- {version}}
- />
-
-
-
-
-
-
- >
- )
- }
+TypedocTemplate.propTypes = {
+ data: PropTypes.object.isRequired,
+ path: PropTypes.string.isRequired,
+ pageContext: PropTypes.shape({
+ slug: PropTypes.string.isRequired,
+ typedoc: PropTypes.object.isRequired
+ }),
+ location: PropTypes.object.isRequired
}
export const TypedocQuery = graphql`
diff --git a/src/templates/Typedoc/utils.js b/src/templates/Typedoc/utils.js
deleted file mode 100644
index 99a49382..00000000
--- a/src/templates/Typedoc/utils.js
+++ /dev/null
@@ -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
-}