Using package listings to display source code
This fixes some line overflow issues and improves appearance.
This commit is contained in:
@@ -820,6 +820,8 @@ public class TeXDoclet extends Doclet {
|
|||||||
|
|
||||||
printPreambleUsePackages(os);
|
printPreambleUsePackages(os);
|
||||||
|
|
||||||
|
printPreambleListingsOptions(os);
|
||||||
|
|
||||||
printPreambleIfPfd(os);
|
printPreambleIfPfd(os);
|
||||||
|
|
||||||
printPreambleNewCommands(os);
|
printPreambleNewCommands(os);
|
||||||
@@ -848,6 +850,11 @@ public class TeXDoclet extends Doclet {
|
|||||||
}
|
}
|
||||||
os.println("\\usepackage{ifpdf}");
|
os.println("\\usepackage{ifpdf}");
|
||||||
os.println("\\usepackage[" + style + "]{fullpage}");
|
os.println("\\usepackage[" + style + "]{fullpage}");
|
||||||
|
os.println("\\usepackage{listings}");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void printPreambleListingsOptions(PrintWriter os) {
|
||||||
|
os.println("\\lstset{language=Java,breaklines=true}");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printPreambleTitle(PrintWriter os) {
|
static void printPreambleTitle(PrintWriter os) {
|
||||||
@@ -1122,25 +1129,24 @@ public class TeXDoclet extends Doclet {
|
|||||||
|
|
||||||
os.println("\\" + sectionLevels[2] + "{Declaration}{");
|
os.println("\\" + sectionLevels[2] + "{Declaration}{");
|
||||||
|
|
||||||
os.print("\\small " + HTMLtoLaTeXBackEnd.fixText(cd.modifiers())
|
os.println("\\begin{lstlisting}[frame=trBL]");
|
||||||
+ " ");
|
os.print(cd.modifiers() + " ");
|
||||||
if (cd.isInterface() == false) {
|
if (cd.isInterface() == false) {
|
||||||
os.print("class ");
|
os.print("class ");
|
||||||
}
|
}
|
||||||
os.println(HTMLtoLaTeXBackEnd.fixText(cd.name()));
|
os.println(cd.name());
|
||||||
ClassDoc sc = cd.superclass();
|
ClassDoc sc = cd.superclass();
|
||||||
if (sc != null) {
|
if (sc != null) {
|
||||||
os.println("\\\\ " + BOLD + " extends} "
|
os.print(" extends "
|
||||||
+ HTMLtoLaTeXBackEnd.fixText(sc.qualifiedName()));
|
+ sc.qualifiedName());
|
||||||
printRef(sc.containingPackage(), sc.name(), null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassDoc intf[] = cd.interfaces();
|
ClassDoc intf[] = cd.interfaces();
|
||||||
if (intf.length > 0) {
|
if (intf.length > 0) {
|
||||||
if (cd.isInterface() == false) {
|
if (cd.isInterface() == false) {
|
||||||
os.println("\\\\ " + BOLD + " implements} ");
|
os.print(" implements ");
|
||||||
} else {
|
} else {
|
||||||
os.println("\\\\ " + BOLD + " extends} ");
|
os.print(" extends ");
|
||||||
}
|
}
|
||||||
for (int j = 0; j < intf.length; ++j) {
|
for (int j = 0; j < intf.length; ++j) {
|
||||||
ClassDoc in = intf[j];
|
ClassDoc in = intf[j];
|
||||||
@@ -1154,10 +1160,10 @@ public class TeXDoclet extends Doclet {
|
|||||||
if (j > 0) {
|
if (j > 0) {
|
||||||
os.print(", ");
|
os.print(", ");
|
||||||
}
|
}
|
||||||
os.print(HTMLtoLaTeXBackEnd.fixText(nm));
|
os.print(nm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
os.println("}");
|
os.println("\\end{lstlisting}");
|
||||||
ExecutableMemberDoc[] mems;
|
ExecutableMemberDoc[] mems;
|
||||||
FieldDoc[] flds;
|
FieldDoc[] flds;
|
||||||
|
|
||||||
@@ -1628,33 +1634,28 @@ public class TeXDoclet extends Doclet {
|
|||||||
os.println();
|
os.println();
|
||||||
|
|
||||||
// Print signature
|
// Print signature
|
||||||
os.print(TRUETYPE);
|
os.println("\\begin{lstlisting}[frame=single]");
|
||||||
if (!mem.containingClass().isInterface()) {
|
if (!mem.containingClass().isInterface()) {
|
||||||
os.print(HTMLtoLaTeXBackEnd.fixText(mem.modifiers()));
|
os.print(mem.modifiers() + " ");
|
||||||
}
|
}
|
||||||
if (mem instanceof MethodDoc) {
|
if (mem instanceof MethodDoc) {
|
||||||
os.print(" "
|
os.print(packageRelativIdentifier(pac, ((MethodDoc) mem)
|
||||||
+ HTMLtoLaTeXBackEnd.fixText(packageRelativIdentifier(pac,
|
.returnType().toString()) + " ");
|
||||||
((MethodDoc) mem).returnType().toString())));
|
|
||||||
}
|
}
|
||||||
os.print("\\ " + BOLD + " " + HTMLtoLaTeXBackEnd.fixText(mem.name())
|
os.print(mem.name() + "(");
|
||||||
+ "}(");
|
|
||||||
Parameter[] parms = mem.parameters();
|
Parameter[] parms = mem.parameters();
|
||||||
int p = 0;
|
int p = 0;
|
||||||
String qparmstr = "";
|
String qparmstr = "";
|
||||||
String parmstr = "";
|
String parmstr = "";
|
||||||
for (; p < parms.length; ++p) {
|
for (; p < parms.length; ++p) {
|
||||||
if (p > 0) {
|
if (p > 0) {
|
||||||
os.println(",");
|
os.print(",");
|
||||||
}
|
}
|
||||||
Type t = parms[p].type();
|
Type t = parms[p].type();
|
||||||
os.print(TRUETYPE
|
os.print(packageRelativIdentifier(pac, t.qualifiedTypeName()));
|
||||||
+ HTMLtoLaTeXBackEnd.fixText(packageRelativIdentifier(pac,
|
os.print(t.dimension());
|
||||||
t.qualifiedTypeName())));
|
|
||||||
os.print(HTMLtoLaTeXBackEnd.fixText(t.dimension()) + "}");
|
|
||||||
if (parms[p].name().equals("") == false) {
|
if (parms[p].name().equals("") == false) {
|
||||||
os.print(" " + BOLD + " "
|
os.print(" " + parms[p].name());
|
||||||
+ HTMLtoLaTeXBackEnd.fixText(parms[p].name()) + "}");
|
|
||||||
}
|
}
|
||||||
if (qparmstr.length() != 0) {
|
if (qparmstr.length() != 0) {
|
||||||
qparmstr += ",";
|
qparmstr += ",";
|
||||||
@@ -1675,19 +1676,7 @@ public class TeXDoclet extends Doclet {
|
|||||||
os.print(", " + thrownExceptions[e].qualifiedName());
|
os.print(", " + thrownExceptions[e].qualifiedName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
os.println();
|
os.println("\\end{lstlisting} %end signature");
|
||||||
|
|
||||||
if (copiedTo == null) {
|
|
||||||
os.print("\\label{"
|
|
||||||
+ refName(makeRefKey(mem.qualifiedName() + mem.signature()))
|
|
||||||
+ "}");
|
|
||||||
} else {
|
|
||||||
os.print("\\label{"
|
|
||||||
+ refName(makeRefKey(copiedTo.qualifiedName()
|
|
||||||
+ copiedTo.signature())) + "}");
|
|
||||||
}
|
|
||||||
|
|
||||||
os.println("}%end signature");
|
|
||||||
boolean yet = false;
|
boolean yet = false;
|
||||||
|
|
||||||
// Description
|
// Description
|
||||||
|
|||||||
Reference in New Issue
Block a user