Search in sources :

Example 1 with ApiFolderObject

use of com.terran4j.commons.api2doc.domain.ApiFolderObject in project commons by terran4j.

the class DocPageBuilder method doc2HtmlPage.

public String doc2HtmlPage(String folderId, String docId) throws Exception {
    ApiFolderObject folder = apiDocService.getFolder(folderId);
    if (folder == null) {
        if (log.isWarnEnabled()) {
            log.warn("ApiFolder NOT Found: {}", folderId);
        }
        return null;
    }
    ApiDocObject doc = folder.getDoc(docId);
    if (doc == null) {
        if (log.isWarnEnabled()) {
            log.warn("ApiDoc NOT Found: {}", folderId);
        }
        return null;
    }
    String md = doc2Md(folder, doc);
    String title = doc.getName();
    return md2HtmlPage(md, title);
}
Also used : ApiFolderObject(com.terran4j.commons.api2doc.domain.ApiFolderObject) ApiDocObject(com.terran4j.commons.api2doc.domain.ApiDocObject)

Example 2 with ApiFolderObject

use of com.terran4j.commons.api2doc.domain.ApiFolderObject in project commons by terran4j.

the class ApiCommentUtilsTest method testSee.

@Test
public void testSee() throws Exception {
    Api2DocCollector collector = new Api2DocCollector();
    ApiFolderObject folder = collector.toApiFolder(new MyController(), "myController");
    ApiDocObject doc = folder.getDoc("updateUser");
    List<ApiParamObject> params = doc.getParams();
    Assert.assertEquals("用户id", params.get(0).getComment().toString());
    Assert.assertEquals("123", params.get(0).getSample().toString());
    Assert.assertEquals("用户名", params.get(1).getComment().toString());
    Assert.assertEquals("terran4j", params.get(1).getSample().toString());
}
Also used : Api2DocCollector(com.terran4j.commons.api2doc.impl.Api2DocCollector) ApiParamObject(com.terran4j.commons.api2doc.domain.ApiParamObject) ApiFolderObject(com.terran4j.commons.api2doc.domain.ApiFolderObject) ApiDocObject(com.terran4j.commons.api2doc.domain.ApiDocObject) Test(org.junit.Test)

Example 3 with ApiFolderObject

use of com.terran4j.commons.api2doc.domain.ApiFolderObject in project commons by terran4j.

the class ParseApiCommentOnSeeClassLoop method testParseApiCommentOnSeeClassLoop.

@Test
public void testParseApiCommentOnSeeClassLoop() throws Exception {
    log.info("testParseApiCommentOnSeeClass");
    Api2DocCollector collector = new Api2DocCollector();
    ApiFolderObject folder = collector.toApiFolder(new ParseApiCommentOnSeeClassLoop.MyController(), "myController");
    ApiDocObject doc = folder.getDoc("updateUser");
    List<ApiParamObject> params = doc.getParams();
    Assert.assertEquals("用户id", params.get(0).getComment().toString());
    Assert.assertEquals("123", params.get(0).getSample().toString());
    Assert.assertEquals("用户名称", params.get(1).getComment().toString());
    Assert.assertEquals("neo", params.get(1).getSample().toString());
    ApiResultObject user = doc.getResults().get(0);
    ApiResultObject userId = user.getChildren().get(0);
    Assert.assertEquals("id", userId.getId());
    Assert.assertEquals("用户id", userId.getComment().getValue());
    Assert.assertEquals("123", userId.getSample().getValue());
    ApiResultObject userName = user.getChildren().get(1);
    Assert.assertEquals("name", userName.getId());
    Assert.assertEquals("用户名称", userName.getComment().getValue());
    Assert.assertEquals("neo", userName.getSample().getValue());
}
Also used : Api2DocCollector(com.terran4j.commons.api2doc.impl.Api2DocCollector) ApiParamObject(com.terran4j.commons.api2doc.domain.ApiParamObject) ApiFolderObject(com.terran4j.commons.api2doc.domain.ApiFolderObject) ApiDocObject(com.terran4j.commons.api2doc.domain.ApiDocObject) ApiResultObject(com.terran4j.commons.api2doc.domain.ApiResultObject) Test(org.junit.Test)

Example 4 with ApiFolderObject

use of com.terran4j.commons.api2doc.domain.ApiFolderObject in project commons by terran4j.

the class DocMenuBuilder method getMenuGroups.

public List<MenuData> getMenuGroups() {
    List<MenuData> menuGroups = new ArrayList<>();
    List<ApiFolderObject> folders = apiDocService.getFolders();
    if (folders == null || folders.size() == 0) {
        return menuGroups;
    }
    for (ApiFolderObject folder : folders) {
        MenuData menuGroup = getMenuGroup(folder);
        menuGroups.add(menuGroup);
    }
    Collections.sort(menuGroups);
    return menuGroups;
}
Also used : ApiFolderObject(com.terran4j.commons.api2doc.domain.ApiFolderObject) ArrayList(java.util.ArrayList) MenuData(com.terran4j.commons.api2doc.controller.MenuData)

Example 5 with ApiFolderObject

use of com.terran4j.commons.api2doc.domain.ApiFolderObject in project commons by terran4j.

the class DocPageBuilder method mdFile2HtmlPage.

public String mdFile2HtmlPage(String folderId, String docId) throws Exception {
    ApiFolderObject folder = apiDocService.getFolder(folderId);
    if (folder == null) {
        log.warn("ApiFolder NOT Found: {}", folderId);
        return null;
    }
    Map<String, String> mds = folder.getMds();
    if (mds == null || !mds.containsKey(docId)) {
        log.warn("Markdown doc {} NOT Found in Folder: {}", docId, folderId);
        return null;
    }
    String fileName = mds.get(docId);
    String path = folderId + "/" + fileName;
    String html = md2HtmlPageByPath(path);
    return html;
}
Also used : ApiFolderObject(com.terran4j.commons.api2doc.domain.ApiFolderObject)

Aggregations

ApiFolderObject (com.terran4j.commons.api2doc.domain.ApiFolderObject)10 ApiDocObject (com.terran4j.commons.api2doc.domain.ApiDocObject)6 Api2DocCollector (com.terran4j.commons.api2doc.impl.Api2DocCollector)5 Test (org.junit.Test)5 ApiParamObject (com.terran4j.commons.api2doc.domain.ApiParamObject)3 ApiResultObject (com.terran4j.commons.api2doc.domain.ApiResultObject)2 ArrayList (java.util.ArrayList)2 MenuData (com.terran4j.commons.api2doc.controller.MenuData)1