You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2017/12/15 04:17:10 UTC

[maven-doxia-sitetools] branch master updated: [DOXIASITETOOLS-184] added generator field to document RenderingContext

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

hboutemy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-doxia-sitetools.git


The following commit(s) were added to refs/heads/master by this push:
     new 2fe1061  [DOXIASITETOOLS-184] added generator field to document RenderingContext
2fe1061 is described below

commit 2fe1061a26aafd35db9d3c73daeab2e01a082946
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Fri Dec 15 05:17:09 2017 +0100

    [DOXIASITETOOLS-184] added generator field to document RenderingContext
    
    to get info on report that generated content
    notice: the only missing case will be when a report mojo generated a
    Doxia document (instead of using Doxia Sink API)
---
 .../maven/doxia/siterenderer/RenderingContext.java | 40 +++++++++++++++++++---
 .../doxia/siterenderer/resources/default-site.vm   |  7 +++-
 2 files changed, 41 insertions(+), 6 deletions(-)

diff --git a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/RenderingContext.java b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/RenderingContext.java
index dc99801..44831e9 100644
--- a/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/RenderingContext.java
+++ b/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/RenderingContext.java
@@ -28,6 +28,7 @@ import org.codehaus.plexus.util.StringUtils;
 
 /**
  * The rendering context of a document.
+ * If not rendered from a Doxia markup source, parserId and extension will be null.
  *
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
  * @since 1.5 (was since 1.1 in o.a.m.d.sink.render)
@@ -50,6 +51,14 @@ public class RenderingContext // TODO rename to DocumentRenderingContext
 
     private final boolean editable;
 
+    private final String generator;
+
+    @Deprecated
+    public RenderingContext( File basedir, String document )
+    {
+        this( basedir, document, null, null, false, null );
+    }
+
     /**
      * <p>
      * Constructor for RenderingContext when document is not rendered from a Doxia markup source.
@@ -58,16 +67,23 @@ public class RenderingContext // TODO rename to DocumentRenderingContext
      * @param basedir the pseudo-source base directory.
      * @param document the pseudo-source document name: will be used to compute output name (same name with extension
      *            replaced with <code>.html</code>).
+     * @param generator the generator (in general a reporting goal: <code>groupId:artifactId:version:goal</code>)
+     * @since 1.8
      */
-    public RenderingContext( File basedir, String document )
+    public RenderingContext( File basedir, String document, String generator )
     {
-        this( basedir, document, null, null, false );
+        this( basedir, document, null, null, false, generator );
     }
 
     @Deprecated
     public RenderingContext( File basedir, String document, String parserId, String extension )
     {
-        this( basedir, document, parserId, extension, false );
+        this( basedir, document, parserId, extension, false, null );
+    }
+
+    public RenderingContext( File basedir, String document, String parserId, String extension, boolean editable )
+    {
+        this( basedir, document, parserId, extension, editable, null );
     }
 
     /**
@@ -81,13 +97,18 @@ public class RenderingContext // TODO rename to DocumentRenderingContext
      *            a Doxia source.
      * @param extension the source document filename extension, may be null if document not rendered from
      *            a Doxia source.
+     * @param editable is the document editable as source, i.e. not generated?
+     * @param generator the generator (in general a reporting goal: <code>groupId:artifactId:version:goal</code>)
+     * @since 1.8
      */
-    public RenderingContext( File basedir, String document, String parserId, String extension, boolean editable )
+    public RenderingContext( File basedir, String document, String parserId, String extension, boolean editable,
+                             String generator )
     {
         this.basedir = basedir;
-        this.extension = extension;
         this.inputName = document;
         this.parserId = parserId;
+        this.extension = extension;
+        this.generator = generator;
         this.attributes = new HashMap<String, String>();
 
         if ( StringUtils.isNotEmpty( extension ) )
@@ -208,4 +229,13 @@ public class RenderingContext // TODO rename to DocumentRenderingContext
     {
         return editable;
     }
+
+    /**
+     * What is the generator (if any)?
+     * @return <code>null</code> if no known generator
+     */
+    public String getGenerator()
+    {
+        return generator;
+    }
 }
diff --git a/doxia-site-renderer/src/main/resources/org/apache/maven/doxia/siterenderer/resources/default-site.vm b/doxia-site-renderer/src/main/resources/org/apache/maven/doxia/siterenderer/resources/default-site.vm
index d701afd..eb2814e 100644
--- a/doxia-site-renderer/src/main/resources/org/apache/maven/doxia/siterenderer/resources/default-site.vm
+++ b/doxia-site-renderer/src/main/resources/org/apache/maven/doxia/siterenderer/resources/default-site.vm
@@ -17,7 +17,12 @@
 ## under the License.
 ##
 #parse( "default-site-macros.vm" )
-<!-- Generated by Apache Maven Doxia Site Renderer#if( $doxiaSiteRendererVersion ) $doxiaSiteRendererVersion#end#if( $docRenderingContext.inputName ) from $docRenderingContext.basedir.name/$docRenderingContext.inputName#end at $dateFormat.format( $currentDate ) -->
+<!-- Generated by Apache Maven Doxia Site Renderer#if( $doxiaSiteRendererVersion ) $doxiaSiteRendererVersion#end##
+#if( $docRenderingContext.generator || $docRenderingContext.extension ) from##
+#if( $docRenderingContext.generator ) $docRenderingContext.generator#end##
+#if( $docRenderingContext.extension ) $docRenderingContext.basedir.name/$docRenderingContext.inputName#end##
+#end
+ at $dateFormat.format( $currentDate ) -->
 <html xmlns="http://www.w3.org/1999/xhtml"#if ( $locale ) xml:lang="$locale.language" lang="$locale.language"#end>
   <head>
     <meta http-equiv="Content-Type" content="text/html; charset=${outputEncoding}" />

-- 
To stop receiving notification emails like this one, please contact
['"commits@maven.apache.org" <co...@maven.apache.org>'].