1
0
mirror of https://github.com/oceanprotocol/docs.git synced 2024-06-29 00:58:02 +02:00

output params, returns, throws

This commit is contained in:
Matthias Kretschmann 2019-03-27 14:03:53 +01:00
parent 34fb7be091
commit 524ead7d18
Signed by: m
GPG Key ID: 606EEEF3C479A91F
3 changed files with 81 additions and 26 deletions

View File

@ -26,15 +26,15 @@
"@oceanprotocol/art": "^2.2.0", "@oceanprotocol/art": "^2.2.0",
"axios": "^0.18.0", "axios": "^0.18.0",
"classnames": "^2.2.6", "classnames": "^2.2.6",
"gatsby": "^2.2.8", "gatsby": "^2.3.2",
"gatsby-image": "^2.0.34", "gatsby-image": "^2.0.35",
"gatsby-plugin-catch-links": "^2.0.13", "gatsby-plugin-catch-links": "^2.0.13",
"gatsby-plugin-google-analytics": "^2.0.17", "gatsby-plugin-google-analytics": "^2.0.18",
"gatsby-plugin-manifest": "^2.0.24", "gatsby-plugin-manifest": "^2.0.24",
"gatsby-plugin-offline": "^2.0.25", "gatsby-plugin-offline": "^2.0.25",
"gatsby-plugin-react-helmet": "^3.0.10", "gatsby-plugin-react-helmet": "^3.0.11",
"gatsby-plugin-sass": "^2.0.11", "gatsby-plugin-sass": "^2.0.11",
"gatsby-plugin-sharp": "^2.0.30", "gatsby-plugin-sharp": "^2.0.31",
"gatsby-plugin-sitemap": "^2.0.10", "gatsby-plugin-sitemap": "^2.0.10",
"gatsby-plugin-svgr": "^2.0.2", "gatsby-plugin-svgr": "^2.0.2",
"gatsby-remark-autolink-headers": "^2.0.16", "gatsby-remark-autolink-headers": "^2.0.16",
@ -51,13 +51,13 @@
"gatsby-transformer-remark": "^2.3.8", "gatsby-transformer-remark": "^2.3.8",
"gatsby-transformer-sharp": "^2.1.17", "gatsby-transformer-sharp": "^2.1.17",
"gatsby-transformer-xml": "^2.0.9", "gatsby-transformer-xml": "^2.0.9",
"gatsby-transformer-yaml": "^2.1.10", "gatsby-transformer-yaml": "^2.1.11",
"giphy-js-sdk-core": "^1.0.6", "giphy-js-sdk-core": "^1.0.6",
"intersection-observer": "^0.5.1", "intersection-observer": "^0.5.1",
"node-sass": "^4.11.0", "node-sass": "^4.11.0",
"prismjs": "^1.15.0", "prismjs": "^1.16.0",
"react": "^16.8.4", "react": "^16.8.5",
"react-dom": "^16.8.4", "react-dom": "^16.8.5",
"react-helmet": "^5.2.0", "react-helmet": "^5.2.0",
"react-scrollspy": "^3.4.0", "react-scrollspy": "^3.4.0",
"rehype-react": "^3.1.0", "rehype-react": "^3.1.0",
@ -65,7 +65,7 @@
"remark-github-plugin": "^1.3.1", "remark-github-plugin": "^1.3.1",
"remark-react": "^5.0.1", "remark-react": "^5.0.1",
"slugify": "^1.3.4", "slugify": "^1.3.4",
"smoothscroll-polyfill": "^0.4.3", "smoothscroll-polyfill": "^0.4.4",
"swagger-client": "^3.8.25" "swagger-client": "^3.8.25"
}, },
"devDependencies": { "devDependencies": {
@ -75,7 +75,7 @@
"eslint-config-oceanprotocol": "^1.3.0", "eslint-config-oceanprotocol": "^1.3.0",
"eslint-config-prettier": "^4.1.0", "eslint-config-prettier": "^4.1.0",
"eslint-plugin-prettier": "^3.0.1", "eslint-plugin-prettier": "^3.0.1",
"markdownlint-cli": "^0.14.0", "markdownlint-cli": "^0.14.1",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"ora": "^3.2.0", "ora": "^3.2.0",
"prettier": "^1.16.4", "prettier": "^1.16.4",

View File

@ -10,11 +10,43 @@ 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 stylesDoc from '../Doc.module.scss' import stylesDoc from '../Doc.module.scss'
import styles from './index.module.scss'
import Toc from './Toc' import Toc from './Toc'
import { cleanPaths } from './utils' import { cleanPaths } from './utils'
const Paths = ({ javadoc }) => { const filterPropertyItems = (item, name) => {
let title
switch (name) {
case '@param':
title = 'Parameters'
break
case '@return':
title = 'Returns'
break
case '@throws':
title = 'Throws'
break
}
return (
<>
{item.filter(item => item.name === name).length > 0 && (
<h4 className={styles.subHeading}>{title}</h4>
)}
{item
.filter(item => item.name === name)
.map((item, index) => (
<div key={index}>
<code>{item.text}</code>
</div>
))}
</>
)
}
const Entities = ({ javadoc }) => {
return Object.entries(javadoc).map(([key, value]) => ( return Object.entries(javadoc).map(([key, value]) => (
<div <div
key={key} key={key}
@ -26,23 +58,23 @@ const Paths = ({ javadoc }) => {
<code>{cleanPaths(key)}</code> <code>{cleanPaths(key)}</code>
</h2> </h2>
{value[0][0].text} <p>{value[0][0].text}</p>
<h4>Parameters</h4> {value.map((item, index) => {
if (index === 0) return
{/* return (
{value <div key={index} className={styles.property}>
.filter(item => { <h3 className={styles.propertyName}>Function Name</h3>
return item.name === '@param'
})
.map(item => {
return item.text
})}
*/}
<h4>Returns</h4> <p>{item[0].text}</p>
<h4>Throws</h4> {filterPropertyItems(item, '@param')}
{filterPropertyItems(item, '@return')}
{filterPropertyItems(item, '@throws')}
</div>
)
})}
</div> </div>
)) ))
} }
@ -104,7 +136,7 @@ export default class JavadocTemplate extends Component {
} }
/> />
<Paths javadoc={javadoc} /> <Entities javadoc={javadoc} />
</article> </article>
</main> </main>
</Content> </Content>

View File

@ -0,0 +1,23 @@
@import 'variables';
.property {
padding: $spacer / 2;
border: 1px solid $brand-grey-lighter;
margin-bottom: $spacer;
border-radius: $border-radius;
}
.subHeading {
font-size: $font-size-base;
border-bottom: 1px solid $brand-grey-lighter;
padding-bottom: $spacer / 4;
margin-bottom: $spacer / 4;
color: $brand-grey;
}
.propertyName {
font-size: $font-size-large;
font-family: $font-family-monospace;
margin-bottom: $spacer / 2;
margin-top: 0;
}