remove flexmark
This commit is contained in:
parent
8f40954f75
commit
c1120f1c81
21
pom.xml
21
pom.xml
|
@ -67,27 +67,6 @@
|
|||
<artifactId>common-util</artifactId>
|
||||
<version>2.0.2</version>
|
||||
</dependency>
|
||||
<!--markdown to html-->
|
||||
<dependency>
|
||||
<groupId>com.vladsch.flexmark</groupId>
|
||||
<artifactId>flexmark</artifactId>
|
||||
<version>${flexmark.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.vladsch.flexmark</groupId>
|
||||
<artifactId>flexmark-util</artifactId>
|
||||
<version>${flexmark.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.vladsch.flexmark</groupId>
|
||||
<artifactId>flexmark-ext-tables</artifactId>
|
||||
<version>${flexmark.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.vladsch.flexmark</groupId>
|
||||
<artifactId>flexmark-ext-gfm-strikethrough</artifactId>
|
||||
<version>${flexmark.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
|
|
|
@ -11,7 +11,7 @@ import com.power.doc.model.*;
|
|||
import com.power.doc.template.SpringBootDocBuildTemplate;
|
||||
import com.power.doc.utils.DocUtil;
|
||||
import com.thoughtworks.qdox.JavaProjectBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
@ -353,7 +353,6 @@ public class OpenApiBuilder {
|
|||
return parametersList;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Map<String, Object> getStringParams(ApiParam apiParam) {
|
||||
Map<String, Object> parameters;
|
||||
parameters = new HashMap<>(20);
|
||||
|
|
|
@ -30,16 +30,13 @@ import com.power.doc.constants.DocLanguage;
|
|||
import com.power.doc.constants.TemplateVariable;
|
||||
import com.power.doc.model.ApiConfig;
|
||||
import com.power.doc.model.ApiErrorCode;
|
||||
import com.power.doc.model.rpc.RpcApiDependency;
|
||||
import com.power.doc.model.rpc.RpcApiDoc;
|
||||
import com.power.doc.template.RpcDocBuildTemplate;
|
||||
import com.power.doc.utils.BeetlTemplateUtil;
|
||||
import com.power.doc.utils.MarkDownUtil;
|
||||
import com.thoughtworks.qdox.JavaProjectBuilder;
|
||||
import org.beetl.core.Template;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static com.power.doc.constants.DocGlobalConstants.*;
|
||||
|
||||
|
@ -153,13 +150,12 @@ public class RpcHtmlBuilder {
|
|||
apiTemplate.binding(TemplateVariable.VERSION.getVariable(), rpcDoc.getVersion());
|
||||
apiTemplate.binding(TemplateVariable.URI.getVariable(), rpcDoc.getUri());
|
||||
|
||||
String html = MarkDownUtil.toHtml(apiTemplate.render());
|
||||
htmlApiDoc = BeetlTemplateUtil.getByName(HTML_API_DOC_TPL);
|
||||
htmlApiDoc.binding(TemplateVariable.HTML.getVariable(), html);
|
||||
htmlApiDoc.binding(TemplateVariable.TITLE.getVariable(), rpcDoc.getDesc());
|
||||
htmlApiDoc.binding(TemplateVariable.CREATE_TIME.getVariable(), strTime);
|
||||
htmlApiDoc.binding(TemplateVariable.VERSION.getVariable(), now);
|
||||
FileUtil.nioWriteFile(htmlApiDoc.render(), outPath + FILE_SEPARATOR + rpcDoc.getShortName() + ".html");
|
||||
// htmlApiDoc = BeetlTemplateUtil.getByName(HTML_API_DOC_TPL);
|
||||
// htmlApiDoc.binding(TemplateVariable.HTML.getVariable(), html);
|
||||
// htmlApiDoc.binding(TemplateVariable.TITLE.getVariable(), rpcDoc.getDesc());
|
||||
// htmlApiDoc.binding(TemplateVariable.CREATE_TIME.getVariable(), strTime);
|
||||
// htmlApiDoc.binding(TemplateVariable.VERSION.getVariable(), now);
|
||||
// FileUtil.nioWriteFile(htmlApiDoc.render(), outPath + FILE_SEPARATOR + rpcDoc.getShortName() + ".html");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,17 +166,17 @@ public class RpcHtmlBuilder {
|
|||
* @param outPath
|
||||
*/
|
||||
private static void buildErrorCodeDoc(List<ApiErrorCode> errorCodeList, String outPath) {
|
||||
if (CollectionUtil.isNotEmpty(errorCodeList)) {
|
||||
Template error = BeetlTemplateUtil.getByName(ERROR_CODE_LIST_MD_TPL);
|
||||
error.binding(TemplateVariable.LIST.getVariable(), errorCodeList);
|
||||
String errorHtml = MarkDownUtil.toHtml(error.render());
|
||||
Template errorCodeDoc = BeetlTemplateUtil.getByName(HTML_API_DOC_TPL);
|
||||
errorCodeDoc.binding(TemplateVariable.VERSION.getVariable(), now);
|
||||
errorCodeDoc.binding(TemplateVariable.HTML.getVariable(), errorHtml);
|
||||
errorCodeDoc.binding(TemplateVariable.TITLE.getVariable(), ERROR_CODE_LIST_EN_TITLE);
|
||||
errorCodeDoc.binding(TemplateVariable.CREATE_TIME.getVariable(), DateTimeUtil.long2Str(now, DateTimeUtil.DATE_FORMAT_SECOND));
|
||||
FileUtil.nioWriteFile(errorCodeDoc.render(), outPath + FILE_SEPARATOR + "error_code.html");
|
||||
}
|
||||
// if (CollectionUtil.isNotEmpty(errorCodeList)) {
|
||||
// Template error = BeetlTemplateUtil.getByName(ERROR_CODE_LIST_MD_TPL);
|
||||
// error.binding(TemplateVariable.LIST.getVariable(), errorCodeList);
|
||||
// String errorHtml = MarkDownUtil.toHtml(error.render());
|
||||
// Template errorCodeDoc = BeetlTemplateUtil.getByName(HTML_API_DOC_TPL);
|
||||
// errorCodeDoc.binding(TemplateVariable.VERSION.getVariable(), now);
|
||||
// errorCodeDoc.binding(TemplateVariable.HTML.getVariable(), errorHtml);
|
||||
// errorCodeDoc.binding(TemplateVariable.TITLE.getVariable(), ERROR_CODE_LIST_EN_TITLE);
|
||||
// errorCodeDoc.binding(TemplateVariable.CREATE_TIME.getVariable(), DateTimeUtil.long2Str(now, DateTimeUtil.DATE_FORMAT_SECOND));
|
||||
// FileUtil.nioWriteFile(errorCodeDoc.render(), outPath + FILE_SEPARATOR + "error_code.html");
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -190,26 +186,26 @@ public class RpcHtmlBuilder {
|
|||
* @param outPath
|
||||
*/
|
||||
private static void buildDependency(ApiConfig config) {
|
||||
List<RpcApiDependency> apiDependencies = config.getRpcApiDependencies();
|
||||
Template template;
|
||||
if (CollectionUtil.isNotEmpty(config.getRpcApiDependencies())) {
|
||||
String rpcConfig = config.getRpcConsumerConfig();
|
||||
String rpcConfigConfigContent = null;
|
||||
if (Objects.nonNull(rpcConfig)) {
|
||||
rpcConfigConfigContent = FileUtil.getFileContent(rpcConfig);
|
||||
}
|
||||
template = BeetlTemplateUtil.getByName(RPC_DEPENDENCY_MD_TPL);
|
||||
template.binding(TemplateVariable.RPC_CONSUMER_CONFIG.getVariable(), rpcConfigConfigContent);
|
||||
template.binding(TemplateVariable.DEPENDENCY_LIST.getVariable(), apiDependencies);
|
||||
} else {
|
||||
template = BeetlTemplateUtil.getByName(RPC_DEPENDENCY_EMPTY_MD_TPL);
|
||||
}
|
||||
String dictHtml = MarkDownUtil.toHtml(template.render());
|
||||
Template dictTpl = BeetlTemplateUtil.getByName(HTML_API_DOC_TPL);
|
||||
dictTpl.binding(TemplateVariable.VERSION.getVariable(), now);
|
||||
dictTpl.binding(TemplateVariable.TITLE.getVariable(), DICT_EN_TITLE);
|
||||
dictTpl.binding(TemplateVariable.HTML.getVariable(), dictHtml);
|
||||
dictTpl.binding(TemplateVariable.CREATE_TIME.getVariable(), DateTimeUtil.long2Str(now, DateTimeUtil.DATE_FORMAT_SECOND));
|
||||
FileUtil.nioWriteFile(dictTpl.render(), config.getOutPath() + FILE_SEPARATOR + "dependency.html");
|
||||
// List<RpcApiDependency> apiDependencies = config.getRpcApiDependencies();
|
||||
// Template template;
|
||||
// if (CollectionUtil.isNotEmpty(config.getRpcApiDependencies())) {
|
||||
// String rpcConfig = config.getRpcConsumerConfig();
|
||||
// String rpcConfigConfigContent = null;
|
||||
// if (Objects.nonNull(rpcConfig)) {
|
||||
// rpcConfigConfigContent = FileUtil.getFileContent(rpcConfig);
|
||||
// }
|
||||
// template = BeetlTemplateUtil.getByName(RPC_DEPENDENCY_MD_TPL);
|
||||
// template.binding(TemplateVariable.RPC_CONSUMER_CONFIG.getVariable(), rpcConfigConfigContent);
|
||||
// template.binding(TemplateVariable.DEPENDENCY_LIST.getVariable(), apiDependencies);
|
||||
// } else {
|
||||
// template = BeetlTemplateUtil.getByName(RPC_DEPENDENCY_EMPTY_MD_TPL);
|
||||
// }
|
||||
// String dictHtml = MarkDownUtil.toHtml(template.render());
|
||||
// Template dictTpl = BeetlTemplateUtil.getByName(HTML_API_DOC_TPL);
|
||||
// dictTpl.binding(TemplateVariable.VERSION.getVariable(), now);
|
||||
// dictTpl.binding(TemplateVariable.TITLE.getVariable(), DICT_EN_TITLE);
|
||||
// dictTpl.binding(TemplateVariable.HTML.getVariable(), dictHtml);
|
||||
// dictTpl.binding(TemplateVariable.CREATE_TIME.getVariable(), DateTimeUtil.long2Str(now, DateTimeUtil.DATE_FORMAT_SECOND));
|
||||
// FileUtil.nioWriteFile(dictTpl.render(), config.getOutPath() + FILE_SEPARATOR + "dependency.html");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
*/
|
||||
package com.power.doc.model;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
@ -99,7 +98,7 @@ public class ApiDoc implements Comparable<ApiDoc> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@NotNull ApiDoc o) {
|
||||
public int compareTo(ApiDoc o) {
|
||||
if (Objects.nonNull(o.getDesc())) {
|
||||
return desc.compareTo(o.getDesc());
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.power.doc.model.rpc;
|
||||
|
||||
import com.power.doc.model.JavaMethodDoc;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
@ -158,7 +157,7 @@ public class RpcApiDoc implements Comparable<RpcApiDoc> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(@NotNull RpcApiDoc o) {
|
||||
public int compareTo(RpcApiDoc o) {
|
||||
if (Objects.nonNull(o.getDesc())) {
|
||||
return desc.compareTo(o.getDesc());
|
||||
}
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* smart-doc
|
||||
*
|
||||
* Copyright (C) 2018-2020 smart-doc
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package com.power.doc.utils;
|
||||
|
||||
import com.vladsch.flexmark.ext.gfm.strikethrough.StrikethroughExtension;
|
||||
import com.vladsch.flexmark.ext.tables.TablesExtension;
|
||||
import com.vladsch.flexmark.html.HtmlRenderer;
|
||||
import com.vladsch.flexmark.parser.Parser;
|
||||
import com.vladsch.flexmark.parser.ParserEmulationProfile;
|
||||
import com.vladsch.flexmark.util.ast.Node;
|
||||
import com.vladsch.flexmark.util.data.MutableDataSet;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author yu 2019/9/21.
|
||||
* @since 1.7+
|
||||
*/
|
||||
public class MarkDownUtil {
|
||||
|
||||
/**
|
||||
* Convert markdown to html.
|
||||
*
|
||||
* @param content markdown contents
|
||||
* @return html contents
|
||||
*/
|
||||
public static String toHtml(String content) {
|
||||
MutableDataSet options = new MutableDataSet();
|
||||
options.setFrom(ParserEmulationProfile.MARKDOWN);
|
||||
// enable table parse!
|
||||
options.set(Parser.EXTENSIONS, Arrays.asList(TablesExtension.create(), StrikethroughExtension.create()));
|
||||
|
||||
Parser parser = Parser.builder(options).build();
|
||||
HtmlRenderer renderer = HtmlRenderer.builder(options).build();
|
||||
|
||||
Node document = parser.parse(content);
|
||||
return renderer.render(document);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package com.power.doc.util;
|
||||
|
||||
import com.power.common.util.FileUtil;
|
||||
import com.power.doc.utils.MarkDownUtil;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
|
@ -13,8 +12,5 @@ public class MarkDownUtilTest {
|
|||
@Test
|
||||
public void testToHtml() {
|
||||
|
||||
String file = FileUtil.getFileContent("D:\\md\\AllInOne-V201909272232.md");
|
||||
String html = MarkDownUtil.toHtml(file);
|
||||
System.out.println(html);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue