Search in sources :

Example 1 with DocumentTOC

use of org.apache.maven.doxia.document.DocumentTOC in project maven-plugins by apache.

the class DocumentModelBuilder method getDocumentTOC.

/**
 * Extract a DocumentTOC from a DecorationModel.
 *
 * @param decorationModel a DecorationModel. May be null.
 * @return a DocumentTOC, always non-null.
 */
private static DocumentTOC getDocumentTOC(DecorationModel decorationModel) {
    final DocumentTOC toc = new DocumentTOC();
    if (decorationModel != null && decorationModel.getMenus() != null) {
        for (final Menu menu : decorationModel.getMenus()) {
            for (final MenuItem item : menu.getItems()) {
                final DocumentTOCItem documentTOCItem = new DocumentTOCItem();
                documentTOCItem.setName(item.getName());
                documentTOCItem.setRef(item.getHref());
                toc.addItem(documentTOCItem);
            }
        }
    }
    return toc;
}
Also used : DocumentTOC(org.apache.maven.doxia.document.DocumentTOC) DocumentTOCItem(org.apache.maven.doxia.document.DocumentTOCItem) MenuItem(org.apache.maven.doxia.site.decoration.MenuItem) Menu(org.apache.maven.doxia.site.decoration.Menu)

Example 2 with DocumentTOC

use of org.apache.maven.doxia.document.DocumentTOC in project maven-plugins by apache.

the class DocumentModelBuilderTest method testGetDocumentModelWithSiteDescriptor.

/**
 * Test of getDocumentModel method, of class DocumentModelBuilder.
 * @throws Exception if something happens.
 */
public void testGetDocumentModelWithSiteDescriptor() throws Exception {
    File descriptorFile = new File(testBaseDir() + "src/site/", "model_builder_site.xml");
    DecorationModel dModel = getDecorationModelFromFile(descriptorFile);
    DocumentModel model = new DocumentModelBuilder(new ModelBuilderMavenProjectStub(), dModel).getDocumentModel();
    DocumentTOC toc = model.getToc();
    assertEquals(1, toc.getItems().size());
    assertEquals("Intro", toc.getItems().get(0).getName());
    assertEquals("index.html", toc.getItems().get(0).getRef());
}
Also used : DocumentTOC(org.apache.maven.doxia.document.DocumentTOC) DecorationModel(org.apache.maven.doxia.site.decoration.DecorationModel) ModelBuilderMavenProjectStub(org.apache.maven.plugins.pdf.stubs.ModelBuilderMavenProjectStub) File(java.io.File) DocumentModel(org.apache.maven.doxia.document.DocumentModel)

Example 3 with DocumentTOC

use of org.apache.maven.doxia.document.DocumentTOC in project maven-plugins by apache.

the class DocumentModelBuilderTest method testGetDocumentModel.

/**
 * Test of getDocumentModel method, of class DocumentModelBuilder.
 */
public void testGetDocumentModel() {
    DocumentModel model = new DocumentModelBuilder(new ModelBuilderMavenProjectStub()).getDocumentModel();
    assertEquals("ISO-8859-1", model.getModelEncoding());
    assertEquals("Test ArtifactId", model.getOutputName());
    DocumentCover cover = model.getCover();
    assertEquals("Test Version", cover.getCoverVersion());
    assertEquals("Test Name", cover.getProjectName());
    assertEquals("Test Name", cover.getCoverTitle());
    assertEquals("v. Test Version", cover.getCoverSubTitle());
    assertEquals("Test Organization", cover.getCompanyName());
    assertEquals(2, cover.getAuthors().size());
    assertFirstDocumentAuthor(cover.getAuthors().get(0));
    DocumentMeta meta = model.getMeta();
    assertEquals("Test Description", meta.getDescription());
    assertEquals(2, meta.getAuthors().size());
    assertFirstDocumentAuthor(meta.getAuthors().get(0));
    assertEquals("Test Name", meta.getSubject());
    assertEquals("Test Name", meta.getTitle());
    DocumentTOC toc = model.getToc();
    assertEquals(0, toc.getItems().size());
}
Also used : DocumentTOC(org.apache.maven.doxia.document.DocumentTOC) DocumentCover(org.apache.maven.doxia.document.DocumentCover) DocumentMeta(org.apache.maven.doxia.document.DocumentMeta) ModelBuilderMavenProjectStub(org.apache.maven.plugins.pdf.stubs.ModelBuilderMavenProjectStub) DocumentModel(org.apache.maven.doxia.document.DocumentModel)

Aggregations

DocumentTOC (org.apache.maven.doxia.document.DocumentTOC)3 DocumentModel (org.apache.maven.doxia.document.DocumentModel)2 ModelBuilderMavenProjectStub (org.apache.maven.plugins.pdf.stubs.ModelBuilderMavenProjectStub)2 File (java.io.File)1 DocumentCover (org.apache.maven.doxia.document.DocumentCover)1 DocumentMeta (org.apache.maven.doxia.document.DocumentMeta)1 DocumentTOCItem (org.apache.maven.doxia.document.DocumentTOCItem)1 DecorationModel (org.apache.maven.doxia.site.decoration.DecorationModel)1 Menu (org.apache.maven.doxia.site.decoration.Menu)1 MenuItem (org.apache.maven.doxia.site.decoration.MenuItem)1