cn.mapway.document.helper.html.ApiDoc2Html Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of api-tools-doc Show documentation
Show all versions of api-tools-doc Show documentation
auto gen doc from api with ui
The newest version!
package cn.mapway.document.helper.html;
import cn.mapway.document.module.ApiDoc;
import cn.mapway.document.module.Entry;
import cn.mapway.document.module.Group;
import java.util.logging.Logger;
/**
* ApiDoc 转 Html
*/
public class ApiDoc2Html {
private static Logger logger = Logger.getLogger(ApiDoc2Html.class.toGenericString());
public ApiDoc2Html() {
}
/**
* 转换文档
*
* @param doc
* @return
*/
public String convert(ApiDoc doc) {
StringBuilder html = new StringBuilder();
html.append("");
html.append("");
html.append("");
html.append("");
html.append("");
HtmlCatalog catalog = new HtmlCatalog();
catalog.parse(doc.root);
html.append(catalog.toString());
exportEntry(html, doc.root);
html.append("");
html.append("");
return html.toString();
}
private void exportEntry(StringBuilder html, Group root) {
for (Entry entry : root.entries) {
logger.info("===>export entry input size " + entry.input.size());
HtmlEntry htmlEntry = new HtmlEntry(entry);
html.append(htmlEntry.toHTML());
}
for (Group subGroup : root.getChildGroups()) {
exportEntry(html, subGroup);
}
}
}