mirror of https://github.com/rusefi/rusefi-1.git
it mostly works!
This commit is contained in:
parent
2fbecab905
commit
4231064431
|
@ -7,6 +7,7 @@ import java.io.IOException;
|
|||
import java.util.Date;
|
||||
|
||||
public class MdGenerator {
|
||||
public static final String PREFIX = "rusEFI-project";
|
||||
static String FOLDER;
|
||||
|
||||
private static final String EOL = "\r\n";
|
||||
|
@ -17,35 +18,70 @@ public class MdGenerator {
|
|||
|
||||
ContentModel contentModel = XmlUtil.readModel();
|
||||
|
||||
FileWriter md = new FileWriter("rusEFI_project.md");
|
||||
generateTopLevel(contentModel);
|
||||
|
||||
for (TopLevelMenuModel topLevelMenuModel : contentModel.getTopLevelMenus()) {
|
||||
md.append("# " + topLevelMenuModel.getTitle() + EOL);
|
||||
md.append(getImageTag(topLevelMenuModel.getImageName()));
|
||||
md.append(EOL);
|
||||
String pageName = getPageName(topLevelMenuModel);
|
||||
FileWriter md = new FileWriter(pageName + ".md");
|
||||
|
||||
md.append("# [rusEFI project](rusEFI-project)"+ EOL);
|
||||
|
||||
md.append("## " + topLevelMenuModel.getTitle() + EOL);
|
||||
|
||||
for (DialogModel dialogModel : topLevelMenuModel.getDialogs()) {
|
||||
md.append("[" + dialogModel.getDialogTitle() + "](" + "#" + safeUrl(dialogModel.getDialogTitle()) + ")" + EOL + EOL);
|
||||
}
|
||||
|
||||
for (TopLevelMenuModel topLevelMenuModel : contentModel.getTopLevelMenus()) {
|
||||
|
||||
md.append("# " + topLevelMenuModel.getTitle() + EOL);
|
||||
|
||||
for (DialogModel dialogModel : topLevelMenuModel.getDialogs()) {
|
||||
appendDialog(md, dialogModel);
|
||||
}
|
||||
}
|
||||
|
||||
md.write(EOL);
|
||||
md.write("generated by " + MdGenerator.class + " on " + new Date());
|
||||
md.write(EOL);
|
||||
md.close();
|
||||
}
|
||||
}
|
||||
|
||||
private static String getPageName(TopLevelMenuModel topLevelMenuModel) {
|
||||
return PREFIX + "-" + safeUrl(topLevelMenuModel.getTitle());
|
||||
}
|
||||
|
||||
private static String safeUrl(String title) {
|
||||
return title.replace(" ", "-");
|
||||
}
|
||||
|
||||
private static void generateTopLevel(ContentModel contentModel) throws IOException {
|
||||
FileWriter md = new FileWriter(PREFIX + ".md");
|
||||
|
||||
for (TopLevelMenuModel topLevelMenuModel : contentModel.getTopLevelMenus()) {
|
||||
md.append("# [" + topLevelMenuModel.getTitle() + "](" + getPageName(topLevelMenuModel) + ")" + EOL + EOL);
|
||||
md.append(getImageTag(topLevelMenuModel.getImageName()));
|
||||
|
||||
for (DialogModel dialogModel : topLevelMenuModel.getDialogs()) {
|
||||
md.append("[" + dialogModel.getDialogTitle() + "](" + getPageName(topLevelMenuModel) + "#" + safeUrl(dialogModel.getDialogTitle()) + ")" + EOL + EOL);
|
||||
}
|
||||
|
||||
md.append(EOL);
|
||||
}
|
||||
md.write(EOL);
|
||||
md.write("generated by " + MdGenerator.class + " on " + new Date());
|
||||
md.write(EOL);
|
||||
md.close();
|
||||
}
|
||||
|
||||
private static void appendDialog(FileWriter md, DialogModel dialogModel) throws IOException {
|
||||
md.append(getImageTag(dialogModel.getImageName()));
|
||||
md.append("### " + dialogModel.getDialogTitle() + EOL);
|
||||
|
||||
md.append(getImageTag(dialogModel.getImageName()) + EOL);
|
||||
|
||||
for (FieldModel fieldModel : dialogModel.fields) {
|
||||
String tooltip = fieldModel.getTooltip();
|
||||
|
||||
if (tooltip.length() > 0) {
|
||||
tooltip = tooltip.replace("\\n", EOL);
|
||||
|
||||
md.append(fieldModel.getUiName() + ": " + tooltip + EOL + EOL);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue