Skip to content

Commit

Permalink
docs: parameterizable maven-plugin documentation generated
Browse files Browse the repository at this point in the history
  • Loading branch information
manusa committed May 6, 2020
1 parent 01e78e6 commit 65899c6
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 13 deletions.
25 changes: 23 additions & 2 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ const config = {
remote: 'https://github.com/eclipse/jkube.git',
branch: `v${latestJKubeVersion}`,
patterns: [
'kubernetes-maven-plugin/doc/**/index.adoc',
'openshift-maven-plugin/doc/**/index.adoc'
'kubernetes-maven-plugin/doc/**/index.adoc'
]
}
},
Expand All @@ -42,6 +41,28 @@ const config = {
}
}
},
{
resolve: 'gatsby-transformer-asciidoc',
options: {
safe: 'unsafe',
attributes: {
plugin: 'kubernetes-maven-plugin',
version: latestJKubeVersion,
'goal-prefix': 'k8s'
}
}
},
{
resolve: 'gatsby-transformer-asciidoc',
options: {
safe: 'unsafe',
attributes: {
plugin: 'openshift-maven-plugin',
version: latestJKubeVersion,
'goal-prefix': 'oc'
}
}
},
{
resolve: 'gatsby-transformer-remark',
options: {
Expand Down
35 changes: 33 additions & 2 deletions gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,33 @@ const {defaultLangKey} = require('./src/i18n');
const mainTemplate = path.resolve('src', 'templates', 'main.jsx');
const docTemplate = path.resolve('src', 'templates', 'doc.jsx');

/**
* Duplicates any node created with Asciidoc transformer plugin
*
* We are currently using 2 'gatsby-transformer-asciidoc' plugins with different attributes in order to generate
* documentation for openshift-maven-plugin and kubernetes-maven-plugin with a single set of asciidocs.
*
* As the node.id calculated for both documentation nodes is the same (id: createNodeId(`${node.id} >>> ASCIIDOC`),)
* the id collides and only the second node created survives.
*
* This method will create a copy with unique id per document.title for each Asciidoc node generated.
* We'll use this instead for documentation generation.
*/
const duplicateAsciiNodes = ({node, actions: {createNode}, createNodeId, createContentDigest}) => {
if (node.internal.type === 'Asciidoc') {
const duplicateAsciiNode = {...node,
id: createNodeId(`${node.id}- ${node.document.title}`),
parent: null,
internal: {
type: 'AsciidocCopy',
mediaType: 'text/html'
}
};
duplicateAsciiNode.internal.contentDigest = createContentDigest(duplicateAsciiNode);
createNode(duplicateAsciiNode);
}
};

const createMarkdownPages = async ({createPage, graphql, reporter}) => {
const result = await graphql(`
{
Expand Down Expand Up @@ -46,7 +73,7 @@ const createMarkdownPages = async ({createPage, graphql, reporter}) => {
const createAsciiDocPages = async({createPage, graphql, reporter}) => {
const result = await graphql(`
{
allAsciidoc {
allAsciidocCopy {
edges {
node {
id
Expand All @@ -65,7 +92,7 @@ const createAsciiDocPages = async({createPage, graphql, reporter}) => {
reporter.panicOnBuild('Error while running GraphQL query for Asciidoc pages.');
return;
}
result.data.allAsciidoc.edges.forEach(({ node }) => {
result.data.allAsciidocCopy.edges.forEach(({ node }) => {
const slug = `/docs/${node.document.title.replace(/(.*\/)?/, '')}`;
createPage({
path: slug,
Expand All @@ -83,3 +110,7 @@ exports.createPages = async ({actions, graphql, reporter}) => {
await createMarkdownPages({createPage, graphql, reporter});
await createAsciiDocPages({createPage, graphql, reporter});
};

exports.onCreateNode = createNodeArgs => {
duplicateAsciiNodes(createNodeArgs);
};
33 changes: 28 additions & 5 deletions src/pages/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,36 @@ available examples for your favourite framework or vanilla Java.
## Javadoc

### JKube Kit
* **Common** model objects and utility classes used across the rest of the modules.
[![Javadocs](http://www.javadoc.io/badge/org.eclipse.jkube/jkube-kit-common.svg?color=blue)
](http://www.javadoc.io/doc/org.eclipse.jkube/jkube-kit-common)
* **Build API** model objects and interfaces for image building.
[![Javadocs](http://www.javadoc.io/badge/org.eclipse.jkube/jkube-kit-build-api.svg?color=blue)
](http://www.javadoc.io/doc/org.eclipse.jkube/jkube-kit-build-api)
* **Build Service Docker**
[![Javadocs](http://www.javadoc.io/badge/org.eclipse.jkube/jkube-kit-build-service-docker.svg?color=blue)
](http://www.javadoc.io/doc/org.eclipse.jkube/jkube-kit-build-service-docker)
* **Image configuration** model objects for modeling Docker image configuration as used in docker-maven-plugin.
[![Javadocs](http://www.javadoc.io/badge/org.eclipse.jkube/jkube-kit-config-image.svg?color=blue)](http://www.javadoc.io/doc/org.eclipse.jkube/jkube-kit-config-image)
[![Javadocs](http://www.javadoc.io/badge/org.eclipse.jkube/jkube-kit-config-image.svg?color=blue)
](http://www.javadoc.io/doc/org.eclipse.jkube/jkube-kit-config-image)
* **Resource configuration** model objects for a simplified configuration of Kubernetes and OpenShift resources.
[![Javadocs](http://www.javadoc.io/badge/org.eclipse.jkube/jkube-kit-config-resource.svg?color=blue)](http://www.javadoc.io/doc/org.eclipse.jkube/jkube-kit-config-resource)
[![Javadocs](http://www.javadoc.io/badge/org.eclipse.jkube/jkube-kit-config-resource.svg?color=blue)
](http://www.javadoc.io/doc/org.eclipse.jkube/jkube-kit-config-resource)
* **Service configuration**
[![Javadocs](http://www.javadoc.io/badge/org.eclipse.jkube/jkube-kit-config-service.svg?color=blue)
](http://www.javadoc.io/doc/org.eclipse.jkube/jkube-kit-config-service)
* **Generator** framework for automatically generating Docker images by examining project information.
[![Javadocs](http://www.javadoc.io/badge/org.eclipse.jkube/jkube-kit-generator-api.svg?color=blue)](http://www.javadoc.io/doc/org.eclipse.jkube/jkube-kit-generator-api)
[![Javadocs](http://www.javadoc.io/badge/org.eclipse.jkube/jkube-kit-generator-api.svg?color=blue)
](http://www.javadoc.io/doc/org.eclipse.jkube/jkube-kit-generator-api)
* **Enricher** framework for creating and enhancing Kubernetes and OpenShift resources.
[![Javadocs](http://www.javadoc.io/badge/org.eclipse.jkube/jkube-kit-enricher-api.svg?color=blue)](http://www.javadoc.io/doc/org.eclipse.jkube/jkube-kit-enricher-api)
[![Javadocs](http://www.javadoc.io/badge/org.eclipse.jkube/jkube-kit-enricher-api.svg?color=blue)
](http://www.javadoc.io/doc/org.eclipse.jkube/jkube-kit-enricher-api)
* **Helm**
[![Javadocs](http://www.javadoc.io/badge/org.eclipse.jkube/jkube-kit-resource-helm.svg?color=blue)
](http://www.javadoc.io/doc/org.eclipse.jkube/jkube-kit-resource-helm)
* **Profile** combining the configuration for generators and enrichers.
[![Javadocs](http://www.javadoc.io/badge/org.eclipse.jkube/jkube-kit-profiles.svg?color=blue)](http://www.javadoc.io/doc/org.eclipse.jkube/jkube-kit-profiles)
[![Javadocs](http://www.javadoc.io/badge/org.eclipse.jkube/jkube-kit-profiles.svg?color=blue)
](http://www.javadoc.io/doc/org.eclipse.jkube/jkube-kit-profiles)
* **Common Maven** utility classes for Maven plugins.
[![Javadocs](http://www.javadoc.io/badge/org.eclipse.jkube/jkube-kit-common-maven.svg?color=blue)
](http://www.javadoc.io/doc/org.eclipse.jkube/jkube-kit-common-maven-maven)
6 changes: 4 additions & 2 deletions src/pages/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ This project focus on two tasks: Building Docker images and creating Kubernetes

You can get Eclipse JKube from these platforms:

[![Maven Central](https://img.shields.io/maven-central/v/org.eclipse.jkube/jkube.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22org.eclipse.jkube%22%20AND%20a:%22jkube%22)
[![Eclipse Download Repository](https://img.shields.io/badge/eclipse%20downloads-downloads.eclipse.org-red)](https://download.eclipse.org/jkube/)
[![Maven Central](https://img.shields.io/maven-central/v/org.eclipse.jkube/jkube.svg?label=Maven%20Central)
](https://search.maven.org/search?q=g:%22org.eclipse.jkube%22)
[![Eclipse Download Repository](https://img.shields.io/badge/eclipse%20downloads-downloads.eclipse.org-red)
](https://download.eclipse.org/jkube/)

</div>
4 changes: 2 additions & 2 deletions src/templates/doc.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const componentDidMount = () => {

const Doc = ({
data: {
asciidoc: {
asciidocCopy: {
document: {
title,
subtitle
Expand Down Expand Up @@ -43,7 +43,7 @@ const Doc = ({

export const pageQuery = graphql`
query($id: String!) {
asciidoc(id: { eq: $id }) {
asciidocCopy(id: { eq: $id }) {
html
document {
title
Expand Down

0 comments on commit 65899c6

Please sign in to comment.