Commit 329a4ddc authored by albert-github's avatar albert-github

Limit images sizes and make more uniform (LaTeX)

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.
parent 0fea3d4c
...@@ -2451,13 +2451,25 @@ only copy the detailed documentation, not the brief description. ...@@ -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:
...@@ -2485,12 +2497,24 @@ class C {}; ...@@ -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.
...@@ -2534,7 +2558,7 @@ class Receiver ...@@ -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
...@@ -2544,6 +2568,28 @@ class Receiver ...@@ -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.
...@@ -2575,19 +2621,8 @@ class Receiver ...@@ -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.
...@@ -2604,8 +2639,16 @@ Without the name doxygen will choose a name automatically. ...@@ -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.
...@@ -2623,10 +2666,16 @@ Without the name doxygen will choose a name automatically. ...@@ -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.
...@@ -2643,6 +2692,12 @@ Without the name doxygen will choose a name automatically. ...@@ -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>
...@@ -2843,7 +2898,7 @@ Without the name doxygen will choose a name automatically. ...@@ -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
...@@ -2859,12 +2914,16 @@ Without the name doxygen will choose a name automatically. ...@@ -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:
......
...@@ -226,6 +226,16 @@ int Mapper::map(const char *n) ...@@ -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);
......
...@@ -201,6 +201,7 @@ class Mapper ...@@ -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;
......
This diff is collapsed.
...@@ -147,16 +147,16 @@ class DocbookDocVisitor : public DocVisitor ...@@ -147,16 +147,16 @@ class DocbookDocVisitor : public DocVisitor
void startMscFile(const QCString &fileName,const QCString &width, void startMscFile(const QCString &fileName,const QCString &width,
const QCString &height, bool hasCaption); const QCString &height, bool hasCaption);
void endMscFile(bool hasCaption); void endMscFile(bool hasCaption);
void writeMscFile(const QCString &fileName); void writeMscFile(const QCString &fileName, DocVerbatim *s);
void startDiaFile(const QCString &fileName,const QCString &width, void startDiaFile(const QCString &fileName,const QCString &width,
const QCString &height, bool hasCaption); const QCString &height, bool hasCaption);
void endDiaFile(bool hasCaption); void endDiaFile(bool hasCaption);
void writeDiaFile(const QCString &fileName); void writeDiaFile(const QCString &fileName, DocVerbatim *s);
void startDotFile(const QCString &fileName,const QCString &width, void startDotFile(const QCString &fileName,const QCString &width,
const QCString &height, bool hasCaption); const QCString &height, bool hasCaption);
void endDotFile(bool hasCaption); void endDotFile(bool hasCaption);
void writeDotFile(const QCString &fileName); void writeDotFile(const QCString &fileName, DocVerbatim *s);
void writePlantUMLFile(const QCString &fileName); void writePlantUMLFile(const QCString &fileName, DocVerbatim *s);
//-------------------------------------- //--------------------------------------
// state variables // state variables
//-------------------------------------- //--------------------------------------
......
This diff is collapsed.
...@@ -447,6 +447,11 @@ class DocVerbatim : public DocNode ...@@ -447,6 +447,11 @@ class DocVerbatim : public DocNode
QCString relPath() const { return m_relPath; } QCString relPath() const { return m_relPath; }
QCString language() const { return m_lang; } QCString language() const { return m_lang; }
bool isBlock() const { return m_isBlock; } bool isBlock() const { return m_isBlock; }
bool hasCaption() const { return !m_children.isEmpty(); }
QCString width() const { return m_width; }
QCString height() const { return m_height; }
const QList<DocNode> &children() const { return m_children; }
QList<DocNode> &children() { return m_children; }
private: private:
QCString m_context; QCString m_context;
...@@ -457,6 +462,10 @@ class DocVerbatim : public DocNode ...@@ -457,6 +462,10 @@ class DocVerbatim : public DocNode
QCString m_relPath; QCString m_relPath;
QCString m_lang; QCString m_lang;
bool m_isBlock; bool m_isBlock;
public:
QCString m_width;
QCString m_height;
QList<DocNode> m_children;
}; };
...@@ -668,7 +677,7 @@ class DocXRefItem : public CompAccept<DocXRefItem>, public DocNode ...@@ -668,7 +677,7 @@ class DocXRefItem : public CompAccept<DocXRefItem>, public DocNode
class DocImage : public CompAccept<DocImage>, public DocNode class DocImage : public CompAccept<DocImage>, public DocNode
{ {
public: public:
enum Type { Html, Latex, Rtf, DocBook }; enum Type { None, Html, Latex, Rtf, DocBook };
DocImage(DocNode *parent,const HtmlAttribList &attribs, DocImage(DocNode *parent,const HtmlAttribList &attribs,
const QCString &name,Type t,const QCString &url=QCString()); const QCString &name,Type t,const QCString &url=QCString());
Kind kind() const { return Kind_Image; } Kind kind() const { return Kind_Image; }
......
...@@ -131,8 +131,10 @@ void doctokenizerYYpushContext(); ...@@ -131,8 +131,10 @@ void doctokenizerYYpushContext();
bool doctokenizerYYpopContext(); bool doctokenizerYYpopContext();
int doctokenizerYYlex(); int doctokenizerYYlex();
void doctokenizerYYsetStatePara(); void doctokenizerYYsetStatePara();
void doctokenizerYYsetStateCaption();
void doctokenizerYYsetStateTitle(); void doctokenizerYYsetStateTitle();
void doctokenizerYYsetStateTitleAttrValue(); void doctokenizerYYsetStateTitleAttrValue();
void doctokenizerYYsetStateTitleAttr();
void doctokenizerYYsetStateCode(); void doctokenizerYYsetStateCode();
void doctokenizerYYsetStateXmlCode(); void doctokenizerYYsetStateXmlCode();
void doctokenizerYYsetStateHtmlOnly(); void doctokenizerYYsetStateHtmlOnly();
...@@ -161,5 +163,6 @@ void doctokenizerYYsetStateSnippet(); ...@@ -161,5 +163,6 @@ void doctokenizerYYsetStateSnippet();
void doctokenizerYYstartAutoList(); void doctokenizerYYstartAutoList();
void doctokenizerYYendAutoList(); void doctokenizerYYendAutoList();
void doctokenizerYYsetStatePlantUML(); void doctokenizerYYsetStatePlantUML();
void doctokenizerYYsetStatePlantUMLOpt();
#endif #endif
...@@ -400,6 +400,7 @@ REFWORD {LABELID}|{REFWORD2}|{REFWORD3}|{LNKWORD2} ...@@ -400,6 +400,7 @@ REFWORD {LABELID}|{REFWORD2}|{REFWORD3}|{LNKWORD2}
%x St_Para %x St_Para
%x St_Comment %x St_Comment
%x St_Title %x St_Title
%x St_Caption
%x St_TitleN %x St_TitleN
%x St_TitleQ %x St_TitleQ
%x St_TitleA %x St_TitleA
...@@ -853,14 +854,18 @@ REFWORD {LABELID}|{REFWORD2}|{REFWORD3}|{LNKWORD2} ...@@ -853,14 +854,18 @@ REFWORD {LABELID}|{REFWORD2}|{REFWORD3}|{LNKWORD2}
<St_Msc>. { /* msc text */ <St_Msc>. { /* msc text */
g_token->verb+=yytext; g_token->verb+=yytext;
} }
<St_PlantUMLOpt>\n { <St_PlantUMLOpt>{BLANK}*"{"[^}]*"}" { // skip curly brackets around the optional image name
g_token->sectionId=g_token->sectionId.stripWhiteSpace(); g_token->sectionId = yytext;
BEGIN(St_PlantUML); g_token->sectionId = g_token->sectionId.stripWhiteSpace();
} g_token->sectionId = g_token->sectionId.left(g_token->sectionId.length()-1);
<St_PlantUMLOpt>["{}] { // skip curly brackets or quotes around the optional image name g_token->sectionId = g_token->sectionId.right(g_token->sectionId.length()-1);
g_token->sectionId = g_token->sectionId.stripWhiteSpace();
return RetVal_OK;
} }
<St_PlantUMLOpt>. { <St_PlantUMLOpt>. {
g_token->sectionId += yytext; g_token->sectionId = "";
unput(*yytext);
return RetVal_OK;
} }
<St_PlantUML>{CMD}"enduml" { <St_PlantUML>{CMD}"enduml" {
return RetVal_OK; return RetVal_OK;
...@@ -870,6 +875,19 @@ REFWORD {LABELID}|{REFWORD2}|{REFWORD3}|{LNKWORD2} ...@@ -870,6 +875,19 @@ REFWORD {LABELID}|{REFWORD2}|{REFWORD3}|{LNKWORD2}
<St_PlantUML>. { /* plantuml text */ <St_PlantUML>. { /* plantuml text */
g_token->verb+=yytext; g_token->verb+=yytext;
} }
<St_Caption>"\"" { // quoted title
BEGIN(St_TitleQ);
return TK_WORD;
}
<St_Caption>[ \t]+ {
g_token->name="";
g_token->chars=yytext;
return TK_WHITESPACE;
}
<St_Caption>\n {
unput(*yytext);
return 0;
}
<St_Title>"\"" { // quoted title <St_Title>"\"" { // quoted title
BEGIN(St_TitleQ); BEGIN(St_TitleQ);
} }
...@@ -940,6 +958,34 @@ REFWORD {LABELID}|{REFWORD2}|{REFWORD3}|{LNKWORD2} ...@@ -940,6 +958,34 @@ REFWORD {LABELID}|{REFWORD2}|{REFWORD3}|{LNKWORD2}
unput(*yytext); unput(*yytext);
return 0; return 0;
} }
<St_Caption>{BLANK}*"min"{BLANK}* { // title special case min / max
g_token->name = "min";
BEGIN(St_TitleA);
return TK_WORD;
}
<St_Caption>{BLANK}*"max"{BLANK}* { // title special case min / max
g_token->name = "max";
BEGIN(St_TitleA);
return TK_WORD;
}
<St_Caption>{BLANK}*"width="{BLANK}* { // title attribute
g_token->name = yytext;
g_token->name = g_token->name.stripWhiteSpace();
BEGIN(St_TitleV);
}
<St_Caption>{BLANK}*"height="{BLANK}* { // title attribute
g_token->name = yytext;
g_token->name = g_token->name.stripWhiteSpace();
BEGIN(St_TitleV);
}
<St_TitleA>{BLANK}*"min"{BLANK}* { // title special case min / max
g_token->name = "min";
return TK_WORD;
}
<St_TitleA>{BLANK}*"max"{BLANK}* { // title special case min / max
g_token->name = "max";
return TK_WORD;
}
<St_TitleA>{BLANK}*{ID}{BLANK}*"="{BLANK}* { // title attribute <St_TitleA>{BLANK}*{ID}{BLANK}*"="{BLANK}* { // title attribute
g_token->name = yytext; g_token->name = yytext;
g_token->name = g_token->name.left( g_token->name = g_token->name.left(
...@@ -951,6 +997,10 @@ REFWORD {LABELID}|{REFWORD2}|{REFWORD3}|{LNKWORD2} ...@@ -951,6 +997,10 @@ REFWORD {LABELID}|{REFWORD2}|{REFWORD3}|{LNKWORD2}
BEGIN(St_TitleN); BEGIN(St_TitleN);
return TK_WORD; return TK_WORD;
} }
<St_TitleV,St_TitleA>[ \t] {
g_token->chars=yytext;
return TK_WHITESPACE;
}
<St_TitleV,St_TitleA>. { <St_TitleV,St_TitleA>. {
unput(*yytext); unput(*yytext);
return 0; return 0;
...@@ -1267,6 +1317,16 @@ void doctokenizerYYsetStateTitle() ...@@ -1267,6 +1317,16 @@ void doctokenizerYYsetStateTitle()
BEGIN(St_Title); BEGIN(St_Title);
} }
void doctokenizerYYsetStateCaption()
{
BEGIN(St_Caption);
}
void doctokenizerYYsetStateTitleAttr()
{
BEGIN(St_TitleA);
}
void doctokenizerYYsetStateTitleAttrValue() void doctokenizerYYsetStateTitleAttrValue()
{ {
BEGIN(St_TitleV); BEGIN(St_TitleV);
...@@ -1341,13 +1401,19 @@ void doctokenizerYYsetStateMsc() ...@@ -1341,13 +1401,19 @@ void doctokenizerYYsetStateMsc()
BEGIN(St_Msc); BEGIN(St_Msc);
} }
void doctokenizerYYsetStatePlantUML() void doctokenizerYYsetStatePlantUMLOpt()
{ {
g_token->verb=""; g_token->verb="";
g_token->sectionId=""; g_token->sectionId="";
BEGIN(St_PlantUMLOpt); BEGIN(St_PlantUMLOpt);
} }
void doctokenizerYYsetStatePlantUML()
{
g_token->verb="";
BEGIN(St_PlantUML);
}
void doctokenizerYYsetStateParam() void doctokenizerYYsetStateParam()
{ {
BEGIN(St_Param); BEGIN(St_Param);
......
...@@ -325,6 +325,32 @@ void HtmlDocVisitor::visit(DocStyleChange *s) ...@@ -325,6 +325,32 @@ void HtmlDocVisitor::visit(DocStyleChange *s)
} }
static void visitPreCaption(FTextStream &t, DocVerbatim *s)
{
if (s->hasCaption())
{
t << "<div class=\"caption\">" << endl;
}
}
static void visitPostCaption(FTextStream &t, DocVerbatim *s)
{
if (s->hasCaption())
{
t << "</div>" << endl;
}
}
static void visitCaption(HtmlDocVisitor *parent, QList<DocNode> children)
{
QListIterator<DocNode> cli(children);
DocNode *n;
for (cli.toFirst();(n=cli.current());++cli) n->accept(parent);
}
void HtmlDocVisitor::visit(DocVerbatim *s) void HtmlDocVisitor::visit(DocVerbatim *s)
{ {
if (m_hide) return; if (m_hide) return;
...@@ -382,6 +408,7 @@ void HtmlDocVisitor::visit(DocVerbatim *s) ...@@ -382,6 +408,7 @@ void HtmlDocVisitor::visit(DocVerbatim *s)
static int dotindex = 1; static int dotindex = 1;
QCString fileName(4096); QCString fileName(4096);
forceEndParagraph(s);
fileName.sprintf("%s%d%s", fileName.sprintf("%s%d%s",
(Config_getString("HTML_OUTPUT")+"/inline_dotgraph_").data(), (Config_getString("HTML_OUTPUT")+"/inline_dotgraph_").data(),
dotindex++, dotindex++,
...@@ -392,17 +419,22 @@ void HtmlDocVisitor::visit(DocVerbatim *s) ...@@ -392,17 +419,22 @@ void HtmlDocVisitor::visit(DocVerbatim *s)
{ {
err("Could not open file %s for writing\n",fileName.data()); err("Could not open file %s for writing\n",fileName.data());
} }
else
{
file.writeBlock( s->text(), s->text().length() ); file.writeBlock( s->text(), s->text().length() );
file.close(); file.close();
forceEndParagraph(s);
m_t << "<div align=\"center\">" << endl; m_t << "<div align=\"center\">" << endl;
writeDotFile(fileName,s->relPath(),s->context()); writeDotFile(fileName,s->relPath(),s->context());
visitPreCaption(m_t, s);
visitCaption(this, s->m_children);
visitPostCaption(m_t, s);
m_t << "</div>" << endl; m_t << "</div>" << endl;
forceStartParagraph(s);
if (Config_getBool("DOT_CLEANUP")) file.remove(); if (Config_getBool("DOT_CLEANUP")) file.remove();
} }
forceStartParagraph(s);
}
break; break;
case DocVerbatim::Msc: case DocVerbatim::Msc:
{ {
...@@ -420,6 +452,8 @@ void HtmlDocVisitor::visit(DocVerbatim *s) ...@@ -420,6 +452,8 @@ void HtmlDocVisitor::visit(DocVerbatim *s)
{ {
err("Could not open file %s.msc for writing\n",baseName.data()); err("Could not open file %s.msc for writing\n",baseName.data());
} }
else
{
QCString text = "msc {"; QCString text = "msc {";
text+=s->text(); text+=s->text();
text+="}"; text+="}";
...@@ -429,8 +463,13 @@ void HtmlDocVisitor::visit(DocVerbatim *s) ...@@ -429,8 +463,13 @@ void HtmlDocVisitor::visit(DocVerbatim *s)
m_t << "<div align=\"center\">" << endl; m_t << "<div align=\"center\">" << endl;
writeMscFile(baseName+".msc",s->relPath(),s->context()); writeMscFile(baseName+".msc",s->relPath(),s->context());
if (Config_getBool("DOT_CLEANUP")) file.remove(); visitPreCaption(m_t, s);
visitCaption(this, s->m_children);
visitPostCaption(m_t, s);
m_t << "</div>" << endl; m_t << "</div>" << endl;
if (Config_getBool("DOT_CLEANUP")) file.remove();
}
forceStartParagraph(s); forceStartParagraph(s);
} }
break; break;
...@@ -442,6 +481,9 @@ void HtmlDocVisitor::visit(DocVerbatim *s) ...@@ -442,6 +481,9 @@ void HtmlDocVisitor::visit(DocVerbatim *s)
QCString baseName = writePlantUMLSource(htmlOutput,s->exampleFile(),s->text()); QCString baseName = writePlantUMLSource(htmlOutput,s->exampleFile(),s->text());
m_t << "<div align=\"center\">" << endl; m_t << "<div align=\"center\">" << endl;
writePlantUMLFile(baseName,s->relPath(),s->context()); writePlantUMLFile(baseName,s->relPath(),s->context());
visitPreCaption(m_t, s);
visitCaption(this, s->m_children);
visitPostCaption(m_t, s);
m_t << "</div>" << endl; m_t << "</div>" << endl;
forceStartParagraph(s); forceStartParagraph(s);
} }
......
This diff is collapsed.
...@@ -170,13 +170,13 @@ class LatexDocVisitor : public DocVisitor ...@@ -170,13 +170,13 @@ class LatexDocVisitor : public DocVisitor
void startMscFile(const QCString &fileName,const QCString &width, void startMscFile(const QCString &fileName,const QCString &width,
const QCString &height, bool hasCaption); const QCString &height, bool hasCaption);
void endMscFile(bool hasCaption); void endMscFile(bool hasCaption);
void writeMscFile(const QCString &fileName); void writeMscFile(const QCString &fileName, DocVerbatim *s);
void startDiaFile(const QCString &fileName,const QCString &width, void startDiaFile(const QCString &fileName,const QCString &width,
const QCString &height, bool hasCaption); const QCString &height, bool hasCaption);
void endDiaFile(bool hasCaption); void endDiaFile(bool hasCaption);
void writeDiaFile(const QCString &fileName); void writeDiaFile(const QCString &fileName, DocVerbatim *s);
void writePlantUMLFile(const QCString &fileName); void writePlantUMLFile(const QCString &fileName, DocVerbatim *s);
void pushEnabled(); void pushEnabled();
void popEnabled(); void popEnabled();
......
...@@ -270,7 +270,7 @@ static void writeDefaultHeaderPart1(FTextStream &t) ...@@ -270,7 +270,7 @@ static void writeDefaultHeaderPart1(FTextStream &t)
"\\usepackage{fixltx2e}\n" // for \textsubscript "\\usepackage{fixltx2e}\n" // for \textsubscript
"\\usepackage{calc}\n" "\\usepackage{calc}\n"
"\\usepackage{doxygen}\n" "\\usepackage{doxygen}\n"
"\\usepackage{graphicx}\n" "\\usepackage[export]{adjustbox} % also loads graphicx\n"
"\\usepackage[utf8]{inputenc}\n" "\\usepackage[utf8]{inputenc}\n"
"\\usepackage{makeidx}\n" "\\usepackage{makeidx}\n"
"\\usepackage{multicol}\n" "\\usepackage{multicol}\n"
......
...@@ -483,7 +483,7 @@ class PrintDocVisitor : public DocVisitor ...@@ -483,7 +483,7 @@ class PrintDocVisitor : public DocVisitor
case DocImage::Rtf: printf("rtf"); break; case DocImage::Rtf: printf("rtf"); break;
case DocImage::DocBook: printf("docbook"); break; case DocImage::DocBook: printf("docbook"); break;
} }
printf("\" width=%s height=%s>\n",img->width().data(),img->height().data()); printf("\" %s %s>\n",img->width().data(),img->height().data());
} }
void visitPost(DocImage *) void visitPost(DocImage *)
{ {
......
...@@ -32,6 +32,71 @@ ...@@ -32,6 +32,71 @@
#include "config.h" #include "config.h"
#include "htmlentity.h" #include "htmlentity.h"
static void visitCaption(XmlDocVisitor *parent, QList<DocNode> children)
{
QListIterator<DocNode> cli(children);
DocNode *n;
for (cli.toFirst();(n=cli.current());++cli) n->accept(parent);
}
static void visitPreStart(FTextStream &t, const char *cmd, const bool doCaption, XmlDocVisitor *parent, QList<DocNode> children, QCString name, DocImage::Type type, QCString width, QCString height)
{
QCString tmpStr;
t << "<" << cmd;
if (type != DocImage::None)
{
t << " type=\"";
switch(type)
{
case DocImage::Html: t << "html"; break;
case DocImage::Latex: t << "latex"; break;
case DocImage::Rtf: t << "rtf"; break;
case DocImage::DocBook: t << "docbook"; break;
}
t << "\"";
}
if (!name.isEmpty())
{
t << " name=\"" << name << "\"";
}
if (!width.isEmpty())
{
tmpStr = width;
tmpStr = tmpStr.replace(QRegExp("min *width"),"minwidth");
tmpStr = tmpStr.replace(QRegExp("max *width"),"maxwidth");
tmpStr = tmpStr.replace(QRegExp("="),"=\"");
tmpStr = tmpStr.replace(QRegExp(","),"\" ") + "\"";
tmpStr = tmpStr.replace(QRegExp("\"\""),"\"");
tmpStr = tmpStr.replace(QRegExp("\\"),"\\\\");
t << " " << tmpStr;
}
if (!height.isEmpty())
{
tmpStr = height;
tmpStr = tmpStr.replace(QRegExp("min *height"),"minheight");
tmpStr = tmpStr.replace(QRegExp("max *height"),"maxheight");
tmpStr = tmpStr.replace(QRegExp("="),"=\"");
tmpStr = tmpStr.replace(QRegExp(","),"\" ") + "\"";
tmpStr = tmpStr.replace(QRegExp("\"\""),"\"");
tmpStr = tmpStr.replace(QRegExp("\\"),"\\\\");
t << " " << tmpStr;
}
if (doCaption)
{
t << " caption=\"";
visitCaption(parent, children);
t << "\"";
}
t << ">";
}
static void visitPostEnd(FTextStream &t, const char *cmd, const bool doCaption)
{
t << "</" << cmd << ">" << endl;
}
XmlDocVisitor::XmlDocVisitor(FTextStream &t,CodeOutputInterface &ci) XmlDocVisitor::XmlDocVisitor(FTextStream &t,CodeOutputInterface &ci)
: DocVisitor(DocVisitor_XML), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE) : DocVisitor(DocVisitor_XML), m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE)
{ {
...@@ -200,19 +265,19 @@ void XmlDocVisitor::visit(DocVerbatim *s) ...@@ -200,19 +265,19 @@ void XmlDocVisitor::visit(DocVerbatim *s)
m_t << "</docbookonly>"; m_t << "</docbookonly>";
break; break;
case DocVerbatim::Dot: case DocVerbatim::Dot:
m_t << "<dot>"; visitPreStart(m_t, "dot", s->hasCaption(), this, s->children(), QCString(""), DocImage::None, s->width(), s->height());
filter(s->text()); filter(s->text());
m_t << "</dot>"; visitPostEnd(m_t, "dot", s->hasCaption());
break; break;
case DocVerbatim::Msc: case DocVerbatim::Msc:
m_t << "<msc>"; visitPreStart(m_t, "msc", s->hasCaption(), this, s->children(), QCString(""), DocImage::None, s->width(), s->height());
filter(s->text()); filter(s->text());
m_t << "</msc>"; visitPostEnd(m_t, "msc", s->hasCaption());
break; break;
case DocVerbatim::PlantUML: case DocVerbatim::PlantUML:
m_t << "<plantuml>"; visitPreStart(m_t, "plantuml", s->hasCaption(), this, s->children(), QCString(""), DocImage::None, s->width(), s->height());
filter(s->text()); filter(s->text());
m_t << "</plantuml>"; visitPostEnd(m_t, "plantuml", s->hasCaption());
break; break;
} }
} }
...@@ -682,15 +747,6 @@ void XmlDocVisitor::visitPost(DocHtmlHeader *) ...@@ -682,15 +747,6 @@ void XmlDocVisitor::visitPost(DocHtmlHeader *)
void XmlDocVisitor::visitPre(DocImage *img) void XmlDocVisitor::visitPre(DocImage *img)
{ {
if (m_hide) return; if (m_hide) return;
m_t << "<image type=\"";
switch(img->type())
{
case DocImage::Html: m_t << "html"; break;
case DocImage::Latex: m_t << "latex"; break;
case DocImage::Rtf: m_t << "rtf"; break;
case DocImage::DocBook: m_t << "docbook"; break;
}
m_t << "\"";
QCString baseName=img->name(); QCString baseName=img->name();
int i; int i;
...@@ -698,20 +754,7 @@ void XmlDocVisitor::visitPre(DocImage *img) ...@@ -698,20 +754,7 @@ void XmlDocVisitor::visitPre(DocImage *img)
{ {
baseName=baseName.right(baseName.length()-i-1); baseName=baseName.right(baseName.length()-i-1);
} }
m_t << " name=\"" << baseName << "\""; visitPreStart(m_t, "image", FALSE, this, img->children(), baseName, img->type(), img->width(), img->height());
if (!img->width().isEmpty())
{
m_t << " width=\"";
filter(img->width());
m_t << "\"";
}
else if (!img->height().isEmpty())
{
m_t << " height=\"";
filter(img->height());
m_t << "\"";
}
m_t << ">";
// copy the image to the output dir // copy the image to the output dir
QFile inImage(img->name()); QFile inImage(img->name());
...@@ -732,43 +775,43 @@ void XmlDocVisitor::visitPre(DocImage *img) ...@@ -732,43 +775,43 @@ void XmlDocVisitor::visitPre(DocImage *img)
void XmlDocVisitor::visitPost(DocImage *) void XmlDocVisitor::visitPost(DocImage *)
{ {
if (m_hide) return; if (m_hide) return;
m_t << "</image>" << endl; visitPostEnd(m_t, "image", FALSE);
} }
void XmlDocVisitor::visitPre(DocDotFile *df) void XmlDocVisitor::visitPre(DocDotFile *df)
{ {
if (m_hide) return; if (m_hide) return;
m_t << "<dotfile name=\"" << df->file() << "\">"; visitPreStart(m_t, "dotfile", FALSE, this, df->children(), df->file(), DocImage::None, df->width(), df->height());
} }
void XmlDocVisitor::visitPost(DocDotFile *) void XmlDocVisitor::visitPost(DocDotFile *)
{ {
if (m_hide) return; if (m_hide) return;
m_t << "</dotfile>" << endl; visitPostEnd(m_t, "dotfile", FALSE);
} }
void XmlDocVisitor::visitPre(DocMscFile *df) void XmlDocVisitor::visitPre(DocMscFile *df)
{ {
if (m_hide) return; if (m_hide) return;
m_t << "<mscfile name=\"" << df->file() << "\">"; visitPreStart(m_t, "mscfile", FALSE, this, df->children(), df->file(), DocImage::None, df->width(), df->height());
} }
void XmlDocVisitor::visitPost(DocMscFile *) void XmlDocVisitor::visitPost(DocMscFile *)
{ {
if (m_hide) return; if (m_hide) return;
m_t << "</mscfile>" << endl; visitPostEnd(m_t, "mscfile", FALSE);
} }
void XmlDocVisitor::visitPre(DocDiaFile *df) void XmlDocVisitor::visitPre(DocDiaFile *df)
{ {
if (m_hide) return; if (m_hide) return;
m_t << "<diafile name=\"" << df->file() << "\">"; visitPreStart(m_t, "diafile", FALSE, this, df->children(), df->file(), DocImage::None, df->width(), df->height());
} }
void XmlDocVisitor::visitPost(DocDiaFile *) void XmlDocVisitor::visitPost(DocDiaFile *)
{ {
if (m_hide) return; if (m_hide) return;
m_t << "</diafile>" << endl; visitPostEnd(m_t, "diafile", FALSE);
} }
void XmlDocVisitor::visitPre(DocLink *lnk) void XmlDocVisitor::visitPre(DocLink *lnk)
......
...@@ -142,7 +142,9 @@ ...@@ -142,7 +142,9 @@
% Used by @image, @dotfile, @dot ... @enddot, and @msc ... @endmsc % Used by @image, @dotfile, @dot ... @enddot, and @msc ... @endmsc
% (only if no caption is specified) % (only if no caption is specified)
\newenvironment{DoxyImageNoCaption}{% \newenvironment{DoxyImageNoCaption}{%
\begin{center}%
}{% }{%
\end{center}%
} }
% Used by @attention % Used by @attention
......
...@@ -11,7 +11,8 @@ digraph example { ...@@ -11,7 +11,8 @@ digraph example {
c [ label="class C" URL="\ref C"]; c [ label="class C" URL="\ref C"];
b -&gt; c [ arrowhead="open", style="dashed" ]; b -&gt; c [ arrowhead="open", style="dashed" ];
} }
</dot> </para> </dot>
</para>
</detaileddescription> </detaileddescription>
</compounddef> </compounddef>
</doxygen> </doxygen>
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<detaileddescription> <detaileddescription>
<para>Some text. <image type="html" name="sample.png"/> <para>Some text. <image type="html" name="sample.png"/>
<image type="latex" name="sample.png" width="5cm">Doxygen logo</image> <image type="latex" name="sample.png" width="5cm">Doxygen logo</image>
More text. </para> More text. </para>
</detaileddescription> </detaileddescription>
</compounddef> </compounddef>
</doxygen> </doxygen>
...@@ -29,7 +29,8 @@ ...@@ -29,7 +29,8 @@
Receiver,Sender; Receiver,Sender;
Receiver&lt;-Sender [label="Command()", URL="\ref Command()"]; Receiver&lt;-Sender [label="Command()", URL="\ref Command()"];
Receiver-&gt;Sender [label="Ack()", URL="\ref Sender::Ack()", ID="1"]; Receiver-&gt;Sender [label="Ack()", URL="\ref Sender::Ack()", ID="1"];
</msc> </para> </msc>
</para>
</detaileddescription> </detaileddescription>
<location file="037_msc.cpp" bodystart="28" bodyend="33"/> <location file="037_msc.cpp" bodystart="28" bodyend="33"/>
<listofallmembers> <listofallmembers>
......
...@@ -29,7 +29,8 @@ ...@@ -29,7 +29,8 @@
Sender,Receiver; Sender,Receiver;
Sender-&gt;Receiver [label="Command()", URL="\ref Receiver::Command()"]; Sender-&gt;Receiver [label="Command()", URL="\ref Receiver::Command()"];
Sender&lt;-Receiver [label="Ack()", URL="\ref Ack()", ID="1"]; Sender&lt;-Receiver [label="Ack()", URL="\ref Ack()", ID="1"];
</msc> </para> </msc>
</para>
</detaileddescription> </detaileddescription>
<location file="037_msc.cpp" bodystart="13" bodyend="18"/> <location file="037_msc.cpp" bodystart="13" bodyend="18"/>
<listofallmembers> <listofallmembers>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment