Skip to content

Commit

Permalink
支持生成 http client, 修复解析参数注释 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzhihang committed Jun 17, 2022
1 parent 4535d80 commit 1fc5c6b
Show file tree
Hide file tree
Showing 48 changed files with 746 additions and 376 deletions.
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group 'com.liuzhihang'
version '1.2.9'
version '1.3.0'

JavaVersion.VERSION_11

Expand All @@ -24,6 +24,7 @@ dependencies {
// See https://github.com/JetBrains/gradle-intellij-plugin/
intellij {
version = '2022.1'
// type = "IU"
plugins = ['com.intellij.java', 'markdown']
pluginName = 'Doc View'
updateSinceUntilBuild = false
Expand Down
12 changes: 6 additions & 6 deletions parts/changeNotes.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@

<h4>English introduction</h4>
<ul>
<li>1.2.9
<li>1.3.0
<ol>
<li>Tuning file cache in x "Scratches and Consoles"</li>
<li>Support double-click to open the document</li>
<li>Support generate http client</li>
<li>Fix Annotation Parsing Parameter Exception</li>
</ol>
</li>
<li><a href="https://github.com/liuzhihang/doc-view/blob/master/doc/ChangeNotes.md">More records</a></li>
</ul>
<h4>中文介绍</h4>
<ul>
<li>1.2.9
<li>1.3.0
<ol>
<li>调整文件缓存在 "Scratches and Consoles" 中</li>
<li>支持双击打开文档</li>
<li>支持生成 http client</li>
<li>修复注释解析参数异常</li>
</ol>
</li>
<li><a href="https://github.com/liuzhihang/doc-view/blob/master/doc/ChangeNotes.md">更多记录</a></li>
Expand Down
12 changes: 5 additions & 7 deletions parts/pluginDescription.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ <h1>Generate Markdown documents based on the interface</h1>
<li>Supports viewing Markdown source code, previewing Markdown, editing interface fields, etc.</li>
<li>Support custom configuration Markdown template</li>
<li>Support exporting Markdown files to local</li>
<li>Support uploading interface documents to YApi</li>
<li>Support uploading interface documents to ShowDoc</li>
<li>Support uploading interface documents to Yuque</li>
<li>Support uploading interface documents to YApi,ShowDoc,Yuque</li>
<li>Generate Http Client</li>
</ul>
<br/>

Expand All @@ -33,17 +32,16 @@ <h1>Generate Markdown documents based on the interface</h1>
<br/>
<br/>

基于接口生成 Markdown 文档, 支持预览、编辑以及上传到YApi、ShowDoc。
基于接口生成 Markdown 文档, 支持预览、编辑以及上传到YApi、ShowDoc、语雀
<br/>
<br/>
<ul>
<li>Controller/Dubbo 接口生成Markdown文档</li>
<li>支持查看 Markdown 源码, 预览 Markdown, 编辑接口字段等</li>
<li>支持自定义配置 Markdown 模版</li>
<li>支持导出 Markdown 文件到本地</li>
<li>支持上传接口文档到 YApi</li>
<li>支持上传接口文档到 ShowDoc</li>
<li>支持上传到语雀</li>
<li>支持上传到 YApi、ShowDoc、语雀</li>
<li>生成 Http Client</li>
</ul>
<br/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {

if (selectedNode instanceof DocViewNode) {
DocViewNode docViewNode = (DocViewNode) selectedNode;
CustomFileUtils.delete(project, docViewNode.cachePath(project));
CustomFileUtils.delete(project, docViewNode.docPath(project));

}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.liuzhihang.doc.view.action.toolbar.window.catalog;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.PlatformDataKeys;
import com.intellij.openapi.project.Project;
import com.intellij.ui.TreeExpandCollapse;
import com.intellij.ui.treeStructure.SimpleNode;
import com.intellij.ui.treeStructure.SimpleTree;
import com.liuzhihang.doc.view.data.DocViewDataKeys;
import com.liuzhihang.doc.view.ui.window.MethodNode;
import com.liuzhihang.doc.view.utils.CustomFileUtils;

/**
* window 窗口目录树, 右键生成 HttpClient 功能
*
* @author liuzhihang
* @version CatalogHttpClientAction.java, v 0.1 2022/6/16 17:53 liuzhihang
*/
public class CatalogHttpClientAction extends AnAction {

@Override
public void actionPerformed(AnActionEvent e) {

// 获取当前project对象
Project project = e.getData(PlatformDataKeys.PROJECT);
SimpleTree simpleTree = e.getData(DocViewDataKeys.WINDOW_CATALOG_TREE);

if (simpleTree == null || project == null) {
return;
}

SimpleNode selectedNode = simpleTree.getSelectedNode();

if (selectedNode instanceof MethodNode) {
MethodNode methodNode = (MethodNode) selectedNode;
CustomFileUtils.openHttp(project, methodNode);
} else {
TreeExpandCollapse.expandAll(simpleTree);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,11 @@ public void actionPerformed(@NotNull AnActionEvent e) {

if (selectedNode instanceof MethodNode) {
MethodNode methodNode = (MethodNode) selectedNode;
CustomFileUtils.open(methodNode, project);
CustomFileUtils.openMd(project, methodNode);
} else {
TreeExpandCollapse.expandAll(simpleTree);
}

}


}
7 changes: 7 additions & 0 deletions src/main/java/com/liuzhihang/doc/view/constant/Constant.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.liuzhihang.doc.view.constant;

/**
* 常量
*
* @author liuzhihang
* @date 2021/8/5 18:12
*/
Expand All @@ -9,4 +11,9 @@ private Constant() {
}

public static final String DOC_VIEW = "DocView";

/**
* 返回 void
*/
public static final String RETURN_VOID = "void";
}
24 changes: 24 additions & 0 deletions src/main/java/com/liuzhihang/doc/view/constant/MethodConstant.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Ant Group
* Copyright (c) 2004-2022 All Rights Reserved.
*/
package com.liuzhihang.doc.view.constant;

/**
* 方法常量
*
* @author liuzhihang
* @version MethodConstant.java, v 0.1 2022年06月17日 11:55 AM zijun.lzh
*/
public final class MethodConstant {

public static final String GET = "GET";
public static final String POST = "POST";
public static final String PUT = "PUT";
public static final String DELETE = "DELETE";
public static final String HEAD = "HEAD";
public static final String OPTIONS = "OPTIONS";
public static final String PATCH = "PATCH";
public static final String DUBBO = "DUBBO";

}
27 changes: 21 additions & 6 deletions src/main/java/com/liuzhihang/doc/view/constant/SpringConstant.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.liuzhihang.doc.view.constant;

import java.util.ArrayList;
import java.util.List;

/**
* @author liuzhihang
* @date 2020/3/4 13:44
Expand Down Expand Up @@ -55,15 +58,27 @@ private SpringConstant() {
/**
* other
*/
public static final String CONTROLLER_ADVICE = "org.springframework.web.bind.annotation.ControllerAdvice";
public static final String CONTROLLER_ADVICE = "org.springframework.web.bind.annotation.ControllerAdvice";
public static final String REST_CONTROLLER_ADVICE = "org.springframework.web.bind.annotation.RestControllerAdvice";
public static final String COOKIE_VALUE = "org.springframework.web.bind.annotation.CookieValue";
public static final String CROSS_ORIGIN = "org.springframework.web.bind.annotation.CrossOrigin";
public static final String COOKIE_VALUE = "org.springframework.web.bind.annotation.CookieValue";
public static final String CROSS_ORIGIN = "org.springframework.web.bind.annotation.CrossOrigin";

public static final String EXCEPTION_HANDLER = "org.springframework.web.bind.annotation.ExceptionHandler";
public static final String INIT_BINDER = "org.springframework.web.bind.annotation.InitBinder";
public static final String MATRIX_VARIABLE = "org.springframework.web.bind.annotation.MatrixVariable";
public static final String MODEL_ATTRIBUTE = "org.springframework.web.bind.annotation.ModelAttribute";
public static final String INIT_BINDER = "org.springframework.web.bind.annotation.InitBinder";
public static final String MATRIX_VARIABLE = "org.springframework.web.bind.annotation.MatrixVariable";
public static final String MODEL_ATTRIBUTE = "org.springframework.web.bind.annotation.ModelAttribute";

/**
* Spring Mapping 注解列表
*/
public static final List<String> MAPPING_ANNOTATIONS = new ArrayList<>() {{

add(GET_MAPPING);
add(POST_MAPPING);
add(PUT_MAPPING);
add(DELETE_MAPPING);
add(PATCH_MAPPING);
add(REQUEST_MAPPING);
}};

}
25 changes: 14 additions & 11 deletions src/main/java/com/liuzhihang/doc/view/dto/DocView.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiMethod;
import com.liuzhihang.doc.view.enums.ContentTypeEnum;
import com.liuzhihang.doc.view.enums.FrameworkEnum;
import lombok.Data;

import java.util.List;
Expand Down Expand Up @@ -76,38 +78,40 @@ public class DocView {
*/
private String changeLog;


/**
* headers
*/
private List<Header> headerList;


/**
* 请求参数
*/
private Body reqRootBody = new Body();
private Body reqBody = new Body();

/**
* 返回参数
*/
private Body respRootBody = new Body();

private Body respBody = new Body();

/**
* 请求参数
*/
private List<Param> reqParamList;

/**
* 参数时Json时举例
* body 参数
*/
private String reqExample;
private String reqBodyExample;

/**
* reqExampleType 类型
* form 参数
*/
private String reqExampleType;
private String reqFormExample;

/**
* 请求参数类型 json/form
*/
private ContentTypeEnum contentType;

/**
* 返回参数
Expand All @@ -119,7 +123,7 @@ public class DocView {
*/
private String remark;

private String type;
private FrameworkEnum type;

public DocView(String name) {
this.name = name;
Expand All @@ -128,5 +132,4 @@ public DocView(String name) {
public DocView() {
}


}
Loading

0 comments on commit 1fc5c6b

Please sign in to comment.