1
0
mirror of https://github.com/oceanprotocol/docs.git synced 2024-11-26 19:49:26 +01:00

more generalization for javadoc & typedoc page generation

This commit is contained in:
Matthias Kretschmann 2019-03-29 12:14:44 +01:00
parent 4c564c9ae9
commit 619924a904
Signed by: m
GPG Key ID: 606EEEF3C479A91F

View File

@ -186,51 +186,50 @@ exports.createPages = ({ graphql, actions }) => {
//
// Create pages from swagger json files
//
const swaggerSpecs = [
'./data/aquarius.json',
'./data/brizo.json'
]
const apiSwaggerTemplate = path.resolve(
'./src/templates/Swagger/index.jsx'
)
swaggerSpecs.forEach(spec => {
const api = require(spec) // eslint-disable-line
const name = path
.basename(spec)
.split('.json')
.join('')
const slug = `/references/${name}/`
createPage({
path: slug,
component: apiSwaggerTemplate,
context: {
slug,
api
}
})
})
// Swagger Pet Store example, fetch from remote
const petStoreSlug = '/references/petstore/'
try {
const spec = await getSpec()
const api = await getSpec()
createPage({
path: petStoreSlug,
component: apiSwaggerTemplate,
context: {
slug: petStoreSlug,
api: spec
api
}
})
} catch (error) {
console.log(error)
}
const aquariusSpecs = require('./data/aquarius.json')
const aquariusSlug = '/references/aquarius/'
createPage({
path: aquariusSlug,
component: apiSwaggerTemplate,
context: {
slug: aquariusSlug,
api: aquariusSpecs
}
})
const brizoSpecs = require('./data/brizo.json')
const brizoSlug = '/references/brizo/'
createPage({
path: brizoSlug,
component: apiSwaggerTemplate,
context: {
slug: brizoSlug,
api: brizoSpecs
}
})
//
// Create pages from TypeDoc json files
//
@ -290,15 +289,16 @@ exports.createPages = ({ graphql, actions }) => {
const javadocTemplate = path.resolve(
'./src/templates/Javadoc/index.jsx'
)
const { name, pom } = result.data.squidJava.repository
const metaSquidJava = parser.xml2js(pom.text, {
compact: true
})
javadocSpecs.forEach(spec => {
const javadoc = require(spec) // eslint-disable-line
const { name, pom } = result.data.squidJava.repository
const slug = `/references/${name}/`
const metaSquidJava = parser.xml2js(pom.text, {
compact: true
})
const { project } = metaSquidJava
createPage({
path: slug,
@ -307,13 +307,13 @@ exports.createPages = ({ graphql, actions }) => {
slug,
javadoc,
title: name,
description: `${
metaSquidJava.project.name._text
}. ${metaSquidJava.project.description._text}.`,
version: metaSquidJava.project.version._text,
namespace: `${
metaSquidJava.project.groupId._text
}.${metaSquidJava.project.artifactId._text}`
description: `${project.name._text}. ${
project.description._text
}.`,
version: project.version._text,
namespace: `${project.groupId._text}.${
project.artifactId._text
}`
}
})
})