Commit 4ce72cf0 authored by Emmanuel Bourg's avatar Emmanuel Bourg

New upstream version 1.7

parent 3375c13b
......@@ -25,7 +25,7 @@ under the License.
<parent>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia</artifactId>
<version>1.6</version>
<version>1.7</version>
<relativePath>../pom.xml</relativePath>
</parent>
......@@ -54,11 +54,6 @@ under the License.
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-annotations</artifactId>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.9.1</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
......
......@@ -21,15 +21,15 @@ package org.apache.maven.doxia.index;
import java.util.Stack;
import org.apache.maven.doxia.sink.impl.SinkAdapter;
import org.apache.maven.doxia.util.HtmlTools;
import org.apache.maven.doxia.sink.SinkAdapter;
/**
* A sink implementation for index.
*
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @version $Id: IndexingSink.java 1090706 2011-04-09 23:15:28Z hboutemy $
* @version $Id: IndexingSink.java 1726411 2016-01-23 16:34:09Z hboutemy $
*/
public class IndexingSink
extends SinkAdapter
......
......@@ -23,16 +23,15 @@ import java.util.Map;
import org.apache.maven.doxia.logging.Log;
import org.apache.maven.doxia.logging.SystemStreamLog;
import org.apache.maven.doxia.sink.SinkEventAttributeSet;
import org.apache.maven.doxia.sink.SinkEventAttributes;
import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
import org.codehaus.plexus.util.StringUtils;
/**
* Abstract base class to execute <code>Macro</code>.
*
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id: AbstractMacro.java 1090706 2011-04-09 23:15:28Z hboutemy $
* @version $Id: AbstractMacro.java 1726411 2016-01-23 16:34:09Z hboutemy $
* @since 1.0
*/
public abstract class AbstractMacro
......
......@@ -20,14 +20,13 @@ package org.apache.maven.doxia.macro;
*/
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.SinkEventAttributeSet;
import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
import org.codehaus.plexus.component.annotations.Component;
/**
* A simple macro that prints out the key and value of some supplied parameters.
*
* @version $Id: EchoMacro.java 1345590 2012-06-02 21:36:10Z hboutemy $
* @version $Id: EchoMacro.java 1726411 2016-01-23 16:34:09Z hboutemy $
*/
@Component( role = Macro.class, hint = "echo" )
public class EchoMacro
......
......@@ -20,17 +20,24 @@ package org.apache.maven.doxia.macro;
*/
import java.util.Map;
import org.apache.maven.doxia.parser.AbstractParser;
import org.apache.maven.doxia.parser.Parser;
import java.io.File;
/**
* <p>MacroRequest class.</p>
*
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id: MacroRequest.java 1090706 2011-04-09 23:15:28Z hboutemy $
* @version $Id: MacroRequest.java 1728197 2016-02-02 19:52:10Z hboutemy $
* @since 1.0
*/
public class MacroRequest
{
private static final String PARAM_SOURCE_CONTENT = "sourceContent";
private static final String PARAM_PARSER = "parser";
/** The current base directory. */
private File basedir;
......@@ -42,6 +49,7 @@ public class MacroRequest
*
* @param param A map of parameters.
* @param base The current base directory.
* @deprecated prefer other constructor
*/
public MacroRequest( Map<String, Object> param, File base )
{
......@@ -49,6 +57,15 @@ public class MacroRequest
this.basedir = base;
}
public MacroRequest( String sourceContent, AbstractParser parser, Map<String, Object> param, File base )
{
this.parameters = param;
this.basedir = base;
param.put( PARAM_SOURCE_CONTENT, sourceContent );
parser.setSecondParsing( true );
param.put( PARAM_PARSER, parser );
}
/**
* Returns the current base directory.
*
......@@ -90,4 +107,19 @@ public class MacroRequest
{
return parameters.get( key );
}
public String getSourceContent()
{
return (String) getParameter( PARAM_SOURCE_CONTENT );
}
public Parser getParser()
{
return (Parser) getParameter( PARAM_PARSER );
}
public static boolean isInternalParameter( String name )
{
return PARAM_PARSER.equals( name ) || PARAM_SOURCE_CONTENT.equals( name );
}
}
package org.apache.maven.doxia.module.site.manager;
package org.apache.maven.doxia.macro;
/*
* Licensed to the Apache Software Foundation (ASF) under one
......@@ -19,58 +19,51 @@ package org.apache.maven.doxia.module.site.manager;
* under the License.
*/
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
import org.apache.maven.doxia.module.site.SiteModule;
import org.apache.maven.doxia.sink.Sink;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
/**
* Simple implementation of the SiteModuleManager interface.
*
* @author Jason van Zyl
* @version $Id: DefaultSiteModuleManager.java 1546011 2013-11-27 12:18:20Z hboutemy $
* @since 1.0
* @deprecated replaced by DefaultParserModuleManager
* Server-Side Include directive, to insert a SSI into the output.
* Required parameter is <code>function</code> to define SSI function, then
* additional parameters are completely free.
* @since 1.7
*/
@Component( role = SiteModuleManager.class )
public class DefaultSiteModuleManager
implements SiteModuleManager
@Component( role = Macro.class, hint = "ssi" )
public class SsiMacro
extends AbstractMacro
{
@Requirement( role = SiteModule.class )
private Map<String, SiteModule> siteModules;
private static final String PARAM_FUNCTION = "function";
private Collection<SiteModule> siteModulesValues;
/** {@inheritDoc} */
public Collection<SiteModule> getSiteModules()
private boolean isInternalParameter( String name )
{
if ( siteModulesValues == null )
{
Map<Class<?>, SiteModule> siteModulesTmp = new LinkedHashMap<Class<?>, SiteModule>();
for ( SiteModule module : siteModules.values() )
{
siteModulesTmp.put( module.getClass(), module );
}
siteModulesValues = siteModulesTmp.values();
}
return siteModulesValues;
return PARAM_FUNCTION.equals( name ) || MacroRequest.isInternalParameter( name );
}
/** {@inheritDoc} */
public SiteModule getSiteModule( String id )
throws SiteModuleNotFoundException
public void execute( Sink sink, MacroRequest request )
throws MacroExecutionException
{
SiteModule siteModule = siteModules.get( id );
String function = (String) request.getParameter( PARAM_FUNCTION );
required( PARAM_FUNCTION, function );
if ( siteModule == null )
StringBuilder buff = new StringBuilder();
buff.append( '#' );
buff.append( function );
for ( Map.Entry<String, Object> entry : request.getParameters().entrySet() )
{
throw new SiteModuleNotFoundException( "Cannot find site module id = " + id );
if ( !isInternalParameter( entry.getKey() ) )
{
buff.append( ' ' );
buff.append( entry.getKey() );
buff.append( "=\"" );
buff.append( entry.getValue() );
buff.append( '"' );
}
}
return siteModule;
buff.append( ' ' );
sink.comment( buff.toString() );
}
}
......@@ -24,7 +24,7 @@ import org.apache.maven.doxia.macro.Macro;
import org.apache.maven.doxia.macro.MacroExecutionException;
import org.apache.maven.doxia.macro.MacroRequest;
import org.apache.maven.doxia.sink.Sink;
import org.apache.maven.doxia.sink.SinkEventAttributeSet;
import org.apache.maven.doxia.sink.impl.SinkEventAttributeSet;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.util.StringUtils;
......@@ -38,7 +38,7 @@ import java.util.Map;
/**
* A macro that prints out the content of a file or a URL.
*
* @version $Id: SnippetMacro.java 1543585 2013-11-19 21:37:30Z michaelo $
* @version $Id: SnippetMacro.java 1726411 2016-01-23 16:34:09Z hboutemy $
*/
@Component( role = Macro.class, hint = "snippet" )
public class SnippetMacro
......@@ -207,6 +207,7 @@ public class SnippetMacro
}
catch ( IOException e )
{
getLog().debug( "IOException which reading " + url + ": " + e );
result = new StringBuffer( "Error during retrieving content skip as ignoreDownloadError activated." );
}
......
......@@ -75,7 +75,7 @@ import org.codehaus.plexus.util.StringUtils;
* </pre>
*
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @version $Id: TocMacro.java 1345590 2012-06-02 21:36:10Z hboutemy $
* @version $Id: TocMacro.java 1702681 2015-09-12 20:34:09Z hboutemy $
*/
@Component( role = Macro.class, hint = "toc" )
public class TocMacro
......@@ -97,8 +97,8 @@ public class TocMacro
public void execute( Sink sink, MacroRequest request )
throws MacroExecutionException
{
String source = (String) request.getParameter( "sourceContent" );
Parser parser = (Parser) request.getParameter( "parser" );
String source = request.getSourceContent();
Parser parser = request.getParser();
section = getInt( request, "section", 0 );
fromDepth = getInt( request, "fromDepth", 0 );
......
......@@ -32,9 +32,10 @@ import javax.swing.text.html.HTML.Tag;
* @see <a href="http://www.w3.org/TR/html401/index/elements.html">http://www.w3.org/TR/html401/index/elements.html</a>
*
* @author ltheussl
* @version $Id: HtmlMarkup.java 1185112 2011-10-17 11:33:00Z ltheussl $
* @version $Id: HtmlMarkup.java 1633964 2014-10-23 22:01:01Z hboutemy $
* @since 1.0
*/
@SuppressWarnings( "checkstyle:interfaceistype" )
public interface HtmlMarkup
extends XmlMarkup
{
......
......@@ -23,9 +23,10 @@ package org.apache.maven.doxia.markup;
* List of constants used by all markup syntax.
*
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @version $Id: Markup.java 657808 2008-05-19 12:11:53Z ltheussl $
* @version $Id: Markup.java 1719653 2015-12-12 11:23:49Z schulte $
* @since 1.0
*/
@SuppressWarnings( "checkstyle:interfaceistype" )
public interface Markup
{
/** The vm line separator */
......
......@@ -23,9 +23,10 @@ package org.apache.maven.doxia.markup;
* List of constants used by <code>Text</code> markup syntax.
*
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @version $Id: TextMarkup.java 638290 2008-03-18 09:45:22Z bentmann $
* @version $Id: TextMarkup.java 1633964 2014-10-23 22:01:01Z hboutemy $
* @since 1.0
*/
@SuppressWarnings( "checkstyle:interfaceistype" )
public interface TextMarkup
extends Markup
{
......
......@@ -19,13 +19,15 @@ package org.apache.maven.doxia.markup;
* under the License.
*/
/**
* List of constants used by <code>Xml</code> markup syntax.
*
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @version $Id: XmlMarkup.java 785531 2009-06-17 09:47:59Z ltheussl $
* @version $Id: XmlMarkup.java 1633964 2014-10-23 22:01:01Z hboutemy $
* @since 1.0
*/
@SuppressWarnings( "checkstyle:interfaceistype" )
public interface XmlMarkup
extends Markup
{
......
package org.apache.maven.doxia.module.site;
/*
* 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.
*/
/**
* An abstract base class that implements the SiteModule interface.
*
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id: AbstractSiteModule.java 1546011 2013-11-27 12:18:20Z hboutemy $
* @since 1.0
* @deprecated replaced by AbstractParserModule
*/
public abstract class AbstractSiteModule
implements SiteModule
{
/** The source directory. */
private final String sourceDirectory;
/** The default file extension. */
private final String extension;
/** The default file extension. */
private final String parserId;
/**
* Constructor with null.
*/
public AbstractSiteModule()
{
this( null, null, null );
}
/**
* @param sourceDirectory not null
* @param extension not null
* @param parserId not null
* @since 1.1.1
*/
protected AbstractSiteModule( String sourceDirectory, String extension, String parserId )
{
super();
this.sourceDirectory = sourceDirectory;
this.extension = extension;
this.parserId = parserId;
}
/** {@inheritDoc} */
public String getSourceDirectory()
{
return sourceDirectory;
}
/** {@inheritDoc} */
public String getExtension()
{
return extension;
}
/** {@inheritDoc} */
public String getParserId()
{
return parserId;
}
}
package org.apache.maven.doxia.module.site;
/*
* 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.
*/
import org.apache.maven.doxia.parser.module.ParserModule;
/**
* Provides definitions for a Doxia module. This is used by the doxia site tools.
*
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id: SiteModule.java 1546011 2013-11-27 12:18:20Z hboutemy $
* @since 1.0
* @deprecated use ParserModule
* @see ParserModule
*/
public interface SiteModule
{
/** The Plexus lookup role. */
String ROLE = SiteModule.class.getName();
/**
* Returns the directory that contains source files for a given module.
*
* @return The source directory.
*/
String getSourceDirectory();
/**
* Returns the default file extension for a given module.
*
* @return The default file extension.
*/
String getExtension();
/**
* Returns the parser id for a given module.
*
* @return The parser id.
*/
String getParserId();
}
package org.apache.maven.doxia.module.site.manager;
/*
* 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.
*/
import org.apache.maven.doxia.module.site.SiteModule;
import org.apache.maven.doxia.parser.module.ParserModuleManager;
import java.util.Collection;
/**
* Handles SiteModule lookups.
*
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id: SiteModuleManager.java 1546011 2013-11-27 12:18:20Z hboutemy $
* @since 1.0
* @deprecated use ParserModuleManager
* @see ParserModuleManager
*/
public interface SiteModuleManager
{
/** The Plexus lookup role. */
String ROLE = SiteModuleManager.class.getName();
/**
* Returns a collection of SiteModules.
*
* @return The SiteModules.
*/
Collection<SiteModule> getSiteModules();
/**
* Returns the SiteModule that corresponds to the given id.
*
* @param id The identifier.
* @return The corresponding SiteModule.
* @throws org.apache.maven.doxia.module.site.manager.SiteModuleNotFoundException if no SiteModule could be found
* for the given id.
*/
SiteModule getSiteModule( String id )
throws SiteModuleNotFoundException;
}
package org.apache.maven.doxia.module.site.manager;
/*
* 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.
*/
/**
* Encapsulate a Doxia exception that indicates that a SiteModule
* does not exist or could not be found.
*
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id: SiteModuleNotFoundException.java 1546011 2013-11-27 12:18:20Z hboutemy $
* @since 1.0
* @deprecated
*/
public class SiteModuleNotFoundException
extends Exception
{
/** serialVersionUID */
static final long serialVersionUID = 295967936746221567L;
/**
* Construct a new SiteModuleNotFoundException with the
* specified detail message.
*
* @param message The detailed message.
* This can later be retrieved by the Throwable.getMessage() method.
*/
public SiteModuleNotFoundException( String message )
{
super( message );
}
/**
* Constructs a new SiteModuleNotFoundException with the specified cause.
* The error message is (cause == null ? null : cause.toString() ).
*
* @param cause the cause. This can be retrieved later by the
* Throwable.getCause() method. (A null value is permitted, and indicates
* that the cause is nonexistent or unknown.)
*/
public SiteModuleNotFoundException( Throwable cause )
{
super( cause );
}
/**
* Construct a new SiteModuleNotFoundException with the specified
* detail message and cause.
*
* @param message The detailed message.
* This can later be retrieved by the Throwable.getMessage() method.
* @param cause The cause. This can be retrieved later by the
* Throwable.getCause() method. (A null value is permitted, and indicates
* that the cause is nonexistent or unknown.)