openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmannibu...@apache.org
Subject svn commit: r1766736 - in /openwebbeans/microwave/trunk/microwave-doc: ./ src/main/java/org/apache/microwave/doc/ src/main/java/org/apache/microwave/doc/generator/ src/main/jbake/content/microwave-core/
Date Wed, 26 Oct 2016 21:12:36 GMT
Author: rmannibucau
Date: Wed Oct 26 21:12:35 2016
New Revision: 1766736

URL: http://svn.apache.org/viewvc?rev=1766736&view=rev
Log:
few more doc - cli and basic config

Added:
    openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/generator/
    openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/generator/BaseGenerator.java
    openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/generator/CliConfiguration.java
    openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/generator/Configuration.java
Modified:
    openwebbeans/microwave/trunk/microwave-doc/pom.xml
    openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/JBake.java
    openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/PDFify.java
    openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-core/cli.adoc
    openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-core/configuration.adoc

Modified: openwebbeans/microwave/trunk/microwave-doc/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-doc/pom.xml?rev=1766736&r1=1766735&r2=1766736&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-doc/pom.xml (original)
+++ openwebbeans/microwave/trunk/microwave-doc/pom.xml Wed Oct 26 21:12:35 2016
@@ -34,7 +34,7 @@
 
   <properties>
     <jbake.http>false</jbake.http>
-    <jbake.pdf>false</jbake.pdf>
+    <jbake.pdf>true</jbake.pdf>
 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
   </properties>
@@ -51,6 +51,16 @@
       <version>1.5.4</version>
     </dependency>
     <dependency>
+      <groupId>org.jruby</groupId>
+      <artifactId>jruby-complete</artifactId>
+      <version>1.7.24</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.tomee</groupId>
+      <artifactId>ziplock</artifactId>
+      <version>7.0.1</version>
+    </dependency>
+    <dependency>
       <groupId>org.apache.microwave</groupId>
       <artifactId>microwave-core</artifactId>
       <version>${project.version}</version>

Modified: openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/JBake.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/JBake.java?rev=1766736&r1=1766735&r2=1766736&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/JBake.java
(original)
+++ openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/JBake.java
Wed Oct 26 21:12:35 2016
@@ -1,8 +1,29 @@
+/*
+ * 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.microwave.doc;
 
 import com.orientechnologies.orient.core.Orient;
 import org.apache.commons.configuration.CompositeConfiguration;
+import org.apache.commons.configuration.MapConfiguration;
 import org.apache.microwave.Microwave;
+import org.apache.microwave.doc.generator.CliConfiguration;
+import org.apache.microwave.doc.generator.Configuration;
 import org.jbake.app.ConfigUtil;
 import org.jbake.app.Oven;
 
@@ -13,6 +34,8 @@ import java.nio.file.Path;
 import java.nio.file.WatchEvent;
 import java.nio.file.WatchKey;
 import java.nio.file.WatchService;
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Scanner;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -38,6 +61,10 @@ public class JBake {
         final boolean startHttp = args == null || args.length < 2 || Boolean.parseBoolean(args[2]);
// by default we dev
         final boolean skipPdf = args != null && args.length > 3 && !Boolean.parseBoolean(args[3]);
// by default...too slow sorry
 
+        // generation of dynamic content
+        new Configuration().run();
+        new CliConfiguration().run();
+
         final Runnable build = () -> {
             System.out.println("Building Microwave website in " + destination);
             final Orient orient = Orient.instance();
@@ -45,7 +72,14 @@ public class JBake {
                 orient.startup();
 
                 final Oven oven = new Oven(source, destination, new CompositeConfiguration()
{{
-                    addConfiguration(ConfigUtil.load(source));
+                    final CompositeConfiguration config = new CompositeConfiguration();
+                    config.addConfiguration(new MapConfiguration(new HashMap<String, Object>()
{{
+                        put("asciidoctor.attributes", new ArrayList<String>() {{
+                            add("source-highlighter=coderay");
+                        }});
+                    }}));
+                    config.addConfiguration(ConfigUtil.load(source));
+                    addConfiguration(config);
                 }}, true);
                 oven.setupPaths();
 

Modified: openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/PDFify.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/PDFify.java?rev=1766736&r1=1766735&r2=1766736&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/PDFify.java
(original)
+++ openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/PDFify.java
Wed Oct 26 21:12:35 2016
@@ -32,6 +32,7 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 
 import static org.asciidoctor.OptionsBuilder.options;
+import static org.asciidoctor.SafeMode.UNSAFE;
 
 public class PDFify {
     private PDFify() {
@@ -54,9 +55,16 @@ public class PDFify {
                         final Map<String, Object> attributes = asciidoctor.readDocumentHeader(asFile).getAttributes();
                         // if we generate the PDF link we need to create the PDF excepted
if it is expected to be manual
                         if (attributes.containsKey("jbake-microwavepdf") && !attributes.containsKey("jbake-microwavepdf-manual"))
{
+                            target.getParentFile().mkdirs();
                             asciidoctor.convertFile(
                                     asFile,
-                                    options().backend("pdf").attributes(AttributesBuilder.attributes().attribute("source-highlighter",
"coderay")).toFile(target).get());
+                                    options()
+                                            //.baseDir(asFile.getParentFile())
+                                            .safe(UNSAFE)
+                                            .backend("pdf")
+                                            .attributes(AttributesBuilder.attributes()
+                                                    .attribute("source-highlighter", "coderay"))
+                                            .toFile(target).get());
                             System.out.println("Generated " + target);
                         }
                     });

Added: openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/generator/BaseGenerator.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/generator/BaseGenerator.java?rev=1766736&view=auto
==============================================================================
--- openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/generator/BaseGenerator.java
(added)
+++ openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/generator/BaseGenerator.java
Wed Oct 26 21:12:35 2016
@@ -0,0 +1,41 @@
+/*
+ * 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.microwave.doc.generator;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+
+import static org.apache.ziplock.JarLocation.jarLocation;
+
+public abstract class BaseGenerator implements Runnable {
+    @Override
+    public void run() {
+        final File output = new File(jarLocation(BaseGenerator.class).getParentFile()/*target*/,
"generated-doc/" + getClass().getSimpleName() + ".adoc");
+        output.getParentFile().mkdirs();
+        try (final Writer w = new FileWriter(output)) {
+            w.write(generate());
+        } catch (final IOException e) {
+            throw new IllegalStateException(e);
+        }
+    }
+
+    protected abstract String generate();
+}

Added: openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/generator/CliConfiguration.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/generator/CliConfiguration.java?rev=1766736&view=auto
==============================================================================
--- openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/generator/CliConfiguration.java
(added)
+++ openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/generator/CliConfiguration.java
Wed Oct 26 21:12:35 2016
@@ -0,0 +1,38 @@
+/*
+ * 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.microwave.doc.generator;
+
+import org.apache.microwave.Microwave;
+import org.apache.microwave.runner.cli.CliOption;
+
+import java.util.stream.Stream;
+
+import static java.util.stream.Collectors.joining;
+
+public class CliConfiguration extends BaseGenerator {
+    @Override
+    protected String generate() {
+        return "[opts=\"header\"]\n|===\n|Name|Description\n" +
+                Stream.of(Microwave.Builder.class.getDeclaredFields())
+                        .sorted((o1, o2) -> o1.getName().compareTo(o2.getName()))
+                        .map(f -> f.getAnnotation(CliOption.class))
+                        .map(opt -> "|--" + opt.name() + "|" + opt.description())
+                        .collect(joining("\n")) + "\n|===\n";
+    }
+}

Added: openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/generator/Configuration.java
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/generator/Configuration.java?rev=1766736&view=auto
==============================================================================
--- openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/generator/Configuration.java
(added)
+++ openwebbeans/microwave/trunk/microwave-doc/src/main/java/org/apache/microwave/doc/generator/Configuration.java
Wed Oct 26 21:12:35 2016
@@ -0,0 +1,37 @@
+/*
+ * 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.microwave.doc.generator;
+
+import org.apache.microwave.Microwave;
+import org.apache.microwave.runner.cli.CliOption;
+
+import java.util.stream.Stream;
+
+import static java.util.stream.Collectors.joining;
+
+public class Configuration extends BaseGenerator {
+    @Override
+    protected String generate() {
+        return "[opts=\"header\"]\n|===\n|Name|Description\n" +
+                Stream.of(Microwave.Builder.class.getDeclaredFields())
+                .sorted((o1, o2) -> o1.getName().compareTo(o2.getName()))
+                .map(f -> "|" + f.getName() + "|" + f.getAnnotation(CliOption.class).description())
+                .collect(joining("\n")) + "\n|===\n";
+    }
+}

Modified: openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-core/cli.adoc
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-core/cli.adoc?rev=1766736&r1=1766735&r2=1766736&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-core/cli.adoc
(original)
+++ openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-core/cli.adoc
Wed Oct 26 21:12:35 2016
@@ -7,4 +7,11 @@
 :jbake-microwavecolor: body-pink
 :icons: font
 
-TBD
+
+Microwave provides a CLI (Command Line Interface) called `org.apache.microwave.runner.Cli`.
+
+It can be used to deploy the java classpath or a war. Here are the main options:
+
+include::../../../../../target/generated-doc/CliConfiguration.adoc[]
+
+Note that `help` command is supported as well.

Modified: openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-core/configuration.adoc
URL: http://svn.apache.org/viewvc/openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-core/configuration.adoc?rev=1766736&r1=1766735&r2=1766736&view=diff
==============================================================================
--- openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-core/configuration.adoc
(original)
+++ openwebbeans/microwave/trunk/microwave-doc/src/main/jbake/content/microwave-core/configuration.adoc
Wed Oct 26 21:12:35 2016
@@ -7,7 +7,4 @@
 :jbake-microwavecolor: body-pink
 :icons: font
 
-== Builder
-
-TBD
-
+include::../../../../../target/generated-doc/Configuration.adoc[]



Mime
View raw message