Skip to content
Snippets Groups Projects
Commit 1c70c416 authored by Jesper's avatar Jesper
Browse files

Add -ragroot option

parent 787f780c
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,7 @@ repositories {
apply plugin: 'java'
apply plugin: 'jastadd'
apply plugin: 'maven'
version = '1.3.0'
group = 'org.extendj'
......
......@@ -73,15 +73,6 @@ public class RagDocBuilder extends Frontend {
* @return {@code true} if documentation generation succeeds
*/
public int compile(String[] args) {
// TODO use command-line arg for ragRoot!
// TODO add package exclude argument.
File userDir = new File(System.getProperty("user.dir"));
if (userDir.isDirectory()) {
jsonBuilder = new JsonBuilder(userDir);
} else {
jsonBuilder = new JsonBuilder(new File("."));
}
ASTNode.jsonBuilder = jsonBuilder;
return run(args, Program.defaultBytecodeReader(), Program.defaultJavaParser());
}
......@@ -90,7 +81,7 @@ public class RagDocBuilder extends Frontend {
long start = System.currentTimeMillis();
int result = super.run(args, reader, parser);
long time = System.currentTimeMillis() - start;
System.out.format("Analysis took %fs%n", time / 1000.0);
System.out.format("Analysis took %.1fs.%n", time / 1000.0);
try {
File outputDir;
if (program.options().hasValueForOption("-d")) {
......@@ -105,6 +96,7 @@ public class RagDocBuilder extends Frontend {
System.err.format("Error: not a valid output directory: '%s'\n", outputDir.getName());
return EXIT_CONFIG_ERROR;
}
System.out.println("Writing ragdoc metadata to: " + outputDir.getPath());
System.out.println("Writing package summary.");
outputJson(outputDir, "packages.json", jsonBuilder.packageIndex());
......@@ -121,7 +113,7 @@ public class RagDocBuilder extends Frontend {
for (Map.Entry<String, File> entry : jsonBuilder.sourceFiles.entrySet()) {
File file = entry.getValue();
String path = entry.getKey();
path = path.replace('/', '_').replace('\\', '_');
path = path.replace('/', '_').replace('\\', '_').replace('.', '_');
copyFile(outputDir, path, file);
}
} catch (IOException e) {
......@@ -181,6 +173,30 @@ public class RagDocBuilder extends Frontend {
@Override protected void initOptions() {
super.initOptions();
program.options().addKeyValueOption("-ragroot");
}
@Override protected int processArgs(String[] args) {
int result = super.processArgs(args);
if (result == 0) {
// TODO add package exclude argument.
File ragRoot;
if (program.options().hasValueForOption("-ragroot")) {
ragRoot = new File(program.options().getValueForOption("-ragroot"));
} else {
System.out.println("No ragroot directory specified. Using default.");
File userDir = new File(System.getProperty("user.dir"));
if (userDir.isDirectory()) {
ragRoot = userDir;
} else {
ragRoot = new File(".");
}
}
System.out.println("Using ragroot directory: " + ragRoot.getAbsolutePath());
jsonBuilder = new JsonBuilder(ragRoot);
ASTNode.jsonBuilder = jsonBuilder;
}
return result;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment