added @field @varIn @varOut

This commit is contained in:
Brian Long 2025-02-10 11:10:15 -05:00
parent 7116962f9f
commit 0886a273e4
5 changed files with 214 additions and 10 deletions

View File

@ -0,0 +1,42 @@
/*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.inteligr8.activiti.doclet;
/**
* @author brian@inteligr8.com
*/
public class FieldFreemarkerModel {
private String name;
private String comment;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
}

View File

@ -135,7 +135,7 @@ class MarkdownWriter {
this.buildDocumentation(commentTree, beanModel);
for (DocTree tag : commentTree.getBlockTags()) {
this.buildTagModel(tag, beandoc.getBeanId(),
null, null, null, beanModel);
null, null, null, null, null, null, beanModel);
}
}
@ -186,6 +186,9 @@ class MarkdownWriter {
this.logger.debug("Building documentation method model: {}", logId);
Map<String, String> paramComments = new HashMap<>();
Map<String, String> fieldComments = new LinkedHashMap<>();
Map<String, String> varInComments = new LinkedHashMap<>();
Map<String, String> varOutComments = new LinkedHashMap<>();
Map<String, String> throwComments = new LinkedHashMap<>();
Map<String, String> errorComments = new LinkedHashMap<>();
@ -196,11 +199,14 @@ class MarkdownWriter {
this.buildDocumentation(methodCommentTree, sigModel);
for (DocTree tag : methodCommentTree.getBlockTags()) {
this.buildTagModel(tag, logId,
paramComments, throwComments, errorComments, sigModel);
paramComments, fieldComments, varInComments, varOutComments, throwComments, errorComments, sigModel);
}
}
this.buildMethodArguments(methodElement, logId, paramComments, sigModel);
this.buildMethodFields(methodElement, logId, fieldComments, sigModel);
this.buildMethodVariablesIn(methodElement, logId, varInComments, sigModel);
this.buildMethodVariablesOut(methodElement, logId, varOutComments, sigModel);
this.buildMethodThrows(methodElement, logId, throwComments, !errorComments.isEmpty(), sigModel);
this.buildMethodErrors(methodElement, logId, errorComments, sigModel);
this.buildMethodReturns(methodElement, logId, sigModel);
@ -222,6 +228,9 @@ class MarkdownWriter {
private void buildTagModel(DocTree tag, String logId,
Map<String, String> paramComments,
Map<String, String> fieldComments,
Map<String, String> varInComments,
Map<String, String> varOutComments,
Map<String, String> throwComments,
Map<String, String> errorComments,
JavadocTaggable sigModel) {
@ -246,6 +255,33 @@ class MarkdownWriter {
paramComments.put(matcher.group(1), this.sanitize(matcher.group(2).trim()));
else this.logger.warn("A @param for the {} bean and {} method is improperly formatted", logId);
return;
case "field":
if (fieldComments == null)
break;
matcher = this.namedCommentPattern.matcher(tagComment);
if (matcher.find())
fieldComments.put(matcher.group(1), this.sanitize(matcher.group(2).trim()));
else this.logger.warn("A @field for the {} bean and {} method is improperly formatted", logId);
return;
case "varIn":
if (varInComments == null)
break;
matcher = this.namedCommentPattern.matcher(tagComment);
if (matcher.find())
varInComments.put(matcher.group(1), this.sanitize(matcher.group(2).trim()));
else this.logger.warn("A @field for the {} bean and {} method is improperly formatted", logId);
return;
case "varOut":
if (varOutComments == null)
break;
matcher = this.namedCommentPattern.matcher(tagComment);
if (matcher.find())
varOutComments.put(matcher.group(1), this.sanitize(matcher.group(2).trim()));
else this.logger.warn("A @field for the {} bean and {} method is improperly formatted", logId);
return;
case "throws":
if (throwComments == null)
break;
@ -295,6 +331,45 @@ class MarkdownWriter {
}
}
private void buildMethodFields(ExecutableElement methodElement, String logId,
Map<String, String> fieldComments, MethodSignatureFreemarkerModel sigModel) {
for (Entry<String, String> fieldComment : fieldComments.entrySet()) {
this.logger.trace("Found BPMN field '{}' for '{}'", fieldComment.getKey(), logId);
FieldFreemarkerModel fieldModel = new FieldFreemarkerModel();
fieldModel.setName(fieldComment.getKey());
fieldModel.setComment(fieldComment.getValue());
sigModel.getBpmnFields().put(fieldModel.getName(), fieldModel);
}
}
private void buildMethodVariablesIn(ExecutableElement methodElement, String logId,
Map<String, String> varComments, MethodSignatureFreemarkerModel sigModel) {
for (Entry<String, String> varComment : varComments.entrySet()) {
this.logger.trace("Found input variable '{}' for '{}'", varComment.getKey(), logId);
VarFreemarkerModel varModel = new VarFreemarkerModel();
varModel.setName(varComment.getKey());
varModel.setComment(varComment.getValue());
sigModel.getVariablesIn().put(varModel.getName(), varModel);
}
}
private void buildMethodVariablesOut(ExecutableElement methodElement, String logId,
Map<String, String> varComments, MethodSignatureFreemarkerModel sigModel) {
for (Entry<String, String> varComment : varComments.entrySet()) {
this.logger.trace("Found output variable '{}' for '{}'", varComment.getKey(), logId);
VarFreemarkerModel varModel = new VarFreemarkerModel();
varModel.setName(varComment.getKey());
varModel.setComment(varComment.getValue());
sigModel.getVariablesIn().put(varModel.getName(), varModel);
}
}
private void buildMethodThrows(ExecutableElement methodElement, String logId,
Map<String, String> throwComments, boolean hasBpmnErrorComments, MethodSignatureFreemarkerModel sigModel) {
for (TypeMirror thrownType : methodElement.getThrownTypes()) {

View File

@ -24,6 +24,12 @@ public class MethodSignatureFreemarkerModel implements JavadocDocumentable, Java
private String methodSignature;
private Map<String, ParamFreemarkerModel> params = new LinkedHashMap<>();
private Map<String, FieldFreemarkerModel> bpmnFields = new LinkedHashMap<>();
private Map<String, VarFreemarkerModel> variablesIn = new LinkedHashMap<>();
private Map<String, VarFreemarkerModel> variablesOut = new LinkedHashMap<>();
private String returnType;
@ -54,6 +60,30 @@ public class MethodSignatureFreemarkerModel implements JavadocDocumentable, Java
public void setParams(Map<String, ParamFreemarkerModel> params) {
this.params = params;
}
public Map<String, FieldFreemarkerModel> getBpmnFields() {
return bpmnFields;
}
public void setBpmnFields(Map<String, FieldFreemarkerModel> fields) {
this.bpmnFields = fields;
}
public Map<String, VarFreemarkerModel> getVariablesIn() {
return variablesIn;
}
public void setVariablesIn(Map<String, VarFreemarkerModel> variablesIn) {
this.variablesIn = variablesIn;
}
public Map<String, VarFreemarkerModel> getVariablesOut() {
return variablesOut;
}
public void setVariablesOut(Map<String, VarFreemarkerModel> variablesOut) {
this.variablesOut = variablesOut;
}
public String getReturnType() {
return returnType;

View File

@ -0,0 +1,42 @@
/*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.inteligr8.activiti.doclet;
/**
* @author brian@inteligr8.com
*/
public class VarFreemarkerModel {
private String name;
private String comment;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
}

View File

@ -80,27 +80,42 @@ This bean and its methods may be used in any "Expression" field or script in a S
<#if sig.docBody??>${sig.docBody}<#else>No documentation available.</#if>
<#if (sig.params?size > 0)>
| Parameter Name | Java Type | Documentation |
| ------------------------ | ------------------------------------------------ | ------------------------ |
| Input Type | Name | Java Type | Documentation |
| ------------------------ | ------------------------ | ------------------------------------------------ | ---------------------------------- |
<#list sig.params as paramName, param>
| ${("`" + paramName + "`")?right_pad(24)} | ${("`" + param.type + "`")?right_pad(48)} | <#if (param.comment?? && param.comment?length > 0)>${param.comment?right_pad(24)}<#else>No documentation available.</#if> |
| Method Parameter | ${("`" + paramName + "`")?right_pad(24)} | ${("`" + param.type + "`")?right_pad(48)} | <#if (param.comment?? && param.comment?length > 0)>${param.comment?right_pad(32)}<#else>No documentation available.</#if> |
</#list>
<#if (sig.bpmnFields?size > 0)>
<#list sig.bpmnFields as fieldName, field>
| BPMN Field | ${("`" + fieldName + "`")?right_pad(48)} | ${("")?right_pad(48)} | <#if (field.comment?? && field.comment?length > 0)>${field.comment?right_pad(32)}<#else>No documentation available.</#if> |
</#list>
</#if>
<#if (sig.variablesIn?size > 0)>
<#list sig.variablesIn as varName, var>
| Variable | ${("`" + varName + "`")?right_pad(48)} | ${("")?right_pad(48)} | <#if (var.comment?? && var.comment?length > 0)>${var.comment?right_pad(32)}<#else>No documentation available.</#if> |
</#list>
</#if>
</#if>
<#if (sig.returnType?? || sig.throwTypes?size > 0)>
| Result Type | Java Type or BPMN Error Code | Documentation |
| ------------------------ | ------------------------------------------------ | ------------------------ |
| Result Type | Java Type, Name, or Error Code | Documentation |
| ------------------------ | ------------------------------------------------ | -------------------------------- |
<#if sig.returnType??>
| Return Value | ${("`" + sig.returnType + "`")?right_pad(48)} | <#if (sig.tags.return?? && sig.tags.return[0]?length > 0)>${sig.tags.return[0]?right_pad(24)}<#else>No documentation available.</#if> |
| Return Value | ${("`" + sig.returnType + "`")?right_pad(48)} | <#if (sig.tags.return?? && sig.tags.return[0]?length > 0)>${sig.tags.return[0]?right_pad(32)}<#else>No documentation available.</#if> |
</#if>
<#if (sig.variablesOut?size > 0)>
<#list sig.variablesOut as varName, var>
| Variable | ${("`" + varName + "`")?right_pad(48)} | <#if (var.comment?? && var.comment?length > 0)>${var.comment?right_pad(32)}<#else>No documentation available.</#if> |
</#list>
</#if>
<#if (sig.throwTypes?size > 0)>
<#list sig.throwTypes as throwType, throw>
| Thrown Exception | ${("`" + throwType + "`")?right_pad(48)} | <#if (throw.comment?? && throw.comment?length > 0)>${throw.comment?right_pad(24)}<#else>No documentation available.</#if> |
| Thrown Exception | ${("`" + throwType + "`")?right_pad(48)} | <#if (throw.comment?? && throw.comment?length > 0)>${throw.comment?right_pad(32)}<#else>No documentation available.</#if> |
</#list>
</#if>
<#if (sig.bpmnErrors?size > 0)>
<#list sig.bpmnErrors as errorCode, bpmnError>
| Thrown BPMN Error | ${("`" + errorCode + "`")?right_pad(48)} | <#if (bpmnError.comment?? && bpmnError.comment?length > 0)>${bpmnError.comment?right_pad(24)}<#else>No documentation available.</#if> |
| Thrown BPMN Error | ${("`" + errorCode + "`")?right_pad(48)} | <#if (bpmnError.comment?? && bpmnError.comment?length > 0)>${bpmnError.comment?right_pad(32)}<#else>No documentation available.</#if> |
</#list>
</#if>