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:
parent
4c564c9ae9
commit
619924a904
@ -186,51 +186,50 @@ exports.createPages = ({ graphql, actions }) => {
|
|||||||
//
|
//
|
||||||
// Create pages from swagger json files
|
// Create pages from swagger json files
|
||||||
//
|
//
|
||||||
|
const swaggerSpecs = [
|
||||||
|
'./data/aquarius.json',
|
||||||
|
'./data/brizo.json'
|
||||||
|
]
|
||||||
const apiSwaggerTemplate = path.resolve(
|
const apiSwaggerTemplate = path.resolve(
|
||||||
'./src/templates/Swagger/index.jsx'
|
'./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/'
|
const petStoreSlug = '/references/petstore/'
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const spec = await getSpec()
|
const api = await getSpec()
|
||||||
|
|
||||||
createPage({
|
createPage({
|
||||||
path: petStoreSlug,
|
path: petStoreSlug,
|
||||||
component: apiSwaggerTemplate,
|
component: apiSwaggerTemplate,
|
||||||
context: {
|
context: {
|
||||||
slug: petStoreSlug,
|
slug: petStoreSlug,
|
||||||
api: spec
|
api
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(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
|
// Create pages from TypeDoc json files
|
||||||
//
|
//
|
||||||
@ -290,15 +289,16 @@ exports.createPages = ({ graphql, actions }) => {
|
|||||||
const javadocTemplate = path.resolve(
|
const javadocTemplate = path.resolve(
|
||||||
'./src/templates/Javadoc/index.jsx'
|
'./src/templates/Javadoc/index.jsx'
|
||||||
)
|
)
|
||||||
const { name, pom } = result.data.squidJava.repository
|
|
||||||
|
|
||||||
const metaSquidJava = parser.xml2js(pom.text, {
|
|
||||||
compact: true
|
|
||||||
})
|
|
||||||
|
|
||||||
javadocSpecs.forEach(spec => {
|
javadocSpecs.forEach(spec => {
|
||||||
const javadoc = require(spec) // eslint-disable-line
|
const javadoc = require(spec) // eslint-disable-line
|
||||||
|
|
||||||
|
const { name, pom } = result.data.squidJava.repository
|
||||||
const slug = `/references/${name}/`
|
const slug = `/references/${name}/`
|
||||||
|
const metaSquidJava = parser.xml2js(pom.text, {
|
||||||
|
compact: true
|
||||||
|
})
|
||||||
|
const { project } = metaSquidJava
|
||||||
|
|
||||||
createPage({
|
createPage({
|
||||||
path: slug,
|
path: slug,
|
||||||
@ -307,13 +307,13 @@ exports.createPages = ({ graphql, actions }) => {
|
|||||||
slug,
|
slug,
|
||||||
javadoc,
|
javadoc,
|
||||||
title: name,
|
title: name,
|
||||||
description: `${
|
description: `${project.name._text}. ${
|
||||||
metaSquidJava.project.name._text
|
project.description._text
|
||||||
}. ${metaSquidJava.project.description._text}.`,
|
}.`,
|
||||||
version: metaSquidJava.project.version._text,
|
version: project.version._text,
|
||||||
namespace: `${
|
namespace: `${project.groupId._text}.${
|
||||||
metaSquidJava.project.groupId._text
|
project.artifactId._text
|
||||||
}.${metaSquidJava.project.artifactId._text}`
|
}`
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user