Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ASDoc generation and inclusion options #706

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
19 changes: 18 additions & 1 deletion asconfigc/src/main/java/com/as3mxml/asconfigc/ASConfigC.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import com.as3mxml.asconfigc.air.AIROptionsParser;
import com.as3mxml.asconfigc.air.AIRSigningOptions;
import com.as3mxml.asconfigc.animate.AnimateOptions;
import com.as3mxml.asconfigc.compiler.ASDocOptions;
import com.as3mxml.asconfigc.compiler.CompilerOptions;
import com.as3mxml.asconfigc.compiler.CompilerOptionsParser;
import com.as3mxml.asconfigc.compiler.ConfigName;
Expand Down Expand Up @@ -242,6 +243,7 @@ public ASConfigC(ASConfigCOptions options) throws ASConfigCException {

private ASConfigCOptions options;
private List<String> compilerOptions;
private List<String> asdocOptions;
private List<List<String>> allModuleCompilerOptions;
private List<List<String>> allWorkerCompilerOptions;
private List<String> airOptions;
Expand All @@ -250,6 +252,7 @@ public ASConfigC(ASConfigCOptions options) throws ASConfigCException {
private String projectType;
private boolean clean;
private boolean watch;
private boolean includeAsdoc;
private boolean debugBuild;
private boolean copySourcePathAssets;
private String jsOutputType;
Expand Down Expand Up @@ -378,6 +381,7 @@ private void parseConfig(JsonNode json) throws ASConfigCException {
debugBuild = options.debug != null && options.debug.equals(true);
}
compilerOptions = new ArrayList<>();
asdocOptions = new ArrayList<>();
allModuleCompilerOptions = new ArrayList<>();
allWorkerCompilerOptions = new ArrayList<>();
if (options.debug != null) {
Expand All @@ -393,6 +397,7 @@ private void parseConfig(JsonNode json) throws ASConfigCException {
String configName = json.get(TopLevelFields.CONFIG).asText();
detectConfigRequirements(configName);
compilerOptions.add("+configname=" + configName);
asdocOptions.add("+configname=" + configName);
}
if (json.has(TopLevelFields.COMPILER_OPTIONS)) {
compilerOptionsJSON = json.get(TopLevelFields.COMPILER_OPTIONS);
Expand All @@ -412,6 +417,13 @@ private void parseConfig(JsonNode json) throws ASConfigCException {
jsOutputPath = compilerOptionsJSON.get(CompilerOptions.JS_OUTPUT).asText();
}
}
if (json.has(TopLevelFields.ASDOC_OPTIONS)) {
JsonNode asdocOptionsJSON = json.get(TopLevelFields.ASDOC_OPTIONS);
CompilerOptionsParser.parseASDoc(asdocOptionsJSON, asdocOptions);
if (asdocOptionsJSON.has(ASDocOptions.INCLUDE)) {
includeAsdoc = asdocOptionsJSON.get(ASDocOptions.INCLUDE).asBoolean();
}
}
if (json.has(TopLevelFields.ADDITIONAL_OPTIONS)) {
JsonNode jsonAdditionalOptions = json.get(TopLevelFields.ADDITIONAL_OPTIONS);
if (jsonAdditionalOptions.isArray()) {
Expand Down Expand Up @@ -845,6 +857,7 @@ private void readCompilerOptions(JsonNode compilerOptionsJson) throws ASConfigCE
CompilerOptionsParser parser = new CompilerOptionsParser();
try {
parser.parse(compilerOptionsJson, options.debug, compilerOptions);
parser.parseForASDoc(compilerOptionsJson, asdocOptions);
} catch (Exception e) {
StringWriter stackTrace = new StringWriter();
e.printStackTrace(new PrintWriter(stackTrace));
Expand Down Expand Up @@ -1079,6 +1092,10 @@ private void compileProject() throws ASConfigCException {
List<String> moduleCompilerOptions = allModuleCompilerOptions.get(i);
options.compiler.compile(projectType, moduleCompilerOptions, workspacePath, sdkPath);
}

if (includeAsdoc && swfOutputPath != null) {
options.compiler.buildASDoc(projectType, swfOutputPath, asdocOptions, workspacePath, sdkPath);
}
}

private void copySourcePathAssetToOutputDirectory(String assetPath, String mainFile, List<String> sourcePaths,
Expand Down Expand Up @@ -1645,4 +1662,4 @@ private void packageAIR() throws ASConfigCException {
throw new ASConfigCException("Failed to execute Adobe AIR Packager: " + e.getMessage());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ public class TopLevelFields {
public static final String MAIN_CLASS = "mainClass";
public static final String MODULES = "modules";
public static final String WORKERS = "workers";
}
public static final String ASDOC_OPTIONS = "asdocOptions";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.as3mxml.asconfigc.compiler;

public class ASDocOptions {
public static final String INCLUDE = "include";
public static final String DOC_SOURCES = "doc-sources";
public static final String DOC_CLASSES = "doc-classes";
public static final String DOC_NAMESPACES = "doc-namespaces";
}
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,162 @@ public void parse(JsonNode options, Boolean debugBuild, List<String> result) thr
}
}

public void parseForASDoc(JsonNode options, List<String> result)
throws UnknownCompilerOptionException {
Iterator<String> iterator = options.fieldNames();
while (iterator.hasNext()) {
String key = iterator.next();
switch (key) {
case CompilerOptions.DEFINE: {
setDefine(key, options.get(key), result);
break;
}
case CompilerOptions.EXTERNAL_LIBRARY_PATH: {
List<String> values = JsonUtils.jsonNodeToListOfStrings(options.get(key));
OptionsFormatter.appendPaths(key, values, result);
break;
}
case CompilerOptions.INCLUDE_LIBRARIES: {
List<String> values = JsonUtils.jsonNodeToListOfStrings(options.get(key));
OptionsFormatter.appendPaths(key, values, result);
break;
}
case CompilerOptions.LIBRARY_PATH: {
List<String> values = JsonUtils.jsonNodeToListOfStrings(options.get(key));
OptionsFormatter.appendPaths(key, values, result);
break;
}
case CompilerOptions.LOAD_CONFIG: {
List<String> values = JsonUtils.jsonNodeToListOfStrings(options.get(key));
OptionsFormatter.appendPaths(key, values, result);
break;
}
case CompilerOptions.STRICT: {
OptionsFormatter.setBoolean(key, options.get(key).asBoolean(), result);
break;
}
case CompilerOptions.SOURCE_PATH: {
List<String> values = JsonUtils.jsonNodeToListOfStrings(options.get(key));
OptionsFormatter.appendPaths(key, values, result);
break;
}
case CompilerOptions.ACCESSIBLE:
case CompilerOptions.ADVANCED_TELEMETRY:
case CompilerOptions.ALLOW_ABSTRACT_CLASSES:
case CompilerOptions.ALLOW_IMPORT_ALIASES:
case CompilerOptions.ALLOW_PRIVATE_CONSTRUCTORS:
case CompilerOptions.BENCHMARK:
case CompilerOptions.DEBUG:
case CompilerOptions.DEBUG_PASSWORD:
case CompilerOptions.DEFAULT_BACKGROUND_COLOR:
case CompilerOptions.DEFAULT_FRAME_RATE:
case CompilerOptions.DEFAULT_SIZE:
case CompilerOptions.DEFAULTS_CSS_FILES:
case CompilerOptions.JS_DEFINE:
case CompilerOptions.DIRECTORY:
case CompilerOptions.DUMP_CONFIG:
case CompilerOptions.EXCLUDE_DEFAULTS_CSS_FILES:
case CompilerOptions.EXPORT_PUBLIC_SYMBOLS:
case CompilerOptions.EXPORT_PROTECTED_SYMBOLS:
case CompilerOptions.EXPORT_INTERNAL_SYMBOLS:
case CompilerOptions.HTML_OUTPUT_FILENAME:
case CompilerOptions.HTML_TEMPLATE:
case CompilerOptions.INCLUDE_CLASSES:
case CompilerOptions.INCLUDE_FILE:
case CompilerOptions.INCLUDE_NAMESPACES:
case CompilerOptions.INCLUDE_SOURCES:
case CompilerOptions.INLINE_CONSTANTS:
case CompilerOptions.JS_COMPILER_OPTION:
case CompilerOptions.JS_COMPLEX_IMPLICIT_COERCIONS:
case CompilerOptions.JS_DEFAULT_INITIALIZERS:
case CompilerOptions.JS_DYNAMIC_ACCESS_UNKNOWN_MEMBERS:
case CompilerOptions.JS_EXTERNAL_LIBRARY_PATH:
case CompilerOptions.JS_LIBRARY_PATH:
case CompilerOptions.JS_OUTPUT:
case CompilerOptions.JS_OUTPUT_OPTIMIZATION:
case CompilerOptions.JS_OUTPUT_TYPE:
case CompilerOptions.JS_VECTOR_EMULATION_CLASS:
case CompilerOptions.JS_VECTOR_INDEX_CHECKS:
case CompilerOptions.KEEP_ALL_TYPE_SELECTORS:
case CompilerOptions.KEEP_AS3_METADATA:
case CompilerOptions.KEEP_GENERATED_ACTIONSCRIPT:
case CompilerOptions.LINK_REPORT:
case CompilerOptions.JS_LOAD_CONFIG:
case CompilerOptions.LOAD_EXTERNS:
case CompilerOptions.LOCALE:
case CompilerOptions.NAMESPACE:
case CompilerOptions.OPTIMIZE:
case CompilerOptions.OMIT_TRACE_STATEMENTS:
case CompilerOptions.OUTPUT:
case CompilerOptions.PRELOADER:
case CompilerOptions.PREVENT_RENAME_PUBLIC_SYMBOLS:
case CompilerOptions.PREVENT_RENAME_PUBLIC_STATIC_METHODS:
case CompilerOptions.PREVENT_RENAME_PUBLIC_INSTANCE_METHODS:
case CompilerOptions.PREVENT_RENAME_PUBLIC_STATIC_VARIABLES:
case CompilerOptions.PREVENT_RENAME_PUBLIC_INSTANCE_VARIABLES:
case CompilerOptions.PREVENT_RENAME_PUBLIC_STATIC_ACCESSORS:
case CompilerOptions.PREVENT_RENAME_PUBLIC_INSTANCE_ACCESSORS:
case CompilerOptions.PREVENT_RENAME_PROTECTED_SYMBOLS:
case CompilerOptions.PREVENT_RENAME_PROTECTED_STATIC_METHODS:
case CompilerOptions.PREVENT_RENAME_PROTECTED_INSTANCE_METHODS:
case CompilerOptions.PREVENT_RENAME_PROTECTED_STATIC_VARIABLES:
case CompilerOptions.PREVENT_RENAME_PROTECTED_INSTANCE_VARIABLES:
case CompilerOptions.PREVENT_RENAME_PROTECTED_STATIC_ACCESSORS:
case CompilerOptions.PREVENT_RENAME_PROTECTED_INSTANCE_ACCESSORS:
case CompilerOptions.PREVENT_RENAME_INTERNAL_SYMBOLS:
case CompilerOptions.PREVENT_RENAME_INTERNAL_STATIC_METHODS:
case CompilerOptions.PREVENT_RENAME_INTERNAL_INSTANCE_METHODS:
case CompilerOptions.PREVENT_RENAME_INTERNAL_STATIC_VARIABLES:
case CompilerOptions.PREVENT_RENAME_INTERNAL_INSTANCE_VARIABLES:
case CompilerOptions.PREVENT_RENAME_INTERNAL_STATIC_ACCESSORS:
case CompilerOptions.PREVENT_RENAME_INTERNAL_INSTANCE_ACCESSORS:
case CompilerOptions.REMOVE_CIRCULARS:
case CompilerOptions.SHOW_UNUSED_TYPE_SELECTOR_WARNINGS:
case CompilerOptions.SIZE_REPORT:
case CompilerOptions.SOURCE_MAP:
case CompilerOptions.SOURCE_MAP_SOURCE_ROOT:
case CompilerOptions.STATIC_LINK_RUNTIME_SHARED_LIBRARIES:
case CompilerOptions.STRICT_IDENTIFIER_NAMES:
case CompilerOptions.SWF_EXTERNAL_LIBRARY_PATH:
case CompilerOptions.SWF_LIBRARY_PATH:
case CompilerOptions.SWF_VERSION:
case CompilerOptions.TARGET_PLAYER:
case CompilerOptions.TARGETS:
case CompilerOptions.THEME:
case CompilerOptions.TOOLS_LOCALE:
case CompilerOptions.USE_DIRECT_BLIT:
case CompilerOptions.USE_GPU:
case CompilerOptions.USE_NETWORK:
case CompilerOptions.USE_RESOURCE_BUNDLE_METADATA:
case CompilerOptions.VERBOSE_STACKTRACES:
case CompilerOptions.WARNINGS:
case CompilerOptions.WARN_PUBLIC_VARS:
break;
default: {
throw new UnknownCompilerOptionException(key);
}
}
}
}

public static void parseASDoc(JsonNode options, List<String> result) {
if (options.has(ASDocOptions.DOC_SOURCES)) {
for (String source : JsonUtils.jsonNodeToListOfStrings(options.get(ASDocOptions.DOC_SOURCES))) {
result.add(0, "-doc-sources+=" + source);
}
}
if (options.has(ASDocOptions.DOC_CLASSES)) {
for (String source : JsonUtils.jsonNodeToListOfStrings(options.get(ASDocOptions.DOC_CLASSES))) {
result.add(0, "-doc-classes+=" + source);
}
}
if (options.has(ASDocOptions.DOC_NAMESPACES)) {
for (String source : JsonUtils.jsonNodeToListOfStrings(options.get(ASDocOptions.DOC_NAMESPACES))) {
result.add(0, "-doc-namespaces+=" + source);
}
}
}

private void appendNamespace(JsonNode values, List<String> result) {
int size = values.size();
if (size == 0) {
Expand Down Expand Up @@ -578,4 +734,4 @@ private void parseIncludeFile(JsonNode files, List<String> result) {
result.add("--" + CompilerOptions.INCLUDE_FILE + "+=" + dest + "," + src);
}
}
}
}
Loading