Skip to content

Commit

Permalink
Make only-annotated lua inclusion optional
Browse files Browse the repository at this point in the history
Resolves: #54
  • Loading branch information
matshou committed Feb 17, 2021
1 parent 4f27a73 commit 25b06e1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/main/java/io/yooksi/pz/zdoc/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ else if (command == Command.VERSION)
else if (paths.isEmpty()) {
Logger.warn("No files found under path " + root);
}
boolean onlyAnnotated = cmdLine.includeOnlyAnnotated();
Properties properties = Utils.getProperties("annotate.properties");
// process every file found under given root path
for (Path path : paths)
Expand Down Expand Up @@ -164,18 +165,30 @@ else if (dir != null)
case NO_MATCH:
Logger.error(String.format("Failed annotating file \"%s\", " +
"no elements were matched", fileName));
if (!onlyAnnotated) {
writeAnnotatedLinesToFile(content, outputFile);
}
break;
case SKIPPED_FILE_IGNORED:
Logger.info(String.format("Skipped annotating file \"%s\", " +
"file was ignored.", fileName));
if (!onlyAnnotated) {
writeAnnotatedLinesToFile(content, outputFile);
}
break;
case SKIPPED_FILE_EMPTY:
Logger.warn(String.format("Skipped annotating file \"%s\", " +
"file was empty.", fileName));
if (!onlyAnnotated) {
writeAnnotatedLinesToFile(content, outputFile);
}
break;
case ALL_EXCLUDED:
Logger.warn(String.format("Skipped annotating file \"%s\", " +
"all elements were excluded.", fileName));
if (!onlyAnnotated) {
writeAnnotatedLinesToFile(content, outputFile);
}
break;
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/io/yooksi/pz/zdoc/cmd/CommandLine.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ public static void printHelp(Command[] commands) {
}
}

/**
* Return {@code true} if {@link Command#ANNOTATE} should include only lua classes that were
* successfully annotated by {@link io.yooksi.pz.zdoc.compile.LuaAnnotator LuaAnnotator}.
*/
public boolean includeOnlyAnnotated() {
return hasOption(CommandOptions.ONLY_ANNOTATED_OPTION.getOpt());
}

/**
* @return {@code Set} of class names specified in command options to exclude from
* compilation process or an empty list if exclude option has not been set.
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/io/yooksi/pz/zdoc/cmd/CommandOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,20 @@ final class CommandOptions {
"to exclude classes from document generation")
.required(false).hasArg().argName("list").valueSeparator(' ').build();

static final Option ONLY_ANNOTATED_OPTION =
Option.builder("s").longOpt("only-annotated")
.desc("only include classes that were annotated")
.required(false).build();

static final Options LUA_OPTIONS = new Options();
static final Options JAVA_OPTIONS = new Options();

static
{
LUA_OPTIONS.addOption(clone(INPUT_OPTION))
.addOption(clone(OUTPUT_OPTION))
.addOption(clone(EXCLUDE_CLASS_OPTION));
.addOption(clone(EXCLUDE_CLASS_OPTION))
.addOption(ONLY_ANNOTATED_OPTION);

JAVA_OPTIONS.addOption(clone(INPUT_OPTION))
.addOption(clone(OUTPUT_OPTION))
Expand Down

0 comments on commit 25b06e1

Please sign in to comment.