-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the ability to dump all the documentation as a dataset
- this includes patterns, languages and data formats
- Loading branch information
Showing
5 changed files
with
83 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
# Based on https://tinyapps.org/blog/201701240700_convert_asciidoc_to_markdown.html | ||
|
||
simpleName=$(basename $1) | ||
inputFile=$1 | ||
xmlFile=${inputFile/.adoc/.xml} | ||
markDownFile=${inputFile/.adoc/.md} | ||
|
||
logDir=$2 | ||
log=$logDir/$simpleName.log | ||
|
||
printf "AsciiDoc to XML conversion for %s\n" "${simpleName}" | ||
asciidoc -b docbook "${inputFile}" > "$log" 2>&1 | ||
if [ $? -ne 0 ] ; then | ||
printf "Failed AsciiDoc to XML conversion for %s\n" "${inputFile}" | tee -a "$log" | ||
fi | ||
|
||
printf "XML to Markdown conversion for %s\n" "${simpleName}" | ||
pandoc -f docbook -t markdown_strict "${xmlFile}" -o "${markDownFile}" >> "$log" 2>&1 | ||
if [ $? -ne 0 ] ; then | ||
printf "Failed XML to Markdown conversion for %s\n" "$1" | tee -a "$log" | ||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
#!/bin/bash | ||
|
||
CODE_DIR=${1:-"$HOME/code/java/camel}"} | ||
install_path=$(dirname "$0") | ||
|
||
# Based on https://tinyapps.org/blog/201701240700_convert_asciidoc_to_markdown.html | ||
logDir=$(mktemp -d) | ||
|
||
# Step 1: convert all component documentation to a docbook file | ||
find $CODE_DIR -type f -iname '*-component.adoc' -ipath '*src/main/docs*' -exec asciidoc -b docbook {} \; | ||
|
||
# Step 2: convert the docbook files to Markdown | ||
find $CODE_DIR -type f -iname '*-component.xml' -ipath '*src/main/docs*' -exec pandoc -f docbook -t markdown_strict {} -o {}.md \; | ||
find "$CODE_DIR" -type f -iname '*.adoc' -ipath '*src/main/docs*' -exec "${install_path}"/convert-file.sh {} "$logDir" \; | tee $logDir/conversion.log | ||
|
||
numDocs=$(find "$CODE_DIR" -type f -iname '*.adoc' -ipath '*src/main/docs*' | wc -l) | ||
numConverted=$(find "$CODE_DIR" -type f -iname '*.xml' -ipath '*src/main/docs*' | wc -l) | ||
printf "Conversion complete. Checking results: converted %s of %s\n" "$numConverted" "$numDocs" | ||
printf "Check %s for results and failures" "$logDir/conversion.log" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/org/apache/camel/jbang/ai/data/documentation/GenericDocumentationVisitor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.apache.camel.jbang.ai.data.documentation; | ||
|
||
import org.apache.camel.catalog.CamelCatalog; | ||
import org.apache.camel.util.StringHelper; | ||
import org.commonmark.node.AbstractVisitor; | ||
import org.commonmark.node.Document; | ||
import org.commonmark.node.Heading; | ||
import org.commonmark.node.Text; | ||
|
||
public class GenericDocumentationVisitor extends AbstractVisitor { | ||
private final CamelCatalog catalog; | ||
private final String componentName; | ||
|
||
public GenericDocumentationVisitor(CamelCatalog catalog, String componentName) { | ||
this.catalog = catalog; | ||
this.componentName = componentName; | ||
} | ||
|
||
@Override | ||
public void visit(Document document) { | ||
super.visit(document); | ||
|
||
final Heading title = new Heading(); | ||
|
||
title.setLevel(1); | ||
Text text = new Text(StringHelper.capitalize(componentName)); | ||
title.appendChild(text); | ||
|
||
document.prependChild(title); | ||
} | ||
} |