Skip to content

Commit

Permalink
Enabling possibility to have { and } in (latex) index items
Browse files Browse the repository at this point in the history
In the doxygen manual the index items for \{ and \} were missing due to the missing support for the usage of { and } in parts of the code.
This patch fixes this problem by introducing 2 new latex commands. See also http://tex.stackexchange.com/questions/153291/index-unmatched-braces-in-latex
Further improvements in the index are:
- consistency in different places
- correction of index for \::
- placing \~ on a more logical place (together with other special characters, ~ is in the ASCII table after a-z whilst other characters are before this range)
  • Loading branch information
albert-github committed Jan 15, 2014
1 parent de9e2e0 commit dd2c137
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
8 changes: 6 additions & 2 deletions doc/commands.doc
Original file line number Diff line number Diff line change
Expand Up @@ -2696,6 +2696,8 @@ class Receiver
<hr>
\section cmdfcurlyopen \\f{environment}{

\addindex \\f{

Marks the start of a formula that is in a specific environment.
\note The second \c { is optional and is only to help editors (such as \c Vim) to
do proper syntax highlighting by making the number of opening and closing braces
Expand All @@ -2705,6 +2707,8 @@ class Receiver
<hr>
\section cmdfcurlyclose \\f}

\addindex \\f}

Marks the end of a formula that is in a specific environment.
\sa section \ref cmdfcurlyopen "\\f{" and section \ref formulas "formulas".

Expand Down Expand Up @@ -3030,15 +3034,15 @@ class Receiver
\section cmdchardot \\.

\addindex \\\.
This command writes a dot (\c .) to the output. This can be useful to
This command writes a dot (`.`) to the output. This can be useful to
prevent ending a brief description when JAVADOC_AUTOBRIEF is enabled
or to prevent starting a numbered list when the dot follows a number at
the start of a line.

<hr>
\section cmddcolon \\::

\addindex \\\::
\addindex \\::
This command writes a double colon (\c \::) to the output. This
character sequence has to be escaped in some cases, because it is used
to reference to documented entities.
Expand Down
2 changes: 2 additions & 0 deletions doc/doxygen.sty
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@
}

\newcommand{\doxyref}[3]{\textbf{#1} (\textnormal{#2}\,\pageref{#3})}
\newcommand{\lcurly}{\{}
\newcommand{\rcurly}{\}}
\newenvironment{DoxyCompactList}
{\begin{list}{}{
\setlength{\leftmargin}{0.5cm}
Expand Down
4 changes: 4 additions & 0 deletions src/doxygen.sty
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,10 @@
\textbf{#1} (\textnormal{#2}\,\pageref{#3})%
}

% Used by @addindex
\newcommand{\lcurly}{\{}
\newcommand{\rcurly}{\}}

% Used for syntax highlighting
\definecolor{comment}{rgb}{0.5,0.0,0.0}
\definecolor{keyword}{rgb}{0.0,0.5,0.0}
Expand Down
5 changes: 5 additions & 0 deletions src/latexdocvisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ static QCString escapeLabelName(const char *s)
case '%': result+="\\%"; break;
case '|': result+="\\texttt{\"|}"; break;
case '!': result+="\"!"; break;
case '{': result+="\\lcurly{}"; break;
case '}': result+="\\rcurly{}"; break;
case '~': result+="````~"; break; // to get it a bit better in index together with other special characters
default: result+=c;
}
}
Expand Down Expand Up @@ -79,6 +82,8 @@ QCString LatexDocVisitor::escapeMakeIndexChars(const char *s)
case '|': m_t << "\\texttt{\"|}"; break;
case '[': m_t << "["; break;
case ']': m_t << "]"; break;
case '{': m_t << "\\lcurly{}"; break;
case '}': m_t << "\\rcurly{}"; break;
default: str[0]=c; filter(str); break;
}
}
Expand Down
19 changes: 15 additions & 4 deletions src/latexgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1374,8 +1374,10 @@ void LatexGenerator::startMemberDoc(const char *clname,
t << "}";
if (clname)
{
t << "!" << clname << "@{";
docify(clname);
t << "!";
escapeLabelName(clname);
t << "@{";
escapeMakeIndexChars(clname);
t << "}";
}
t << "}" << endl;
Expand Down Expand Up @@ -2012,13 +2014,18 @@ void LatexGenerator::escapeLabelName(const char *s)
{
switch (c)
{
case '|': t << "\\texttt{\"|}"; break;
case '!': t << "\"!"; break;
case '%': t << "\\%"; break;
case '{': t << "\\lcurly{}"; break;
case '}': t << "\\rcurly{}"; break;
case '~': t << "````~"; break; // to get it a bit better in index together with other special characters
// NOTE: adding a case here, means adding it to while below as well!
default:
i=0;
// collect as long string as possible, before handing it to docify
result[i++]=c;
while ((c=*p) && c!='%')
while ((c=*p) && c!='|' && c!='!' && c!='%' && c!='{' && c!='}' && c!='~')
{
result[i++]=c;
p++;
Expand All @@ -2041,16 +2048,20 @@ void LatexGenerator::escapeMakeIndexChars(const char *s)
{
switch (c)
{
case '!': t << "\"!"; break;
case '"': t << "\"\""; break;
case '@': t << "\"@"; break;
case '|': t << "\\texttt{\"|}"; break;
case '[': t << "["; break;
case ']': t << "]"; break;
case '{': t << "\\lcurly{}"; break;
case '}': t << "\\rcurly{}"; break;
// NOTE: adding a case here, means adding it to while below as well!
default:
i=0;
// collect as long string as possible, before handing it to docify
result[i++]=c;
while ((c=*p) && c!='"' && c!='@' && c!='[' && c!=']')
while ((c=*p) && c!='"' && c!='@' && c!='[' && c!=']' && c!='!' && c!='{' && c!='}' && c!='|')
{
result[i++]=c;
p++;
Expand Down

0 comments on commit dd2c137

Please sign in to comment.