AAPT2: Add option to add JavaDoc annotations to Java classes
Change-Id: I7ee8c20cdd91380927a65c41097ffd3a6ffa2df5
This commit is contained in:
@ -437,6 +437,15 @@ bool JavaClassGenerator::generate(const StringPiece16& packageNameToGenerate, st
|
||||
return generate(packageNameToGenerate, packageNameToGenerate, out);
|
||||
}
|
||||
|
||||
static void appendJavaDocAnnotations(const std::vector<std::string>& annotations,
|
||||
AnnotationProcessor* processor) {
|
||||
for (const std::string& annotation : annotations) {
|
||||
std::string properAnnotation = "@";
|
||||
properAnnotation += annotation;
|
||||
processor->appendComment(properAnnotation);
|
||||
}
|
||||
}
|
||||
|
||||
bool JavaClassGenerator::generate(const StringPiece16& packageNameToGenerate,
|
||||
const StringPiece16& outPackageName, std::ostream* out) {
|
||||
|
||||
@ -477,14 +486,17 @@ bool JavaClassGenerator::generate(const StringPiece16& packageNameToGenerate,
|
||||
mOptions.types == JavaClassGeneratorOptions::SymbolTypes::kPublic) {
|
||||
// When generating a public R class, we don't want Styleable to be part of the API.
|
||||
// It is only emitted for documentation purposes.
|
||||
AnnotationProcessor* processor = classDef->getCommentBuilder();
|
||||
processor->appendComment("@doconly");
|
||||
classDef->getCommentBuilder()->appendComment("@doconly");
|
||||
}
|
||||
|
||||
appendJavaDocAnnotations(mOptions.javadocAnnotations, classDef->getCommentBuilder());
|
||||
|
||||
rClass.addMember(std::move(classDef));
|
||||
}
|
||||
}
|
||||
|
||||
appendJavaDocAnnotations(mOptions.javadocAnnotations, rClass.getCommentBuilder());
|
||||
|
||||
if (!ClassDefinition::writeJavaFile(&rClass, util::utf16ToUtf8(outPackageName),
|
||||
mOptions.useFinal, out)) {
|
||||
return false;
|
||||
@ -494,6 +506,4 @@ bool JavaClassGenerator::generate(const StringPiece16& packageNameToGenerate,
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace aapt
|
||||
|
@ -44,6 +44,11 @@ struct JavaClassGeneratorOptions {
|
||||
};
|
||||
|
||||
SymbolTypes types = SymbolTypes::kAll;
|
||||
|
||||
/**
|
||||
* A list of JavaDoc annotations to add to the comments of all generated classes.
|
||||
*/
|
||||
std::vector<std::string> javadocAnnotations;
|
||||
};
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user