Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Fixed Bug #56 : https://github.com/SalesforceFoundation/ApexDoc/issues/56 #68

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
Test Demo
2 changes: 1 addition & 1 deletion src/org/salesforce/apexdoc/ApexDoc.java
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ private static void fillClassModel(ClassModel cModelParent, ClassModel cModel, S
break;
}
if (j < comment.length()) {
cModel.setDescription(cModel.getDescription() + ' ' + comment.substring(j));
cModel.setDescription(cModel.getDescription() + Constants.newLinePlaceHolder + comment.substring(j));
}
continue;
}
Expand Down
6 changes: 3 additions & 3 deletions src/org/salesforce/apexdoc/ClassModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ public ArrayList<MethodModel> getMethods() {

public ArrayList<MethodModel> getMethodsSorted() {
@SuppressWarnings("unchecked")
List<MethodModel> sorted = (List<MethodModel>)methods.clone();
List<MethodModel> sorted = (List<MethodModel>)methods.clone();
Collections.sort(sorted, new Comparator<MethodModel>(){
@Override
public int compare(MethodModel o1, MethodModel o2) {
String methodName1 = o1.getMethodName();
String methodName2 = o2.getMethodName();
String className = getClassName();

if(methodName1.equals(className)){
if(methodName1 != null && methodName1.equals(className)){
return Integer.MIN_VALUE;
} else if(methodName2.equals(className)){
} else if(methodName2 != null && methodName2.equals(className)){
return Integer.MAX_VALUE;
}
return (methodName1.toLowerCase().compareTo(methodName2.toLowerCase()));
Expand Down
3 changes: 3 additions & 0 deletions src/org/salesforce/apexdoc/Constants.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package org.salesforce.apexdoc;

public class Constants {

public static final String newLinePlaceHolder = "[BR]";
public static final String newLineHTML = "<br />";

public static final String HEADER_OPEN = "<html><head>" +
"<script type='text/javascript' src='jquery-1.11.1.js'></script>" +
Expand Down
17 changes: 17 additions & 0 deletions src/org/salesforce/apexdoc/FileManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,24 @@ private static String escapeHTML(String s) {
out.append(c);
}
}
replaceAll(out,Constants.newLinePlaceHolder,Constants.newLineHTML);
return out.toString();
}

/**
* There is no replaceAll method for Stringbuilder, so custom method
* */
public static void replaceAll(StringBuilder builder, String oldString, String newString)
{
int index = builder.indexOf(oldString);
while (index != -1)
{
builder.replace(index, index + oldString.length(), newString);
index += newString.length(); // Move to the end of the replacement
index = builder.indexOf(oldString, index);
}
}

public FileManager(String path) {
infoMessages = new StringBuffer();

Expand Down Expand Up @@ -212,6 +227,8 @@ private String htmlForClassModel(ClassModel cModel, String hostedSourceURL) {
"<h2 class='subsection-title'>Methods</h2>" +
"<div class='subsection-container'> ";



// method Table of Contents (TOC)
contents += "<ul class='methodTOC'>";
for (MethodModel method : cModel.getMethodsSorted()) {
Expand Down
1 change: 1 addition & 0 deletions src/org/salesforce/apexdoc/MethodModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public String getMethodName() {
int lastindex = nameLine.indexOf("(");
if (lastindex >= 0) {
String methodName = ApexDoc.strPrevWord(nameLine, lastindex);
methodName = methodName != null ? methodName : "";
return methodName;
}
}
Expand Down