Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
beb9d19
Remove closing brace in HTMLToTex which caused errors with ordered li…
suluke Dec 7, 2013
91c9222
Update Eclipse project to use open jdk 7's tools.jar
suluke Dec 9, 2013
95ad42f
Quick hack to exclude classes with '@excludeFromTex' tag
suluke Dec 9, 2013
c1fc4d0
Replace preamble.tex with '\input'able docletcommands.tex (thanks to …
suluke Dec 9, 2013
04b10d1
Add build instructions and change the credits
suluke Dec 9, 2013
f436be7
Push all chapter/section declarations one level down (section->subsec…
suluke Dec 10, 2013
5c878f5
Change clearing page not BEFORE but AFTER package
suluke Dec 16, 2013
fbdced4
Add eclipse local .settings folderto gitignore
suluke Dec 19, 2013
2a3e67a
Add -silent option. Add implements and extends being shown.
suluke Dec 19, 2013
7f7c7f9
Update README with info about new features
suluke Dec 19, 2013
09a2f0b
Fix reference from "excludeFromTex" to "texexclude"
suluke Dec 20, 2013
c649a64
Fix warnings and implements/extends being mixed up. Fix doclet doing …
suluke Dec 20, 2013
80bbcb5
Add escaping of double quotes (")
suluke Dec 21, 2013
715affd
Fix classnames not being wrapped properly when using @inheritDoc
suluke Dec 21, 2013
212804b
Fix doclet not showing type dimensions ( = []) at least for return types
suluke Dec 21, 2013
f5236ca
Fix texexclude != texignore
suluke Dec 21, 2013
472a5a4
Clean up docletcommands.tex
suluke Dec 21, 2013
634fb9a
Update usage section of README
suluke Dec 21, 2013
aa64d4c
Small bugfixes in HTMLToTex.java
suluke Dec 23, 2013
a9eb628
Fix issues related to Generics (<> parsed as html tags, class paramet…
suluke Dec 23, 2013
7d3a119
Fix class modifiers not being shown
suluke Dec 23, 2013
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
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="/usr/lib/jvm/java-6-sun/lib/tools.jar"/>
<classpathentry kind="lib" path="/usr/lib/jvm/java-7-openjdk/lib/tools.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
bin
release
.settings
46 changes: 35 additions & 11 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,21 @@ TexDoclet

This is a javadoc doclet - a plugin for the [javadoc tool](http://java.sun.com/j2se/javadoc/). This doclet produces output suitable to
be included into LaTeX documents.
This version is based on [TexDoclet](https://texdoclet.dev.java.net/) from Gregg Wonderly.
A lot of the code was rewritten and changed to support a separation from content
and layout. The sourcecode is also cleaner than the original.
This version is based on [TexDoclet](https://texdoclet.dev.java.net/) from Gregg Wonderly with the changes made and
applied to by [Matthias Braun](https://github.com/MatzeB). See his github project for details.

My fork adapts the doclet to meet the requirements of our project [lambda-alligatoren](https://github.com/vincent23/lambda-alligatoren).
In detail, those are:
* @texignore tag support
* modify the original "preamble.tex" to become an "\\input"-able "docletcommands.tex" (thanks to [@vincent23](https://github.com/vincent23))
* fix a surplus "}" in HTMLtoTex which broke ordered lists

Build instructions
------------------
* The ant Build.xml file provided does NOT run on its own.
* You will need to open the project in Eclipse
* You will probably have to update the path to "tools.jar" in the project's build path properties if you aren't on linux and/or using an SDK different to openjdk 7
* You can build a self-contained doclet jar file by exporting the project as jar from eclipse

Features
--------
Expand All @@ -14,6 +26,18 @@ Features
* Layout is defined by a set of macros outside the tool. This allows you to
easily adapt to your own style/document without the need to touch the tools
output.
* Classes not intended to be part of the generated tex document can be excluded with a dedicated "texignore" tag.
* Shows generalization and realizations ("extends" and "implements")
* Shows dimensions of types, like in "String[][]".
* Has doclet specific tex commands outsourced to allow easy integration into existing documents.

Commandline Options
-------------------
* -output: Defines the output file path. Default is "docs.tex"
* -silent: If this option is specified, all usually unnecessary messages are muted. Error messages will be printed still.
* -see: Specifies the text to use for references created from inline tags. The default text is "see "
* -See: Specifies the text to use for references created from block tags. The default text is "See also ".
* -help: Prints a help text similar to this

Usage
-----
Expand All @@ -23,17 +47,17 @@ Usage

javadoc -docletpath texdoclet.jar -doclet org.wonderly.doclets.TexDoclet my.cool.package

This should produce a file docs.tex
This should produce a file docs.tex. See "man javadoc" and the section above for additional command line arguments.

2. You may test the generated output by copying preamble.tex into the current
directory and compiling it with pdflatex (preamble.tex includes docs.tex)
2. You will need to also input "docletcommands.tex" to the preamble of your main document, otherwise
you will get a lot of errors due to missing commands.

3. Copy the definitions inside preamble.tex into the preamble of your own latex
document. Adapt the macros to your style and language needs.
Use \input{docs.tex} inside your document to include the generated
documentation.
3. \\Input the generated "docs.tex" (or the file with the name you specified via -output) at any place within
your document environment.
4. If you like headers, put \\pagestyle{myheadings} in front of the \\input command you just entered.
You can turn off the headers again by re-executing \\pagestyle{plain} or whichever pagestyle you were using before.

Author/Contact
Original Author/Contact
--------------

Matthias Braun <[email protected]>
110 changes: 48 additions & 62 deletions preamble.tex → docletcommands.tex
Original file line number Diff line number Diff line change
@@ -1,33 +1,15 @@
% This is an example preamble for texdoclet generated output.
% Used like this it produces a standalone document. However it should be easy
% to copy these definitions into your own document and use \input{docs.tex}
% where you want your texdoc documentation.

% The following is an example to put packagename and class into the page
% headings.
\documentclass[a4paper,11pt,parskip=half]{scrbook}

% Make sure you use at least the following packages
\usepackage{color}
% The texdoclet output is in UTF-8. I strongly recommend writing the latex
% source in UTF-8 encoding anyway...
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

% The following packages are not striclty necessary to get texdoclet working
\usepackage{hyperref}

\pagestyle{myheadings}
\usepackage{xparse}% for passing multiple arguments
\usepackage{needspace}% for preventing classe to begin within the lower 7cm of a page

% Initially we're not in a package or class
\def\packagename{}
\def\classname{}
% Custom page heading which displays packagename and class
\markboth{\protect\packagename{} -- \protect\classname{}}{\protect\packagename{} -- \protect\classname{}}

% ---------------------------------------------------------------------------
% TexDoc macros start - everything below this point should be copied to your
% own document and adapted to your style/language if needed
% TexDoc macros start - everything below this point can be
% adapted to your style/language if needed
% ---------------------------------------------------------------------------

% Environment used to simulate html <p> </p>
Expand All @@ -36,64 +18,79 @@
}
% Environment for packages
\newenvironment{texdocpackage}[1]{%
\newpage{}\gdef\packagename{#1}\chapter{Package \texttt{#1}}
\rule{\hsize}{.7mm}
}{}
\gdef\packagename{#1}\section{Package \texttt{#1}}
\rule{\hsize}{.7mm}
}{\newpage{}}

% Environment for classes, interfaces
% Argument 1: "class" or "interface"
% Argument 2: the name of the class/interface
\newenvironment{texdocclass}[2]{%
\gdef\classname{#2}
\section{\texttt{#1 \textbf{#2}}}
}{\newpage{}}
% Argument 3 [opt.]: the name of the superclass
% Argument 4 [opt.]: the name of the realized interfaces
\NewDocumentEnvironment{texdocclass}{ m m o o }{%
\gdef\classname{#2}
\subsection[#2]{\texttt{#1 \textbf{#2}
\IfNoValueTF{#3}
{}
{% "extends" argument was given
% test, if the argument was empty or not
\ifx&#3&%
\else
extends #3
\fi
}
\IfNoValueTF{#4}
{}
{implements #4}
}}
}{\needspace{7cm}}

% Environment for class description
\newenvironment{texdocclassintro}{
\subsection*{Description}
\subsubsection*{Description}
}{
}

% Environment around class fields
\newenvironment{texdocclassfields}{%
\subsection*{Attributes}
\begin{itemize}
\subsubsection*{Attributes}
\begin{itemize}
}{%
\end{itemize}
\end{itemize}
}

% Environment around class methods
\newenvironment{texdocclassmethods}{%
\subsection*{Methods}
\begin{itemize}
\subsubsection*{Methods}
\begin{itemize}
}{%
\end{itemize}
\end{itemize}
}

% Environment around class Constructors
\newenvironment{texdocclassconstructors}{%
\subsection*{Constructors}
\begin{itemize}
\subsubsection*{Constructors}
\begin{itemize}
}{%
\end{itemize}
\end{itemize}
}

% Environment around enum constants
\newenvironment{texdocenums}{%
\subsection*{Enum Constants}
\begin{itemize}
\subsubsection*{Enum Constants}
\begin{itemize}
}{%
\end{itemize}
\end{itemize}
}

% Environment around "See also"-Blocks (\texdocsee invocations)
% Argument 1: Text preceding the references
\newenvironment{texdocsees}[1]{
\textbf{#1:}
\begin{itemize}
\textbf{#1:}
\begin{itemize}
}{%
\end{itemize}
\end{itemize}
}
% Formats a single field
% Argument 1: modifiers
Expand Down Expand Up @@ -127,7 +124,7 @@
% Inserted when @inheritdoc is used
% Argument 1: Class where the documentation was inherited from
% Argument 2: Documentation
\newcommand{\texdocinheritdoc}[2]{#2 (\textit{documentation inherited from \texttt{#1})}}
\newcommand{\texdocinheritdoc}[2]{#2 \\(\textit{documentation inherited from \texttt{#1})}}

% Formats a single see-BlockTag
% Argument 1: text
Expand All @@ -136,10 +133,10 @@

% Environment around \texdocparameter invocations
\newenvironment{texdocparameters}{%
\minisec{Parameters}
\begin{tabular}{ll}
\minisec{Parameters}
\begin{tabular}{ll}
}{%
\end{tabular}
\end{tabular}
}

% Environment around \texdocthrow invocations
Expand Down Expand Up @@ -176,14 +173,3 @@
\relax\else
{$($ in \ref{#1}, page \pageref{#1}$)$}
\fi}

% ---------------------------------------------------------------------------
% TexDoc macros end
% ---------------------------------------------------------------------------

\begin{document}

\tableofcontents
\input{docs.tex}

\end{document}
27 changes: 9 additions & 18 deletions src/org/wonderly/doclets/HTMLToTex.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.Properties;
import java.util.Stack;

import com.sun.javadoc.ClassDoc;
import com.sun.javadoc.MethodDoc;

/**
Expand Down Expand Up @@ -58,12 +57,9 @@ private HTMLToTex() {
private String str;
private int pos;
private StringBuffer ret;
private String block = "";
private String refurl = "";
private String refimg = "";
private boolean collectBlock;
private int chapt = 0;
private int textdepth = 0;
private int verbat = 0;
private Stack<TableInfo> tblstk = new Stack<TableInfo>();
private Hashtable<String, String> colors = new Hashtable<String, String>(10);
Expand Down Expand Up @@ -166,7 +162,6 @@ private String convertToTex(String input, MethodDoc md) {
this.str = input;
ret = new StringBuffer();

++textdepth;
for (pos = 0; pos < str.length(); ++pos) {
char c = str.charAt(pos);
switch (c) {
Expand All @@ -177,6 +172,9 @@ private String convertToTex(String input, MethodDoc md) {
ret.append(' ');
}
break;
case '"':
ret.append("\"'");
break;
case '_':
case '%':
case '$':
Expand Down Expand Up @@ -232,27 +230,27 @@ private String convertToTex(String input, MethodDoc md) {
leave("</center>");
} else if (startsWith("<meta")) {
Properties p = new Properties();
int idx = HTMLToTex.getTagAttrs(str, p, pos + 3);
int idx = HTMLToTex.getTagAttrs(str, p, pos + 5);
pos = idx;
} else if (match("<title>")) {
ret.append("\\chapter{");
} else if (match("</title>")) {
ret.append("}");
} else if (startsWith("<form")) {
Properties p = new Properties();
int idx = HTMLToTex.getTagAttrs(str, p, pos + 3);
int idx = HTMLToTex.getTagAttrs(str, p, pos + 5);
pos = idx;
} else if (match("</form>")) {
/* nothing */
} else if (startsWith("<input")) {
Properties p = new Properties();
int idx = HTMLToTex.getTagAttrs(str, p, pos + 3);
int idx = HTMLToTex.getTagAttrs(str, p, pos + 6);
pos = idx;
} else if (match("</input>")) {
/* nothing */
} else if (startsWith("<body")) {
Properties p = new Properties();
int idx = HTMLToTex.getTagAttrs(str, p, pos + 3);
int idx = HTMLToTex.getTagAttrs(str, p, pos + 5);
pos = idx;
} else if (match("</body>")) {
/* nothing */
Expand Down Expand Up @@ -330,7 +328,7 @@ private String convertToTex(String input, MethodDoc md) {
}
} else if (startsWith("<a")) {
Properties p = new Properties();
int idx = HTMLToTex.getTagAttrs(str, p, pos + 3);
int idx = HTMLToTex.getTagAttrs(str, p, pos + 2);
refurl = p.getProperty("href");
String refname = p.getProperty("href");
pos = idx;
Expand Down Expand Up @@ -360,7 +358,7 @@ else if (refname != null)
} else if (match("</dl>")) {
ret.append("\n\\end{itemize}\n");
} else if (match("</ol>")) {
ret.append("}\n\\end{enumerate}");
ret.append("\n\\end{enumerate}");
} else if (startsWith("<ul")) {
Properties p = new Properties();
int idx = HTMLToTex.getTagAttrs(str, p, pos + 3);
Expand All @@ -387,11 +385,6 @@ else if (refname != null)
int idx = getTagAttrs(str, p, pos + 3);
pos = idx;
tblinfo.startRow(ret, p);
} else if (startsWith("<tr")) {
Properties p = new Properties();
int idx = getTagAttrs(str, p, pos + 3);
pos = idx;
tblinfo.startCol(ret, p);
} else if (startsWith("<th")) {
Properties p = new Properties();
int idx = getTagAttrs(str, p, pos + 3);
Expand Down Expand Up @@ -505,8 +498,6 @@ else if (refname != null)
break;
}
}
--textdepth;

/* leave all contexts */
leave("");

Expand Down
Loading