Skip to content

Commit

Permalink
Limit images sizes and make more uniform (LaTeX)
Browse files Browse the repository at this point in the history
This patch adjusts some problems regarding image sizes in LaTeX output of doxygen (a.o. Bug 738299 - When using msc or PlantUML, the default latex for the created image should include [width=\linewidth]) this has been done is such a way that all the "image" commands (i.e. image, dot, dotfile, msc, mscfile, diafile, startuml) operate in a similar way / have the same possibilities.

- commands.doc
Adjusted documentation to reflect changes.

- cmdmapper.cpp
- cmdmapper.h
Added utility function to map command id back to command name

- doctokenizer.h
- doctokenizer.l
Handle Caption  and Size indication. Required also that some other rules had to be tightened a bit (like usage of {} in startuml and usage of "" for captions. This was already described in the documentation in this way).

- docparser.cpp
- docparser.h
Created routine to uniformly handle the Caption and size indications and store them in a general way.

- latexgen.cpp
Replaced graphicx package by adjustbox package (includes graphicx) to support "min width" etc.

- doxygen.sty templates\latex
Added commands to make commands with and without caption behave similar.

- docbookvisitor.cpp
- docbookvisitor.h
- htmldocvisitor.cpp
- latexdocvisitor.cpp
- latexdocvisitor.h
- printdocvisitor.h
- xmldocvisitor.cpp
Created routine to uniformly handle the Caption and size indications in a general way.

- indexpage.xml (testing\022)
- indexpage.xml (testing\031)
- class_receiver.xml (testing\037)
- class_sender.xml (testing\037)
Adjusted example output.
  • Loading branch information
albert-github committed Nov 28, 2014
1 parent 0fea3d4 commit 329a4dd
Show file tree
Hide file tree
Showing 20 changed files with 731 additions and 702 deletions.
107 changes: 83 additions & 24 deletions doc/commands.doc
Expand Up @@ -2451,13 +2451,25 @@ only copy the detailed documentation, not the brief description.
\ref cmdhtmlonly "\\htmlonly". \ref cmdhtmlonly "\\htmlonly".


<hr> <hr>
\section cmddot \\dot \section cmddot \\dot ["caption"] [<sizeindication>=<size>]


\addindex \\dot \addindex \\dot
Starts a text fragment which should contain a valid description of a Starts a text fragment which should contain a valid description of a
dot graph. The text fragment ends with \ref cmdenddot "\\enddot". dot graph. The text fragment ends with \ref cmdenddot "\\enddot".
Doxygen will pass the text on to dot and include the resulting Doxygen will pass the text on to dot and include the resulting
image (and image map) into the output. image (and image map) into the output.

The first argument is optional and can be used to specify the caption
that is displayed below the image. This argument has to be specified
between quotes even if it does not contain any spaces. The quotes are
stripped before the caption is displayed.

The second argument is also optional and can be used to specify the
width or height of the image.
For a descriptionm of the possibilities see the paragraph
\ref image_sizeindicator "Size indication" with the
\ref cmdimage "\\image" command.

The nodes of a graph can be made clickable by using the URL attribute. The nodes of a graph can be made clickable by using the URL attribute.
By using the command \ref cmdref "\\ref" inside the URL value you can conveniently By using the command \ref cmdref "\\ref" inside the URL value you can conveniently
link to an item inside doxygen. Here is an example: link to an item inside doxygen. Here is an example:
Expand Down Expand Up @@ -2485,12 +2497,24 @@ class C {};
\endcode \endcode


<hr> <hr>
\section cmdmsc \\msc \section cmdmsc \\msc ["caption"] [<sizeindication>=<size>]


\addindex \\msc \addindex \\msc
Starts a text fragment which should contain a valid description of a Starts a text fragment which should contain a valid description of a
message sequence chart. See http://www.mcternan.me.uk/mscgen/ for examples. message sequence chart. See http://www.mcternan.me.uk/mscgen/ for examples.
The text fragment ends with \ref cmdendmsc "\\endmsc". The text fragment ends with \ref cmdendmsc "\\endmsc".

The first argument is optional and can be used to specify the caption
that is displayed below the image. This argument has to be specified
between quotes even if it does not contain any spaces. The quotes are
stripped before the caption is displayed.

The second argument is also optional and can be used to specify the
width or height of the image.
For a descriptionm of the possibilities see the paragraph
\ref image_sizeindicator "Size indication" with the
\ref cmdimage "\\image" command.

\note The text fragment should only include the part of the message \note The text fragment should only include the part of the message
sequence chart that is sequence chart that is
within the <code>msc {...}</code> block. within the <code>msc {...}</code> block.
Expand Down Expand Up @@ -2534,7 +2558,7 @@ class Receiver
\sa section \ref cmdmscfile "\\mscfile". \sa section \ref cmdmscfile "\\mscfile".


<hr> <hr>
\section cmdstartuml \\startuml \section cmdstartuml \\startuml [{file}] ["caption"] [<sizeindication>=<size>]


\addindex \\startuml \addindex \\startuml
Starts a text fragment which should contain a valid description of a Starts a text fragment which should contain a valid description of a
Expand All @@ -2544,6 +2568,28 @@ class Receiver
if you want to use this command. The location of the jar file should be specified if you want to use this command. The location of the jar file should be specified
using \ref cfg_plantuml_jar_path "PLANTUML_JAR_PATH". using \ref cfg_plantuml_jar_path "PLANTUML_JAR_PATH".


The first argument is optional and is for compatibility with running PlantUML as a preprocessing
step before running doxygen, you can also add the name of the image file after \c \\startuml
and inside curly brackets, i.e.
\verbatim
@startuml{myimage.png}
Alice -> Bob : Hello
@enduml
\endverbatim
When the name of the image is specified, doxygen will generate an image with that name.
Without the name doxygen will choose a name automatically.

The second argument is optional and can be used to specify the caption
that is displayed below the image. This argument has to be specified
between quotes even if it does not contain any spaces. The quotes are
stripped before the caption is displayed.

The third argument is also optional and can be used to specify the
width or height of the image.
For a descriptionm of the possibilities see the paragraph
\ref image_sizeindicator "Size indication" with the
\ref cmdimage "\\image" command.

Here is an example of the use of the \c \\startuml command. Here is an example of the use of the \c \\startuml command.
\code \code
/** Sender class. Can be used to send a command to the server. /** Sender class. Can be used to send a command to the server.
Expand Down Expand Up @@ -2575,19 +2621,8 @@ class Receiver
}; };
\endcode \endcode


\note For compatibility with running PlantUML as a preprocessing step before
running doxygen, you can also add the name of the image file after \c \\startuml
and inside curly brackets, i.e.
\verbatim
@startuml{myimage.png}
Alice -> Bob : Hello
@enduml
\endverbatim
When the name of the image is specified, doxygen will generate an image with that name.
Without the name doxygen will choose a name automatically.

<hr> <hr>
\section cmddotfile \\dotfile <file> ["caption"] \section cmddotfile \\dotfile <file> ["caption"] [<sizeindication>=<size>]


\addindex \\dotfile \addindex \\dotfile
Inserts an image generated by dot from \<file\> into the documentation. Inserts an image generated by dot from \<file\> into the documentation.
Expand All @@ -2604,8 +2639,16 @@ Without the name doxygen will choose a name automatically.
between quotes even if it does not contain any spaces. The quotes are between quotes even if it does not contain any spaces. The quotes are
stripped before the caption is displayed. stripped before the caption is displayed.


The third argument is also optional and can be used to specify the
width or height of the image.
For a descriptionm of the possibilities see the paragraph
\ref image_sizeindicator "Size indication" with the
\ref cmdimage "\\image" command.

\sa section \ref cmddot "\\dot".

<hr> <hr>
\section cmdmscfile \\mscfile <file> ["caption"] \section cmdmscfile \\mscfile <file> ["caption"] [<sizeindication>=<size>]


\addindex \\mscfile \addindex \\mscfile
Inserts an image generated by mscgen from \<file\> into the documentation. Inserts an image generated by mscgen from \<file\> into the documentation.
Expand All @@ -2623,10 +2666,16 @@ Without the name doxygen will choose a name automatically.
between quotes even if it does not contain any spaces. The quotes are between quotes even if it does not contain any spaces. The quotes are
stripped before the caption is displayed. stripped before the caption is displayed.


The third argument is also optional and can be used to specify the
width or height of the image.
For a descriptionm of the possibilities see the paragraph
\ref image_sizeindicator "Size indication" with the
\ref cmdimage "\\image" command.

\sa section \ref cmdmsc "\\msc". \sa section \ref cmdmsc "\\msc".


<hr> <hr>
\section cmddiafile \\diafile <file> ["caption"] \section cmddiafile \\diafile <file> ["caption"] [<sizeindication>=<size>]


\addindex \\diafile \addindex \\diafile
Inserts an image made in dia from \<file\> into the documentation. Inserts an image made in dia from \<file\> into the documentation.
Expand All @@ -2643,6 +2692,12 @@ Without the name doxygen will choose a name automatically.
between quotes even if it does not contain any spaces. The quotes are between quotes even if it does not contain any spaces. The quotes are
stripped before the caption is displayed. stripped before the caption is displayed.


The third argument is also optional and can be used to specify the
width or height of the image.
For a descriptionm of the possibilities see the paragraph
\ref image_sizeindicator "Size indication" with the
\ref cmdimage "\\image" command.

<hr> <hr>
\section cmde \\e <word> \section cmde \\e <word>


Expand Down Expand Up @@ -2843,7 +2898,7 @@ Without the name doxygen will choose a name automatically.
format you'll have to repeat this command for each format. format you'll have to repeat this command for each format.


The first argument specifies the output format. Currently, the The first argument specifies the output format. Currently, the
following values are supported: \c html, \c latex and \c rtf. following values are supported: \c html, \c latex, \c docbook and \c rtf.


The second argument specifies the file name of the image. The second argument specifies the file name of the image.
doxygen will look for files in the paths (or files) that you specified doxygen will look for files in the paths (or files) that you specified
Expand All @@ -2859,12 +2914,16 @@ Without the name doxygen will choose a name automatically.
spaces. The quotes are stripped before the caption is displayed. spaces. The quotes are stripped before the caption is displayed.


The fourth argument is also optional and can be used to specify the The fourth argument is also optional and can be used to specify the
width or height of the image. This is only useful width or height of the image. This can be useful for \LaTeX output
for \LaTeX output (i.e. format=<code>latex</code>).
(i.e. format=<code>latex</code>). The \c sizeindication can be \anchor image_sizeindicator \par Size indication
either \c width or \c height. The size should be a valid The \c sizeindication can
size specifier in \LaTeX (for example <code>10cm</code> or specify the width or height to be used )or a combination). Possible
<code>6in</code> or a symbolic width like <code>\\textwidth</code>). values are (width, analogous for height):
`width` or `max with` or `min width`. The size should be a valid
size specifier in \LaTeX (for example `10cm` or
`6in` or a symbolic width like `\\textwidth`). (The `max width` etc.
are based on the \LaTeX package `adjustbox`)


Here is example of a comment block: Here is example of a comment block:


Expand Down
10 changes: 10 additions & 0 deletions src/cmdmapper.cpp
Expand Up @@ -226,6 +226,16 @@ int Mapper::map(const char *n)
return !name.isEmpty() && (result=m_map.find(name)) ? *result: 0; return !name.isEmpty() && (result=m_map.find(name)) ? *result: 0;
} }


QString Mapper::map(const int n)
{
QDictIterator<int> mapIterator(m_map);
for (int *curVal = mapIterator.toFirst();curVal = mapIterator.current();++mapIterator)
{
if (*curVal == n || (*curVal == (n | SIMPLESECT_BIT))) return mapIterator.currentKey();
}
return NULL;
}

Mapper::Mapper(const CommandMap *cm,bool caseSensitive) : m_map(89), m_cs(caseSensitive) Mapper::Mapper(const CommandMap *cm,bool caseSensitive) : m_map(89), m_cs(caseSensitive)
{ {
m_map.setAutoDelete(TRUE); m_map.setAutoDelete(TRUE);
Expand Down
1 change: 1 addition & 0 deletions src/cmdmapper.h
Expand Up @@ -201,6 +201,7 @@ class Mapper
{ {
public: public:
int map(const char *n); int map(const char *n);
QString map(const int n);
Mapper(const CommandMap *cm,bool caseSensitive); Mapper(const CommandMap *cm,bool caseSensitive);
private: private:
QDict<int> m_map; QDict<int> m_map;
Expand Down

0 comments on commit 329a4dd

Please sign in to comment.