Merge branch 'master' of github.com:apache/tomee-site-generator
diff --git a/src/main/java/org/apache/tomee/website/AddAsciidocCodeblocks.java b/src/main/java/org/apache/tomee/website/AddAsciidocCodeblocks.java
index bb5fa3c..6856dc2 100644
--- a/src/main/java/org/apache/tomee/website/AddAsciidocCodeblocks.java
+++ b/src/main/java/org/apache/tomee/website/AddAsciidocCodeblocks.java
@@ -21,6 +21,7 @@
import java.io.File;
import java.io.IOException;
+import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
@@ -35,16 +36,31 @@
public static void main(String[] args) throws Exception {
- final File docs = new File("repos/tomee-8.0/docs/");
+ final File docs = new File("repos/master/examples/");
Files.walk(docs.toPath())
.map(Path::toFile)
.filter(File::isFile)
.filter(path -> path.getName().endsWith(".adoc"))
- .forEach(AddAsciidocCodeblocks::process);
+ .peek(AddAsciidocCodeblocks::process)
+ .forEach(AddAsciidocCodeblocks::fixLanguage);
+ ;
}
+ private static void fixLanguage(final File file) {
+ try {
+ String contents = IO.slurp(file);
+
+ contents = contents.replace("[source,java]\n----\n<", "[source,xml]\n----\n<");
+ contents = contents.replace("[source,java]\n----\n----", "[source,console]\n----\n----");
+
+ IO.copy(IO.read(contents), file);
+ } catch (IOException e) {
+ throw new UncheckedIOException("Failed to process file: " + file.getAbsolutePath(), e);
+ }
+ }
+
public static void process(final File destReadme) {
final AddAsciidocCodeblocks fix = new AddAsciidocCodeblocks();
diff --git a/src/main/java/org/apache/tomee/website/GroupedIndex.java b/src/main/java/org/apache/tomee/website/GroupedIndex.java
index ab309a7..45bdab6 100644
--- a/src/main/java/org/apache/tomee/website/GroupedIndex.java
+++ b/src/main/java/org/apache/tomee/website/GroupedIndex.java
@@ -27,7 +27,15 @@
import java.io.PrintStream;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
import java.util.stream.Collectors;
public class GroupedIndex {
@@ -67,22 +75,22 @@
final Map<String, List<Doc>> sections = new HashMap<>();
//filtering only documents with the same language for: target/jbake/<tomeeBranch>/docs
- if(this.type.equalsIgnoreCase("docsindex")){
+ if (this.type.equalsIgnoreCase("docsindex")) {
for (Doc doc1 : docs) {
if (doc1.language.equalsIgnoreCase(language)) {
sections.computeIfAbsent(doc1.getGroup(), k -> new ArrayList<>()).add(doc1);
}
}
- }else{
+ } else {
- if(this.type.equalsIgnoreCase("examplesindex")){
+ if (this.type.equalsIgnoreCase("examplesindex")) {
for (Doc doc1 : docs) { //filtering only documents with the same language for: target/jbake/<tomeeBranch> and type = examplesindex
if (doc1.language.equalsIgnoreCase(language) && doc1.source.getParentFile().getName().equalsIgnoreCase("examples")) {
sections.computeIfAbsent(doc1.getGroup(), k -> new ArrayList<>()).add(doc1);
}
}
- }else{//any type (used in GroupedIndexTest.java
+ } else {//any type (used in GroupedIndexTest.java
for (Doc doc1 : docs) {
if (doc1.language.equalsIgnoreCase(language)) {
sections.computeIfAbsent(doc1.getGroup(), k -> new ArrayList<>()).add(doc1);
@@ -156,9 +164,9 @@
out.printf(" </div>\n");
final ListIterator<Doc> iterator = entry.getValue().stream()
- .sorted()
- .collect(Collectors.toList())
- .listIterator();
+ .sorted()
+ .collect(Collectors.toList())
+ .listIterator();
final int i = (int) Math.ceil(entry.getValue().size() / 3f);
@@ -190,17 +198,17 @@
try {
File fileParentFolder = null;
- if(type.equalsIgnoreCase("docsindex")){
+ if (type.equalsIgnoreCase("docsindex")) {
fileParentFolder = new File(directory);
- }else {
- if(type.equalsIgnoreCase("examplesindex")){
- if(language.equalsIgnoreCase("en")){
- fileParentFolder = new File(directory + File.separator + "examples");
- }else{
- fileParentFolder = new File(directory + File.separator + language + File.separator + "examples");
+ } else {
+ if (type.equalsIgnoreCase("examplesindex")) {
+ if (language.equalsIgnoreCase("en")) {
+ fileParentFolder = new File(directory + File.separator + "examples");
+ } else {
+ fileParentFolder = new File(directory + File.separator + language + File.separator + "examples");
}
- }else{
+ } else {
fileParentFolder = new File(directory);
}
}
@@ -214,24 +222,24 @@
public List<Doc> list(final File directory) {//target/jbake/<tomeeBranch>
try {
return Files.walk(directory.toPath())
- .map(Path::toFile)
- .filter(File::isFile)
- .filter(Docs::isRendered)
- .map(this::parse)
- .collect(Collectors.toList());
+ .map(Path::toFile)
+ .filter(File::isFile)
+ .filter(Docs::isRendered)
+ .map(this::parse)
+ .collect(Collectors.toList());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
private static String getLanguageFromPath(File file, String type) { //target/jbake/<tomeeBranch>/fr/examples/index.html
- if(type.equalsIgnoreCase("docsindex")){ //ToDo: this needs to be updated when we are going to proccess docs internationalization too.
+ if (type.equalsIgnoreCase("docsindex")) { //ToDo: this needs to be updated when we are going to proccess docs internationalization too.
return "";
- }else { //examplesindex
+ } else { //examplesindex
- if(file.getParentFile().getParentFile().getName().length() > 3){ // target/jbake/<tomeeBranchLengthIsGratherThan3>/examples/index.html
+ if (file.getParentFile().getParentFile().getName().length() > 3) { // target/jbake/<tomeeBranchLengthIsGratherThan3>/examples/index.html
return "en";
- }else{
+ } else {
return file.getParentFile().getParentFile().getName(); // target/jbake/<tomeeBranch>/fr/examples/index.html
}
@@ -260,12 +268,12 @@
*/
if (type.equalsIgnoreCase("examplesindex") && file.getParentFile().getName().equalsIgnoreCase("examples")) {
- String detectedLanguage = getLanguageFromPath(file,this.type);
+ String detectedLanguage = getLanguageFromPath(file, this.type);
- if(detectedLanguage.equalsIgnoreCase("en")){
- return new Doc(group, title, Docs.href(new File (directory + File.separator + "examples"), file), file, detectedLanguage);
- }else{
- return new Doc(group, title, Docs.href(new File (directory + File.separator + detectedLanguage + File.separator + "examples"), file), file, detectedLanguage);
+ if (detectedLanguage.equalsIgnoreCase("en")) {
+ return new Doc(group, title, Docs.href(new File(directory + File.separator + "examples"), file), file, detectedLanguage);
+ } else {
+ return new Doc(group, title, Docs.href(new File(directory + File.separator + detectedLanguage + File.separator + "examples"), file), file, detectedLanguage);
}
} else {
diff --git a/src/main/java/org/apache/tomee/website/audit/JbakeHeaderHasNoSpace.java b/src/main/java/org/apache/tomee/website/audit/JbakeHeaderHasNoSpace.java
new file mode 100644
index 0000000..61a00be
--- /dev/null
+++ b/src/main/java/org/apache/tomee/website/audit/JbakeHeaderHasNoSpace.java
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomee.website.audit;
+
+import org.apache.openejb.loader.IO;
+import org.tomitribe.tio.Dir;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * The Jbake header in asciidoc form cannot have a space
+ * after the title.
+ */
+public class JbakeHeaderHasNoSpace {
+
+ public static void main(String[] args) throws IOException {
+ final Dir dir = Dir.from(new File("/Users/dblevins/work/apache/tomee-site-generator/repos/master"));
+ final List<File> files = dir.searchFiles()
+ .filter(file -> file.getName().endsWith(".adoc"))
+ .collect(Collectors.toList());
+ for (final File file : files) {
+ final String contents = IO.slurp(file);
+ final String[] lines = contents.split("\n");
+ if ("".equals(lines[1])) {
+ System.out.println(file.getAbsolutePath());
+ }
+ }
+ }
+}