Skip to content
This repository was archived by the owner on Oct 29, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion circumflex-docco/src/main/scala/docco.scala
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ class DoccoBatch {
.map(_.toString).getOrElse("/docco-batch-page.html.ftl")
val indexTemplate: String = cx.get("docco.indexTemplate")
.map(_.toString).getOrElse("/docco-index.html.ftl")
val indexFile: String = cx.get("docco.indexFile")
.map(_.toString).getOrElse("index.html")

// Regex to filter sources
val filenameRegex = cx.get("docco.filenameRegex").map(_.toString)
.getOrElse(".*\\.scala$")
Expand Down Expand Up @@ -264,7 +267,7 @@ class DoccoBatch {
(dirName -> filenames)
}
val dirs = indexMap.keys.toList.sortBy(_.toString)
val out = new FileWriter(new File(outputPath, "index.html"))
val out = new FileWriter(new File(outputPath, indexFile))
try {
var data = Map[String, Any]("dirs" -> dirs, "index" -> indexMap, "title" -> title)
ftlConfig.getTemplate(indexTemplate).process(data, out)
Expand Down
4 changes: 2 additions & 2 deletions circumflex-ftl/src/main/scala/config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import markeven.BlockProcessor
import _root_.freemarker.template._
import _root_.freemarker.core.Environment
import _root_.freemarker.cache._
import java.io.StringWriter
import java.io.{File, StringWriter}

/*!# Default FreeMarker Configuration

Expand Down Expand Up @@ -53,7 +53,7 @@ class DefaultConfiguration extends Configuration {
CX_LOG.warn("Not running in webapp context.")
}
addLoader(new ClassTemplateLoader(getClass, "/"))

addLoader(new FileTemplateLoader(new File("/")))
}

object MarkevenDirective extends TemplateDirectiveModel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,18 @@ protected ClassLoader prepareClassLoader() throws MojoExecutionException {

protected Properties collectProps() {
Properties result = new Properties();
copyProps(getDefaultProperties(), result);
copyProps(project.getProperties(), result);
copyProps(System.getProperties(), result);
return result;
}

private void copyProps(Properties src, Properties dst) {
protected Properties getDefaultProperties()
{
return new Properties();
}

private void copyProps(Properties src, Properties dst) {
for (Object key : src.keySet()) {
String value = src.get(key).toString().trim();
if (skipUnresolved && value.matches(".*\\$\\{.*\\}.*")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import org.apache.maven.plugin.MojoFailureException;
import ru.circumflex.docco.DoccoBatch;
import ru.circumflex.core.Circumflex;

import java.io.File;
import java.util.Properties;

/**
Expand All @@ -16,9 +18,18 @@ public class DoccoMojo extends AbstractCircumflexMojo {
*/
protected String[] customResources;

/**
* @parameter expression="${project.build.sourceDirectory}
*/
protected File sourceDirectory;

/**
* @parameter expression="${project.build.directory}
*/
protected File buildDirectory;

public void execute() throws MojoExecutionException, MojoFailureException {
Thread.currentThread().setContextClassLoader(prepareClassLoader());
if (!project.isExecutionRoot()) return;
// Configure Circumflex
Properties props = collectProps();
for (Object k : props.keySet()) {
Expand All @@ -33,4 +44,13 @@ public void execute() throws MojoExecutionException, MojoFailureException {
getLog().info("Generating docco in " + db.outputPath());
db.generate();
}

@Override
protected Properties getDefaultProperties() {
Properties props = new Properties();
props.setProperty("docco.basePath", sourceDirectory.getParentFile().getAbsolutePath());
props.setProperty("docco.outputPath", new File(buildDirectory, "docco").getAbsolutePath());
props.setProperty("docco.filenameRegex", ".*\\.(java|scala)$");
return props;
}
}