All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.mapway.document.helper.html.ApiDoc2Html Maven / Gradle / Ivy

There is a newer version: 3.20.0
Show 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);
        }
    }


}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy