Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
apidoc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
apidoc
Commits
bf2a7907
Commit
bf2a7907
authored
Apr 09, 2020
by
duanledexianxianxian
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
♻
Refactoring code.
parent
2b76db72
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
60 additions
and
27 deletions
+60
-27
apidoc-core/src/main/java/com/kim/apidoc/core/common/description/ObjectTypeDescription.java
...apidoc/core/common/description/ObjectTypeDescription.java
+24
-0
apidoc-core/src/main/java/com/kim/apidoc/core/parser/VisitorParser.java
...c/main/java/com/kim/apidoc/core/parser/VisitorParser.java
+18
-19
apidoc-core/src/main/java/com/kim/apidoc/core/schema/Project.java
...ore/src/main/java/com/kim/apidoc/core/schema/Project.java
+5
-1
apidoc-springmvc/src/main/java/com/kim/apidoc/springmvc/SpringParser.java
.../src/main/java/com/kim/apidoc/springmvc/SpringParser.java
+12
-6
apidoc-springmvc/src/test/java/com/kim/apidoc/springmvc/SpringTest.java
...vc/src/test/java/com/kim/apidoc/springmvc/SpringTest.java
+1
-1
No files found.
apidoc-core/src/main/java/com/kim/apidoc/core/common/description/ObjectTypeDescription.java
View file @
bf2a7907
...
@@ -12,19 +12,38 @@ import java.util.List;
...
@@ -12,19 +12,38 @@ import java.util.List;
/**
/**
* 对象类型描述
* 对象类型描述
*
* @author fengyuchenglun
* @version 1.0.0
*/
*/
@Setter
@Setter
@Getter
@Getter
public
class
ObjectTypeDescription
extends
TypeDescription
{
public
class
ObjectTypeDescription
extends
TypeDescription
{
/**
* The Members.
*/
protected
List
<
TypeDescription
>
members
=
Lists
.
newArrayList
();
protected
List
<
TypeDescription
>
members
=
Lists
.
newArrayList
();
/**
* The Value.
*/
private
ObjectNode
value
=
ObjectMappers
.
instance
.
createObjectNode
();
private
ObjectNode
value
=
ObjectMappers
.
instance
.
createObjectNode
();
/**
* Merge.
*
* @param other the other
*/
public
void
merge
(
ObjectTypeDescription
other
)
{
public
void
merge
(
ObjectTypeDescription
other
)
{
value
.
setAll
(
other
.
getValue
());
value
.
setAll
(
other
.
getValue
());
members
.
addAll
(
other
.
members
);
members
.
addAll
(
other
.
members
);
}
}
/**
* Add.
*
* @param component the component
*/
public
void
add
(
TypeDescription
component
)
{
public
void
add
(
TypeDescription
component
)
{
members
.
add
(
component
);
members
.
add
(
component
);
if
(
component
.
isPrimitive
())
{
if
(
component
.
isPrimitive
())
{
...
@@ -38,6 +57,11 @@ public class ObjectTypeDescription extends TypeDescription {
...
@@ -38,6 +57,11 @@ public class ObjectTypeDescription extends TypeDescription {
}
}
}
}
/**
* Primitive.
*
* @param typeDescription the type description
*/
public
void
primitive
(
PrimitiveTypeDescription
typeDescription
)
{
public
void
primitive
(
PrimitiveTypeDescription
typeDescription
)
{
switch
(
typeDescription
.
getType
())
{
switch
(
typeDescription
.
getType
())
{
case
"byte"
:
case
"byte"
:
...
...
apidoc-core/src/main/java/com/kim/apidoc/core/parser/VisitorParser.java
View file @
bf2a7907
package
com.kim.apidoc.core.parser
;
package
com.kim.apidoc.core.parser
;
import
com.github.javaparser.ast.body.ClassOrInterfaceDeclaration
;
import
com.github.javaparser.ast.body.ClassOrInterfaceDeclaration
;
import
com.github.javaparser.ast.body.EnumConstantDeclaration
;
import
com.github.javaparser.ast.body.EnumDeclaration
;
import
com.github.javaparser.ast.body.EnumDeclaration
;
import
com.github.javaparser.ast.body.MethodDeclaration
;
import
com.github.javaparser.ast.body.MethodDeclaration
;
import
com.github.javaparser.ast.comments.Comment
;
import
com.github.javaparser.ast.comments.JavadocComment
;
import
com.github.javaparser.ast.comments.JavadocComment
;
import
com.github.javaparser.ast.visitor.VoidVisitorAdapter
;
import
com.github.javaparser.ast.visitor.VoidVisitorAdapter
;
import
com.github.javaparser.javadoc.Javadoc
;
import
com.github.javaparser.javadoc.JavadocBlockTag
;
import
com.github.javaparser.symbolsolver.core.resolution.Context
;
import
com.kim.apidoc.core.ApiDoc
;
import
com.kim.apidoc.core.ApiDoc
;
import
com.kim.apidoc.core.common.helper.OptionalHelper
;
import
com.kim.apidoc.core.common.helper.OptionalHelper
;
import
com.kim.apidoc.core.schema.*
;
import
com.kim.apidoc.core.schema.*
;
import
java.util.Objects
;
import
java.util.Optional
;
/**
/**
* The type Visitor parser.
* The type Visitor parser.
...
@@ -89,11 +81,11 @@ public class VisitorParser extends VoidVisitorAdapter<Node> {
...
@@ -89,11 +81,11 @@ public class VisitorParser extends VoidVisitorAdapter<Node> {
Chapter
chapter
=
(
Chapter
)
arg
;
Chapter
chapter
=
(
Chapter
)
arg
;
OptionalHelper
.
any
(
chapter
.
getTag
(
"code"
))
OptionalHelper
.
any
(
chapter
.
getTag
(
"code"
))
.
ifPresent
(
tag
->
{
.
ifPresent
(
tag
->
{
if
(
javadocComment
.
getCommentedNode
().
isPresent
()){
if
(
javadocComment
.
getCommentedNode
().
isPresent
())
{
com
.
github
.
javaparser
.
ast
.
Node
commentedNode
=
javadocComment
.
getCommentedNode
().
get
();
com
.
github
.
javaparser
.
ast
.
Node
commentedNode
=
javadocComment
.
getCommentedNode
().
get
();
// 常量类||枚举类
// 常量类||枚举类
if
(
commentedNode
instanceof
ClassOrInterfaceDeclaration
if
(
commentedNode
instanceof
ClassOrInterfaceDeclaration
||
commentedNode
instanceof
EnumDeclaration
)
{
||
commentedNode
instanceof
EnumDeclaration
)
{
Appendix
appendix
=
Appendix
.
parse
(
javadocComment
);
Appendix
appendix
=
Appendix
.
parse
(
javadocComment
);
if
(
appendix
!=
null
)
{
if
(
appendix
!=
null
)
{
ApiDoc
.
getInstance
().
getProject
().
getAppendices
().
add
(
appendix
);
ApiDoc
.
getInstance
().
getProject
().
getAppendices
().
add
(
appendix
);
...
@@ -104,7 +96,14 @@ public class VisitorParser extends VoidVisitorAdapter<Node> {
...
@@ -104,7 +96,14 @@ public class VisitorParser extends VoidVisitorAdapter<Node> {
OptionalHelper
.
any
(
chapter
.
getTag
(
"resultData"
))
OptionalHelper
.
any
(
chapter
.
getTag
(
"resultData"
))
.
ifPresent
(
tag
->
{
.
ifPresent
(
tag
->
{
System
.
out
.
println
(
javadocComment
);
if
(
javadocComment
.
getCommentedNode
().
isPresent
())
{
com
.
github
.
javaparser
.
ast
.
Node
commentedNode
=
javadocComment
.
getCommentedNode
().
get
();
// 常量类||枚举类
if
(
commentedNode
instanceof
ClassOrInterfaceDeclaration
)
{
ClassOrInterfaceDeclaration
classOrInterfaceDeclaration
=
(
ClassOrInterfaceDeclaration
)
commentedNode
;
ApiDoc
.
getInstance
().
getProject
().
setResultDataClassOrInterfaceDeclaration
(
classOrInterfaceDeclaration
);
}
}
});
});
}
}
super
.
visit
(
javadocComment
,
arg
);
super
.
visit
(
javadocComment
,
arg
);
...
...
apidoc-core/src/main/java/com/kim/apidoc/core/schema/Project.java
View file @
bf2a7907
package
com.kim.apidoc.core.schema
;
package
com.kim.apidoc.core.schema
;
import
com.github.javaparser.ast.body.ClassOrInterfaceDeclaration
;
import
lombok.Getter
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.Setter
;
...
@@ -30,7 +31,10 @@ public class Project extends Node {
...
@@ -30,7 +31,10 @@ public class Project extends Node {
* 附录
* 附录
*/
*/
List
<
Appendix
>
appendices
=
new
LinkedList
<>();
List
<
Appendix
>
appendices
=
new
LinkedList
<>();
/**
* resultData
*/
ClassOrInterfaceDeclaration
resultDataClassOrInterfaceDeclaration
;
/**
/**
* Add chapter.
* Add chapter.
...
...
apidoc-springmvc/src/main/java/com/kim/apidoc/springmvc/SpringParser.java
View file @
bf2a7907
package
com.kim.apidoc.springmvc
;
package
com.kim.apidoc.springmvc
;
import
com.kim.apidoc.springmvc.resovler.SpringComponentTypeResolver
;
import
com.github.javaparser.ast.body.ClassOrInterfaceDeclaration
;
import
com.github.javaparser.ast.body.MethodDeclaration
;
import
com.github.javaparser.ast.body.Parameter
;
import
com.github.javaparser.ast.expr.AnnotationExpr
;
import
com.github.javaparser.ast.expr.Expression
;
import
com.github.javaparser.ast.type.ClassOrInterfaceType
;
import
com.kim.apidoc.core.ApiDoc
;
import
com.kim.apidoc.core.ApiDoc
;
import
com.kim.apidoc.core.common.URI
;
import
com.kim.apidoc.core.common.URI
;
import
com.kim.apidoc.core.common.description.ObjectTypeDescription
;
import
com.kim.apidoc.core.common.description.ObjectTypeDescription
;
...
@@ -13,11 +18,7 @@ import com.kim.apidoc.core.schema.Chapter;
...
@@ -13,11 +18,7 @@ import com.kim.apidoc.core.schema.Chapter;
import
com.kim.apidoc.core.schema.Header
;
import
com.kim.apidoc.core.schema.Header
;
import
com.kim.apidoc.core.schema.Row
;
import
com.kim.apidoc.core.schema.Row
;
import
com.kim.apidoc.core.schema.Section
;
import
com.kim.apidoc.core.schema.Section
;
import
com.github.javaparser.ast.body.ClassOrInterfaceDeclaration
;
import
com.kim.apidoc.springmvc.resovler.SpringComponentTypeResolver
;
import
com.github.javaparser.ast.body.MethodDeclaration
;
import
com.github.javaparser.ast.body.Parameter
;
import
com.github.javaparser.ast.expr.AnnotationExpr
;
import
com.github.javaparser.ast.expr.Expression
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Optional
;
import
java.util.Optional
;
...
@@ -307,6 +308,11 @@ public class SpringParser implements ParserStrategy {
...
@@ -307,6 +308,11 @@ public class SpringParser implements ParserStrategy {
* @param section the section
* @param section the section
*/
*/
private
void
visitReturn
(
MethodDeclaration
n
,
Chapter
chapter
,
Section
section
)
{
private
void
visitReturn
(
MethodDeclaration
n
,
Chapter
chapter
,
Section
section
)
{
ClassOrInterfaceType
returnType
=
new
ClassOrInterfaceType
();
returnType
.
setName
(
ApiDoc
.
getInstance
().
getProject
().
getResultDataClassOrInterfaceDeclaration
().
getName
());
returnType
.
setTypeArguments
(
n
.
getType
());
n
.
setType
(
returnType
);
TypeDescription
description
=
ApiDoc
.
getInstance
().
getTypeResolvers
().
resolve
(
n
.
getType
());
TypeDescription
description
=
ApiDoc
.
getInstance
().
getTypeResolvers
().
resolve
(
n
.
getType
());
if
(
description
.
isAvailable
())
{
if
(
description
.
isAvailable
())
{
if
(
description
.
isPrimitive
())
{
if
(
description
.
isPrimitive
())
{
...
...
apidoc-springmvc/src/test/java/com/kim/apidoc/springmvc/SpringTest.java
View file @
bf2a7907
...
@@ -17,7 +17,7 @@ public class SpringTest {
...
@@ -17,7 +17,7 @@ public class SpringTest {
Context
context
=
new
Context
();
Context
context
=
new
Context
();
context
.
setId
(
"test"
);
context
.
setId
(
"test"
);
context
.
setName
(
"测试项目"
);
context
.
setName
(
"测试项目"
);
context
.
addSource
(
Paths
.
get
(
"
F:\\@project@\\@
dianli@\\tool\\apidoc\\apidoc-springmvc\\src\\test\\java"
));
context
.
addSource
(
Paths
.
get
(
"
K:\\@project-
dianli@\\tool\\apidoc\\apidoc-springmvc\\src\\test\\java"
));
// context.setCss("https://darshandsoni.com/asciidoctor-skins/css/monospace.css");
// context.setCss("https://darshandsoni.com/asciidoctor-skins/css/monospace.css");
ApiDoc
apigcc
=
new
ApiDoc
(
context
);
ApiDoc
apigcc
=
new
ApiDoc
(
context
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment