mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-02 02:42:35 +00:00
Merge "Add description field to meta.json file." into main
This commit is contained in:
1
automotive/vehicle/aidl/emu_metadata/.clang-format
Normal file
1
automotive/vehicle/aidl/emu_metadata/.clang-format
Normal file
@@ -0,0 +1 @@
|
||||
DisableFormat: true
|
||||
File diff suppressed because one or more lines are too long
@@ -95,6 +95,8 @@ public final class EmuMetadataGenerator {
|
||||
private static final String CHECK_FILE_PATH =
|
||||
"${ANDROID_BUILD_TOP}/hardware/interfaces/automotive/vehicle/aidl/emu_metadata/"
|
||||
+ "android.hardware.automotive.vehicle-types-meta.json";
|
||||
private static final List<String> ANNOTATIONS =
|
||||
List.of("@change_mode", "@access", "@version", "@data_enum", "@unit");
|
||||
|
||||
// Emulator can display at least this many characters before cutting characters.
|
||||
private static final int MAX_PROPERTY_NAME_LENGTH = 30;
|
||||
@@ -141,6 +143,7 @@ public final class EmuMetadataGenerator {
|
||||
public String name;
|
||||
public Integer value;
|
||||
public final List<String> dataEnums = new ArrayList<>();
|
||||
public String description = "";
|
||||
|
||||
ValueField(String name, Integer value) {
|
||||
this.name = name;
|
||||
@@ -313,14 +316,36 @@ public final class EmuMetadataGenerator {
|
||||
|
||||
int propertyId = parseIntEnumField(propertyDef);
|
||||
// We use the first paragraph as the property's name
|
||||
String propertyDescription = doc.getDescription().toText().split("\n\n")[0];
|
||||
String name = propertyDescription;
|
||||
if (propertyDescription.indexOf("\n") != -1
|
||||
|| propertyDescription.length() > MAX_PROPERTY_NAME_LENGTH) {
|
||||
String propertyDescription = doc.getDescription().toText();
|
||||
String firstLine = propertyDescription.split("\n\n")[0];
|
||||
String name = firstLine;
|
||||
if (firstLine.indexOf("\n") != -1 || firstLine.length() > MAX_PROPERTY_NAME_LENGTH) {
|
||||
// The description is too long, we just use the property name.
|
||||
name = propertyName;
|
||||
}
|
||||
|
||||
ValueField field = new ValueField(name, propertyId);
|
||||
String fieldDescription = "";
|
||||
for (String line : propertyDescription.split("\n")) {
|
||||
String stripped = line.strip();
|
||||
// If this is an empty line, starts a new paragraph.
|
||||
if (stripped.isEmpty()) {
|
||||
fieldDescription += "\n";
|
||||
}
|
||||
// Ignore annotation lines.
|
||||
for (int j = 0; j < ANNOTATIONS.size(); j++) {
|
||||
if (stripped.startsWith(ANNOTATIONS.get(j))) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// If this is a new line, we concat it with the previous line with a space.
|
||||
if (!fieldDescription.isEmpty()
|
||||
&& fieldDescription.charAt(fieldDescription.length() - 1) != '\n') {
|
||||
fieldDescription += " ";
|
||||
}
|
||||
fieldDescription += stripped;
|
||||
}
|
||||
field.description = fieldDescription.strip();
|
||||
|
||||
List<JavadocBlockTag> blockTags = doc.getBlockTags();
|
||||
for (int j = 0; j < blockTags.size(); j++) {
|
||||
@@ -381,6 +406,9 @@ public final class EmuMetadataGenerator {
|
||||
// entry.
|
||||
jsonValueField.put("data_enum", valueField.dataEnums.get(0));
|
||||
}
|
||||
if (!valueField.description.isEmpty()) {
|
||||
jsonValueField.put("description", valueField.description);
|
||||
}
|
||||
values.put(jsonValueField);
|
||||
}
|
||||
|
||||
@@ -390,6 +418,7 @@ public final class EmuMetadataGenerator {
|
||||
try (FileOutputStream outputStream = new FileOutputStream(parsedArgs.output)) {
|
||||
outputStream.write(jsonEnums.toString(4).getBytes());
|
||||
}
|
||||
|
||||
System.out.println("Input at folder: " + parsedArgs.inputDir
|
||||
+ " successfully parsed. Output at: " + parsedArgs.output);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user