Commit 669f69ad authored by Emmanuel Bourg's avatar Emmanuel Bourg

Imported Upstream version 1.1.4

parent 50fce079
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia</artifactId>
<version>1.1.4</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>doxia-book</artifactId>
<name>Doxia :: Book Component</name>
<description>A component to write books like user manuals and guides in any format supported by Doxia.</description>
<dependencies>
<!-- doxia core -->
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-sink-api</artifactId>
</dependency>
<!-- doxia modules ordered -->
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-module-apt</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-module-docbook-simple</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-module-itext</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-module-latex</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-module-xdoc</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-module-xhtml</artifactId>
</dependency>
<!-- plexus -->
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-i18n</artifactId>
<version>1.0-beta-6</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
</dependency>
<!-- test -->
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-core</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.modello</groupId>
<artifactId>modello-maven-plugin</artifactId>
<configuration>
<models>
<model>src/main/modello/book.mdo</model>
</models>
<version>1.0.0</version>
</configuration>
<executions>
<execution>
<id>site-docs</id>
<phase>pre-site</phase>
<goals>
<goal>xdoc</goal>
<goal>xsd</goal>
</goals>
</execution>
<execution>
<id>descriptor</id>
<phase>generate-sources</phase>
<goals>
<goal>java</goal>
<goal>xpp3-reader</goal>
<goal>xsd</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>reporting</id>
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>l10n-maven-plugin</artifactId>
<version>1.0-alpha-2</version>
<configuration>
<locales>
<locale>en</locale>
<locale>fr</locale>
</locales>
</configuration>
</plugin>
</plugins>
</reporting>
</profile>
</profiles>
</project>
\ No newline at end of file
package org.apache.maven.doxia.book;
/*
* 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.book.model.BookModel;
import java.io.File;
import java.util.List;
import java.util.Locale;
/**
* An interface to create books in different output formats from a book descriptor.
*
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
* @version $Id: BookDoxia.java 748141 2009-02-26 13:29:10Z vsiveton $
*/
public interface BookDoxia
{
/** The plexus lookup role. */
String ROLE = BookDoxia.class.getName();
/**
* Load a BookModel from a descriptor file.
*
* @param bookDescriptor the book descriptor file.
* @return BookModel
* @throws org.apache.maven.doxia.book.BookDoxiaException if the model cannot be loaded.
*/
BookModel loadBook( File bookDescriptor )
throws BookDoxiaException;
/**
* Creates a book from a BookModel using the {@link Locale#getDefault()} and UTF-8 as default encoding.
*
* @param book the BookModel.
* @param bookRendererId the id of the output format.
* @param files a list of source files.
* @param outputDirectory the output directory.
* @throws org.apache.maven.doxia.book.BookDoxiaException if the model cannot be loaded.
* @see #renderBook(BookModel, String, List, File, Locale, String, String)
* @see Locale#getDefault()
*/
void renderBook( BookModel book, String bookRendererId, List files, File outputDirectory )
throws BookDoxiaException;
/**
* Creates a book from a BookModel.
*
* @param book the BookModel.
* @param bookRendererId the id of the output format.
* @param files a list of source files.
* @param outputDirectory the output directory.
* @param locale the wanted locale.
* @param inputEncoding the input encoding when processing <code>files</code>.
* @param outputEncoding the output encoding when writing files in <code>ouputDirectory</code>.
* @throws org.apache.maven.doxia.book.BookDoxiaException if the model cannot be loaded.
* @since 1.1
*/
void renderBook( BookModel book, String bookRendererId, List files, File outputDirectory, Locale locale,
String inputEncoding, String outputEncoding )
throws BookDoxiaException;
}
package org.apache.maven.doxia.book;
/*
* 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.
*/
/**
* Wraps an exception when rendering books.
*
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
* @version $Id: BookDoxiaException.java 740275 2009-02-03 11:17:28Z vsiveton $
*/
public class BookDoxiaException
extends Exception
{
/** serialVersionUID */
private static final long serialVersionUID = 87146681585045106L;
/**
* Construct a new BookDoxiaException with the specified detail message.
*
* @param message The detailed message. This can later be retrieved by the Throwable.getMessage() method.
*/
public BookDoxiaException( String message )
{
super( message );
}
/**
* Construct a new BookDoxiaException 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).
*/
public BookDoxiaException( String message, Throwable cause )
{
super( message, cause );
}
}
package org.apache.maven.doxia.book;
/*
* 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.book.context.BookContext;
import org.apache.maven.doxia.book.model.BookModel;
import org.apache.maven.doxia.book.services.indexer.BookIndexer;
import org.apache.maven.doxia.book.services.io.BookIo;
import org.apache.maven.doxia.book.services.renderer.BookRenderer;
import org.apache.maven.doxia.book.services.validation.BookValidator;
import org.apache.maven.doxia.book.services.validation.ValidationResult;
import org.codehaus.plexus.logging.AbstractLogEnabled;
import java.io.File;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
/**
* Default implementation of BookDoxia.
*
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
* @version $Id: DefaultBookDoxia.java 740705 2009-02-04 11:57:33Z vsiveton $
* @plexus.component
*/
public class DefaultBookDoxia
extends AbstractLogEnabled
implements BookDoxia
{
/**
* @plexus.requirement
*/
private BookIo bookIo;
/**
* @plexus.requirement
*/
private BookValidator bookValidator;
/**
* @plexus.requirement
*/
private BookIndexer bookIndexer;
/**
* @plexus.requirement role="org.apache.maven.doxia.book.services.renderer.BookRenderer"
*/
private Map bookRenderers;
// ----------------------------------------------------------------------
// BookDoxia Implementation
// ----------------------------------------------------------------------
/** {@inheritDoc} */
public BookModel loadBook( File bookDescriptor )
throws BookDoxiaException
{
return bookIo.readBook( bookDescriptor );
}
/** {@inheritDoc} */
public void renderBook( BookModel book, String bookRendererId, List files, File outputDirectory )
throws BookDoxiaException
{
renderBook( book, bookRendererId, files, outputDirectory, Locale.getDefault(), "UTF-8", "UTF-8" );
}
/** {@inheritDoc} */
public void renderBook( BookModel book, String bookRendererId, List files, File outputDirectory, Locale locale,
String inputEncoding, String outputEncoding )
throws BookDoxiaException
{
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
ValidationResult validationResult = bookValidator.validateBook( book );
if ( !validationResult.isAllOk() )
{
throw new InvalidBookDescriptorException( validationResult );
}
// ----------------------------------------------------------------------
// Create and initialize the context
// ----------------------------------------------------------------------
BookContext context = new BookContext();
context.setBook( book );
context.setOutputDirectory( outputDirectory );
context.setLocale( locale );
context.setInputEncoding( inputEncoding );
context.setOutputEncoding( outputEncoding );
// -----------------------------------------------------------------------
//
// -----------------------------------------------------------------------
bookIo.loadFiles( context, files );
// ----------------------------------------------------------------------
// Generate indexes
// ----------------------------------------------------------------------
bookIndexer.indexBook( book, context );
// ----------------------------------------------------------------------
// Render the book
// ----------------------------------------------------------------------
BookRenderer bookRenderer = (BookRenderer) bookRenderers.get( bookRendererId );
if ( bookRenderer == null )
{
throw new BookDoxiaException( "No such book renderer '" + bookRendererId + "'." );
}
bookRenderer.renderBook( context );
}
/**
* Returns a Set of ids of the BookRenderers that are available in this BookDoxia.
*
* @return Set
*/
public Set getAvailableBookRenderers()
{
return Collections.unmodifiableSet( bookRenderers.keySet() );
}
}
package org.apache.maven.doxia.book;
/*
* 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.book.services.validation.ValidationResult;
/**
* Indicates that the book descriptor file could not be parsed correctly.
*
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
* @version $Id: InvalidBookDescriptorException.java 769433 2009-04-28 15:26:55Z ltheussl $
*/
public class InvalidBookDescriptorException
extends BookDoxiaException
{
/** serialVersionUID */