# Creating software function index

I need to create some type of index for exported functions in the software for the latex manual. The doxygen feature of exporting to LaTeX does not allow to do it by default. The required form is following:

Index: [function name], [function description] ....... [page]

_other functions

Text:

[function name[ [function description] [additional information(function parameters, return type and so on...]

Traditional index package have no possibility to add custom description to the index however (or I have not looked thoroughly?) Or the glossaries package has the required functionality?

Here is file example:

GetOperationState %function name
function returns the actual state of measurement. %function description
\begin{verbatim}
unsigned short GetOperationState(unsigned short Op)
\end{verbatim}
Parameters
\begin{description}
\item{Op}  Reserved for future use.
\end{description}
Return Values
...Some Text...


-
You could do it in a normal index (basically you make the function name the hidden sort key and put everything as the index entry) or glossaries would probably help, but if you are generating a file with a list of such entries, a few lines of perl (or awk or python or elisp) would just re-order the file before you gave it to latex, which might be easier. –  David Carlisle Dec 19 '12 at 19:35
welcome to tex.sx by the way:-) Do you mean an index (re-sorted alphabetical listing, normally at end of the document) or do you mean a table of contents (called an index in some non-english languages) which is in document order, and normally at the front of the document? –  David Carlisle Dec 19 '12 at 19:55
@DavidCarlisle -- this sounds a lot like the (wonderful) command summary in kopka & daly, appendix g. but i don't know how they created it. –  barbara beeton Dec 19 '12 at 19:58
@barbarabeeton yes, that's very similar –  alivenets Dec 19 '12 at 20:08

I think you mean something like this, which is just using \@starttoc which underlies \tableofcontents and \listoffigures

\documentclass{article}

\setlength\textheight{30\baselineskip}

\makeatletter

\def\FunName#1#2#3{%
\par
\vskip 2\baselineskip plus 1fil\penalty-200\vfilneg
\noindent\hskip-5em\label{Fun-#1}\textbf{#1}%
\par
\nopagebreak
\noindent\ignorespaces#3\par}

\def\l@fun#1{\l@@fun#1}
\def\l@@fun#1#2#3{%
\parbox[t]{.6\textwidth}{\small\raggedright#2}\dotfill
#3\par}

\def\FunctionListing{%
\section*{Function Listing}%
\@starttoc{fun}}%

\makeatother

\begin{document}

\FunctionListing

\FunName{GetOperationState} %function name
\FunDesc{function returns the actual state of measurement.} %function description
\begin{verbatim}
unsigned short GetOperationState(unsigned short Op)
\end{verbatim}
Parameters
\begin{description}
\item{Op}  Reserved for future use.
\end{description}
Return Values
...Some Text...

\FunName{SetOperationState} %function name
\FunDesc{function sets the actual state of measurement.} %function description
\begin{verbatim}
unsigned short SetOperationState(unsigned short Op)
\end{verbatim}
Parameters
\begin{description}
\item{Op}  Reserved for future use.
\end{description}
Return Values
...Some Text...

\FunName{GetSomething} %function name
\FunDesc{function does something interesting.} %function description
\begin{verbatim}
unsigned short GetSomething(
unsigned short Opa,
unsigned short Opb,
unsigned short Opc}
\end{verbatim}
Parameters
\begin{description}
\item{Opa}  Reserved for future use.
\item{Opb}  Reserved for future use.
\item{Opc}  Reserved for future use.
\end{description}
Return Values
...Some Text...

\end{document}

-
That's is the needed thing, thanks! But there's one more question - where is \FunDesc macro defined? –  alivenets Dec 21 '12 at 12:07
Sorry I should have commented on that, it's not defined at all. I needed FunName to have access to the description so it could write to the table of contents file. I probably should have made it just take two arguments the name and description but since I already had the example markup with \FunDesc I made \FunName take three arguments but not use #2 (\FunDesc) –  David Carlisle Dec 21 '12 at 12:26