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