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;
}
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());
}
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());
}
Aggregations