# Documentation Generator for LaTeX

Is there Documentation Generator for LaTeX like Javadoc for Java or Doxygen for C++?

Especially when defining macros or environments for LaTeX-files throughout a big project it would be useful for the team to have a nice documentation at best auto generated from commentary in the LaTeX-file.

• – percusse Sep 21 '14 at 20:06
• Something like docstrip? – user31729 Sep 21 '14 at 20:10
• @ChristianHupfer DocStrip is for getting the code out of commented sources: you are probably thinking of doc, ltxdoc, etc. – Joseph Wright Sep 21 '14 at 21:06
• @JosephWright: Yes, that's right. I meant doc or ltxdoc of course. – user31729 Sep 21 '14 at 21:07
• Perhaps something like texinfo? – Aradnix Sep 22 '14 at 2:10

The LaTeX Project have developed a series of tools to help documenting (La)TeX code: this is hardly surprising given the fact hat LaTeX itself is a large and complex piece of software. The combination of various pieces of the 'jigsaw' leads to a file format known as .dtx ('documented (La)TeX source' or something like that). This format combines the ability to extract code from the source using DocStrip with mark-up tools for creating documentation using the doc package. I've written about the format before and provided a starting point for creating an 'all in one' .dtx. A minimal-ise version might look something like

% \iffalse meta-comment
%<*driver>
\documentclass{ltxdoc}
\begin{document}
\DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
% \section{The documentation}
%
% \DescribeMacro{\examplemacro}
%   Some text about an example macro called \cs{examplemacro}, which
%   might have an optional argument \oarg{arg1} and mandatory one
%   \marg{arg2}.
%
% \section{The code}
%
% Start the DocStrip guard for extracting the code.
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%
% \begin{macro}{\examplemacro}
%   Something about the implementation here, perhaps.
%    \begin{macrocode}
\newcommand*\examplemacro[2][]{%
Some code here, probably
}
%    \end{macrocode}
%\end{macro}
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}


where I've not provided the .ins file necessary to extract the code from the source, just the necessary set up to typeset some comments.

This format is used a lot by LaTeX package authors, so there are many variations on the standard set up on CTAN.