You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by dd...@apache.org on 2021/02/08 08:30:35 UTC

[freemarker-generator] 03/03: FREEMARKER-154 Using [docgen:insertOutput] at a few places (more to come). Inserting freemarker-generator output into the documentation is much less fuss with this.

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

ddekany pushed a commit to branch FREEMARKER-154
in repository https://gitbox.apache.org/repos/asf/freemarker-generator.git

commit 910ea44b6881dca3c91dc2864c1c327d58160f83
Author: ddekany <dd...@apache.org>
AuthorDate: Mon Feb 8 09:25:23 2021 +0100

    FREEMARKER-154 Using [docgen:insertOutput] at a few places (more to come).  Inserting freemarker-generator output into the documentation is much less fuss with this.
---
 freemarker-generator-website/pom.xml               | 106 ++-------------------
 .../src/main/docgen/book.xml                       |  20 ++--
 .../src/main/docgen/docgen.cjson                   |  12 +++
 3 files changed, 33 insertions(+), 105 deletions(-)

diff --git a/freemarker-generator-website/pom.xml b/freemarker-generator-website/pom.xml
index 2d0a5fe..a365a22 100644
--- a/freemarker-generator-website/pom.xml
+++ b/freemarker-generator-website/pom.xml
@@ -99,102 +99,6 @@
                           <outputFile>${docgenInsertedOutputsDirectory}/info-template-output.txt</outputFile>
                         </configuration>
                     </execution>
-                    <execution>
-                        <id>named-uri-my_users-simple</id>
-                        <phase>package</phase>
-                        <goals>
-                          <goal>exec</goal>
-                        </goals>
-                        <configuration>
-                          <executable>java</executable>
-                          <arguments>
-                              <argument>-classpath</argument>
-                              <classpath/>
-
-                              <!-- Setting up things without calling the launcher scripts in app/bin: -->
-                              <argument>-Dapp.home=${freemarkerGeneratorAppHome}</argument>
-
-                              <argument>org.apache.freemarker.generator.cli.Main</argument>
-                              <argument>-t</argument>
-                              <argument>freemarker-generator/info.ftl</argument>
-                              <argument>my_users=examples/data/csv/user.csv</argument>
-                          </arguments>
-                          <workingDirectory>${freemarkerGeneratorAppHome}</workingDirectory>
-                          <outputFile>${docgenInsertedOutputsDirectory}/named-uri-my_users-simple.txt</outputFile>
-                        </configuration>
-                    </execution>
-                    <execution>
-                        <id>named-uri-my_users-charset-fragment</id>
-                        <phase>package</phase>
-                        <goals>
-                            <goal>exec</goal>
-                        </goals>
-                        <configuration>
-                            <executable>java</executable>
-                            <arguments>
-                                <argument>-classpath</argument>
-                                <classpath/>
-
-                                <!-- Setting up things without calling the launcher scripts in app/bin: -->
-                                <argument>-Dapp.home=${freemarkerGeneratorAppHome}</argument>
-
-                                <argument>org.apache.freemarker.generator.cli.Main</argument>
-                                <argument>-t</argument>
-                                <argument>freemarker-generator/info.ftl</argument>
-                                <argument>my_users=examples/data/csv/user.csv#charset=UTF-16</argument>
-                            </arguments>
-                            <workingDirectory>${freemarkerGeneratorAppHome}</workingDirectory>
-                            <outputFile>${docgenInsertedOutputsDirectory}/named-uri-my_users-charset-fragment.txt</outputFile>
-                        </configuration>
-                    </execution>
-                    <execution>
-                        <id>named-uri-example-no-name</id>
-                        <phase>package</phase>
-                        <goals>
-                            <goal>exec</goal>
-                        </goals>
-                        <configuration>
-                            <executable>java</executable>
-                            <arguments>
-                                <argument>-classpath</argument>
-                                <classpath/>
-
-                                <!-- Setting up things without calling the launcher scripts in app/bin: -->
-                                <argument>-Dapp.home=${freemarkerGeneratorAppHome}</argument>
-
-                                <argument>org.apache.freemarker.generator.cli.Main</argument>
-                                <argument>-t</argument>
-                                <argument>freemarker-generator/info.ftl</argument>
-                                <argument>http://google.com?foo=bar</argument>
-                            </arguments>
-                            <workingDirectory>${freemarkerGeneratorAppHome}</workingDirectory>
-                            <outputFile>${docgenInsertedOutputsDirectory}/named-uri-example-no-name.txt</outputFile>
-                        </configuration>
-                    </execution>
-                    <execution>
-                        <id>named-uri-example-with-name</id>
-                        <phase>package</phase>
-                        <goals>
-                            <goal>exec</goal>
-                        </goals>
-                        <configuration>
-                            <executable>java</executable>
-                            <arguments>
-                                <argument>-classpath</argument>
-                                <classpath/>
-
-                                <!-- Setting up things without calling the launcher scripts in app/bin: -->
-                                <argument>-Dapp.home=${freemarkerGeneratorAppHome}</argument>
-
-                                <argument>org.apache.freemarker.generator.cli.Main</argument>
-                                <argument>-t</argument>
-                                <argument>freemarker-generator/info.ftl</argument>
-                                <argument>page=http://google.com?foo=bar</argument>
-                            </arguments>
-                            <workingDirectory>${freemarkerGeneratorAppHome}</workingDirectory>
-                            <outputFile>${docgenInsertedOutputsDirectory}/named-uri-example-with-name.txt</outputFile>
-                        </configuration>
-                    </execution>
                 </executions>
             </plugin>
             <plugin>
@@ -220,11 +124,19 @@
                         <exampleOutputs>${docgenInsertedExampleOutputDirectory}/**</exampleOutputs>
                     </insertableFiles>
                     <customVariables>
-                      <version>${project.version}</version>
+                        <version>${project.version}</version>
+                        <freemarkerGeneratorAppHome>${freemarkerGeneratorAppHome}</freemarkerGeneratorAppHome>
                     </customVariables>
                     <!-- TODO set it back to false before release -->
                     <offline>true</offline>
                 </configuration>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.apache.freemarker.generator</groupId>
+                        <artifactId>freemarker-generator-cli</artifactId>
+                        <version>${project.version}</version>
+                    </dependency>
+                </dependencies>
             </plugin>
         </plugins>
     </build>
diff --git a/freemarker-generator-website/src/main/docgen/book.xml b/freemarker-generator-website/src/main/docgen/book.xml
index 377a1e4..88f97bd 100644
--- a/freemarker-generator-website/src/main/docgen/book.xml
+++ b/freemarker-generator-website/src/main/docgen/book.xml
@@ -947,25 +947,29 @@ EDITOR ==&gt; vi</programlisting>
       <para>The following Named URI loads a <literal>user.csv</literal> and
       the data source is available as <literal>my_users</literal>:</para>
 
-      <programlisting>&gt; freemarker-generator -t freemarker-generator/info.ftl my_users=examples/data/csv/user.csv
-[docgen.insertFile "@websitePomGenerated/named-uri-my_users-simple.txt" from="FreeMarker Generator DataSources" toIfPresent=r"^\s*$"]</programlisting>
+      <programlisting>[docgen.insertOutput from="FreeMarker Generator DataSources" to=r"^\s*$" printCommand=true]
+freemarker-generator -t freemarker-generator/info.ftl my_users=[docgen:wd]/examples/data/csv/user.csv
+[/docgen.insertOutput]</programlisting>
 
       <para>A Named URI allows to pass additional information as part of the
       fragment, e.g. the charset of the text file:</para>
 
-      <programlisting>&gt; freemarker-generator -t freemarker-generator/info.ftl my_users=examples/data/csv/user.csv#charset=UTF-16
-[docgen.insertFile "@websitePomGenerated/named-uri-my_users-charset-fragment.txt" from="FreeMarker Generator DataSources" toIfPresent=r"^\s*$"]</programlisting>
+      <programlisting>[docgen.insertOutput from="FreeMarker Generator DataSources" to=r"^\s*$" printCommand=true]
+freemarker-generator -t freemarker-generator/info.ftl my_users=[docgen:wd]/examples/data/csv/user.csv#charset=UTF-16
+[/docgen.insertOutput]</programlisting>
 
       <para>In addition to the simplified file syntax full URIs can be
       used:</para>
 
-      <programlisting>&gt; freemarker-generator -t freemarker-generator/info.ftl http://google.com?foo=bar
-[docgen.insertFile "@websitePomGenerated/named-uri-example-no-name.txt" from="FreeMarker Generator DataSources" toIfPresent=r"^\s*$"]</programlisting>
+      <programlisting>[docgen.insertOutput from="FreeMarker Generator DataSources" to=r"^\s*$" printCommand=true]
+freemarker-generator -t freemarker-generator/info.ftl http://google.com?foo=bar
+[/docgen.insertOutput]</programlisting>
 
       <para>and also combined with a name:</para>
 
-      <programlisting>&gt; freemarker-generator -t freemarker-generator/info.ftl page=http://google.com?foo=bar
-[docgen.insertFile "@websitePomGenerated/named-uri-example-with-name.txt" from="FreeMarker Generator DataSources" toIfPresent=r"^\s*$"]</programlisting>
+      <programlisting>[docgen.insertOutput from="FreeMarker Generator DataSources" to=r"^\s*$" printCommand=true]
+freemarker-generator -t freemarker-generator/info.ftl page=http://google.com?foo=bar
+[/docgen.insertOutput]</programlisting>
     </section>
 
     <section xml:id="datasources">
diff --git a/freemarker-generator-website/src/main/docgen/docgen.cjson b/freemarker-generator-website/src/main/docgen/docgen.cjson
index de141d6..eb1f80b 100644
--- a/freemarker-generator-website/src/main/docgen/docgen.cjson
+++ b/freemarker-generator-website/src/main/docgen/docgen.cjson
@@ -95,6 +95,7 @@ socialLinks: {
 
 customVariables: {
   version: null // Must be overridden by the caller
+  freemarkerGeneratorAppHome: null // Must be overridden by the caller
 }
 
 insertableFiles: {
@@ -103,3 +104,14 @@ insertableFiles: {
   exampleTemplates: null // Must be overridden by the caller
   exampleOutputs: null // Must be overridden by the caller
 }
+
+insertableOutputCommands: {
+  freemarker-generator: {
+    mainClass: org.apache.freemarker.generator.cli.Main
+    mainMethod: execute
+    systemProperties: {
+      app.home: getCustomVariable("freemarkerGeneratorAppHome")
+    }
+    docgenWdReplacedWith: getCustomVariable("freemarkerGeneratorAppHome")
+  }
+}