Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,28 @@ public class TOCGenerator {

public static void main(String[] args) throws IOException {
Path root = Paths.get(".").normalize();
new TOCGenerator(Arrays.asList("target", "dist", "template", "guide")).generate(root, "[TOC-quickstart]", Paths.get("README.adoc"), false);
new TOCGenerator(Arrays.asList("target", "dist", "template", "guide")).generate(root, "[TOC-quickstart]", Paths.get("README.adoc"), Paths.get("README.adoc"), false);
}

public TOCGenerator(List<String> ignoredDirs) {
this.ignoredDirs = ignoredDirs;
}

public void generate(Path root, String tocMarker, Path targetDoc, boolean includeOpenshift) throws IOException {
public void generate(Path root, String tocMarker, Path sourceDoc, Path targetDoc, boolean includeOpenshift) throws IOException {
Set<MetaData> allMetaData = new TreeSet<>(Comparator.comparing(MetaData::getName));
try (DirectoryStream<Path> dirs = Files.newDirectoryStream(root, entry -> Files.isDirectory(entry)
&& (!entry.getFileName().toString().startsWith("."))
&& (!ignoredDirs.contains(entry.getFileName().toString())))
) {
dirs.forEach(path -> {
if (Files.exists(path.resolve("README.adoc"))){
if (Files.exists(path.resolve(sourceDoc))){
try {
allMetaData.add(MetaData.parseReadme(path));
} catch (IOException e) {
e.printStackTrace();
}
}else{
System.out.println(String.format("Directory %s doesn't contain README.adoc, skipping", path));
System.out.println(String.format("Directory %s doesn't contain source %s, skipping", path, sourceDoc));
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public class TOCMojo extends AbstractMojo {
@Parameter(defaultValue = "[TOC-quickstart]", required = true)
protected String replaceMarker;

@Parameter(defaultValue = "target/docs/README-source.adoc", required = true)
protected String sourceDocument;

@Parameter(defaultValue = "target/docs/README.adoc", required = true)
protected String targetDocument;

Expand All @@ -49,7 +52,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
getLog().info("root directory: " + root);

try {
generator.generate(root, replaceMarker, Paths.get(targetDocument), includeOpenshift);
generator.generate(root, replaceMarker, Paths.get(sourceDocument), Paths.get(targetDocument), includeOpenshift);
} catch (IOException e) {
throw new MojoFailureException("Could not generate TOC", e);
}
Expand Down