maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hbout...@apache.org
Subject svn commit: r1720929 - in /maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src: main/java/org/apache/maven/doxia/siterenderer/ test/java/org/apache/maven/doxia/siterenderer/ test/resources/site/apt/
Date Sat, 19 Dec 2015 14:09:42 GMT
Author: hboutemy
Date: Sat Dec 19 14:09:41 2015
New Revision: 1720929

URL: http://svn.apache.org/viewvc?rev=1720929&view=rev
Log:
[DOXIASITETOOLS-130] ensure calculations even if ".<extension>" in filename

Added:
    maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/resources/site/apt/extension.apt.not.at.end.apt
  (with props)
Modified:
    maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
    maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/RenderingContext.java
    maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
    maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/RenderingContextTest.java

Modified: maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java?rev=1720929&r1=1720928&r2=1720929&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
(original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
Sat Dec 19 14:09:41 2015
@@ -929,7 +929,7 @@ public class DefaultSiteRenderer
     }
 
     // TODO replace with StringUtils.endsWithIgnoreCase() from maven-shared-utils 0.7
-    private boolean endsWithIgnoreCase( String str, String searchStr )
+    static boolean endsWithIgnoreCase( String str, String searchStr )
     {
         if ( str.length() < searchStr.length() )
         {

Modified: maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/RenderingContext.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/RenderingContext.java?rev=1720929&r1=1720928&r2=1720929&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/RenderingContext.java
(original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/RenderingContext.java
Sat Dec 19 14:09:41 2015
@@ -21,7 +21,6 @@ package org.apache.maven.doxia.siterende
 
 import java.io.File;
 import java.util.HashMap;
-import java.util.Locale;
 import java.util.Map;
 
 import org.codehaus.plexus.util.PathTool;
@@ -79,28 +78,28 @@ public class RenderingContext
     {
         this.basedir = basedir;
         this.extension = extension;
+        this.inputName = document;
+        this.parserId = parserId;
+        this.attributes = new HashMap<String, String>();
+
         if ( StringUtils.isNotEmpty( extension ) )
         {
             // here we now the parserId we can play with this
             // index.xml -> index.html
             // index.xml.vm -> index.html
             // download.apt.vm --> download.html
-            int startIndexOfExtension =
-                document.toLowerCase( Locale.ENGLISH ).indexOf( "." + extension.toLowerCase(
Locale.ENGLISH ) );
-            String fileNameWithoutExt = document.substring( 0, startIndexOfExtension );
+            if ( DefaultSiteRenderer.endsWithIgnoreCase( document, ".vm" ) )
+            {
+                document = document.substring( 0, document.length() - 3 );
+            }
+            String fileNameWithoutExt = document.substring( 0, document.length() - extension.length()
- 1 );
             this.outputName = fileNameWithoutExt + ".html";
         }
         else
         {
-            this.outputName = document.substring( 0, document.indexOf( '.' ) ).replace( '\\',
'/' ) + ".html";
+            this.outputName = document.substring( 0, document.lastIndexOf( '.' ) ).replace(
'\\', '/' ) + ".html";
         }
-        this.relativePath = PathTool.getRelativePath( basedir.getPath(), new File( basedir,
document ).getPath() );
-
-        this.inputName = document;
-
-        this.parserId = parserId;
-
-        this.attributes = new HashMap<String, String>();
+        this.relativePath = PathTool.getRelativePath( basedir.getPath(), new File( basedir,
inputName ).getPath() );
     }
 
     /**

Modified: maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java?rev=1720929&r1=1720928&r2=1720929&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
(original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/DefaultSiteRendererTest.java
Sat Dec 19 14:09:41 2015
@@ -175,6 +175,7 @@ public class DefaultSiteRendererTest
         verifyMisc();
         verifyDocbookPageExists();
         verifyApt();
+        verifyExtensionInFilename();
         verifyNewlines();
 
         // ----------------------------------------------------------------------
@@ -389,9 +390,9 @@ public class DefaultSiteRendererTest
     public void verifyDocbookPageExists()
         throws Exception
     {
-        File nestedItems = getTestFile( "target/output/docbook.html" );
-        assertNotNull( nestedItems );
-        assertTrue( nestedItems.exists() );
+        File output = getTestFile( "target/output/docbook.html" );
+        assertNotNull( output );
+        assertTrue( output.exists() );
     }
 
     /**
@@ -405,6 +406,17 @@ public class DefaultSiteRendererTest
     }
 
     /**
+     * @throws Exception if something goes wrong.
+     */
+    public void verifyExtensionInFilename()
+        throws Exception
+    {
+        File output = getTestFile( "target/output/extension.apt.not.at.end.html" );
+        assertNotNull( output );
+        assertTrue( output.exists() );
+    }
+
+    /**
      * @throws Exception if something goes wrong.
      */
     public void verifyNewlines()

Modified: maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/RenderingContextTest.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/RenderingContextTest.java?rev=1720929&r1=1720928&r2=1720929&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/RenderingContextTest.java
(original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/java/org/apache/maven/doxia/siterenderer/RenderingContextTest.java
Sat Dec 19 14:09:41 2015
@@ -48,6 +48,10 @@ public class RenderingContextTest
         assertEquals( "file.with.dot.in.name.html", renderingContext.getOutputName() );
         assertEquals( ".", renderingContext.getRelativePath() );
 
+        renderingContext = new RenderingContext( baseDir, docName );
+        assertEquals( "file.with.dot.in.name.html", renderingContext.getOutputName() );
+        assertEquals( ".", renderingContext.getRelativePath() );
+
         docName = "index.xml.vm";
 
         renderingContext = new RenderingContext( baseDir, docName, "", "xml" );

Added: maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/resources/site/apt/extension.apt.not.at.end.apt
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/resources/site/apt/extension.apt.not.at.end.apt?rev=1720929&view=auto
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/resources/site/apt/extension.apt.not.at.end.apt
(added)
+++ maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/resources/site/apt/extension.apt.not.at.end.apt
Sat Dec 19 14:09:41 2015
@@ -0,0 +1,32 @@
+-----
+ extension in filename
+ -----
+ Hervé Boutemy
+ -----
+ 2015-12-19
+ -----
+
+~~ 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.
+
+~~ NOTE: For help with the syntax of this file, see:
+~~ http://maven.apache.org/doxia/references/apt-format.html
+
+RenderingContext
+
+  When transforming source file name into output file name, it is important to use last ".apt"
and not first one
+

Propchange: maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/resources/site/apt/extension.apt.not.at.end.apt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/test/resources/site/apt/extension.apt.not.at.end.apt
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



Mime
View raw message