Skip to content

Commit

Permalink
Merge pull request #630 from HubSpot/npe-doc-annotation
Browse files Browse the repository at this point in the history
Fix NPE around code snippets documentation
  • Loading branch information
mattcoley authored Apr 2, 2021
2 parents 83ead56 + 41298a7 commit 463b1be
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/main/java/com/hubspot/jinjava/doc/JinjavaDocFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,26 +307,28 @@ private String getTagSnippet(Tag tag) {
StringBuilder snippet = new StringBuilder("{% ");
snippet.append(tag.getName());
int i = 1;
for (JinjavaParam param : docAnnotation.input()) {
String inputValue = "${" + i + ":" + param.value() + "}";
if (param.value().equalsIgnoreCase("path")) {
inputValue = "'" + inputValue + "'";
} else if (param.value().equalsIgnoreCase("argument_names")) {
inputValue = "(" + inputValue + ")";
if (docAnnotation != null) {
for (JinjavaParam param : docAnnotation.input()) {
String inputValue = "${" + i + ":" + param.value() + "}";
if (param.value().equalsIgnoreCase("path")) {
inputValue = "'" + inputValue + "'";
} else if (param.value().equalsIgnoreCase("argument_names")) {
inputValue = "(" + inputValue + ")";
}
snippet.append(" " + inputValue);
i++;
}
snippet.append(" " + inputValue);
i++;
}

for (JinjavaParam param : docAnnotation.params()) {
String paramValue = "${" + i + ":" + param.value() + "}";
if (param.value().equalsIgnoreCase("path")) {
paramValue = "'" + paramValue + "'";
} else if (param.value().equalsIgnoreCase("argument_names")) {
paramValue = "(" + paramValue + ")";
for (JinjavaParam param : docAnnotation.params()) {
String paramValue = "${" + i + ":" + param.value() + "}";
if (param.value().equalsIgnoreCase("path")) {
paramValue = "'" + paramValue + "'";
} else if (param.value().equalsIgnoreCase("argument_names")) {
paramValue = "(" + paramValue + ")";
}
snippet.append(" " + paramValue);
i++;
}
snippet.append(" " + paramValue);
i++;
}

snippet.append(" %}");
Expand Down

0 comments on commit 463b1be

Please sign in to comment.