You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2020/08/10 02:19:56 UTC

[tomee-site-generator] 02/11: Checks for the Asciidoc content

This is an automated email from the ASF dual-hosted git repository.

dblevins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee-site-generator.git

commit b5405cfea9d2c65cc5673e129bbb28ed540f10c3
Author: David Blevins <da...@gmail.com>
AuthorDate: Sat Aug 8 16:14:11 2020 -0700

    Checks for the Asciidoc content
---
 .../tomee/website/AddAsciidocCodeblocks.java       | 20 +++++++++-
 .../tomee/website/audit/JbakeHeaderHasNoSpace.java | 46 ++++++++++++++++++++++
 2 files changed, 64 insertions(+), 2 deletions(-)

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 org.apache.openejb.util.Join;
 
 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 class AddAsciidocCodeblocks {
 
     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/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());
+            }
+        }
+    }
+}