summaryrefslogtreecommitdiffstats
path: root/src/htmldocvisitor.h
diff options
context:
space:
mode:
authordimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7>2002-08-26 17:33:07 (GMT)
committerdimitri <dimitri@afe2bf4a-e733-0410-8a33-86f594647bc7>2002-08-26 17:33:07 (GMT)
commit55d2ef8412008e1560b0d5a2ecc2031f269af4a1 (patch)
tree6d5ee0db5c717ebabc57f2d2a15a1365d5e3fa19 /src/htmldocvisitor.h
parent17e35fd285d98df3c7fe59ee8805152726c3572e (diff)
downloadDoxygen-55d2ef8412008e1560b0d5a2ecc2031f269af4a1.zip
Doxygen-55d2ef8412008e1560b0d5a2ecc2031f269af4a1.tar.gz
Doxygen-55d2ef8412008e1560b0d5a2ecc2031f269af4a1.tar.bz2
Release-1.2.17-20020826
Diffstat (limited to 'src/htmldocvisitor.h')
-rw-r--r--src/htmldocvisitor.h244
1 files changed, 151 insertions, 93 deletions
diff --git a/src/htmldocvisitor.h b/src/htmldocvisitor.h
index 9f0f699..39956da 100644
--- a/src/htmldocvisitor.h
+++ b/src/htmldocvisitor.h
@@ -25,8 +25,9 @@
#include "doxygen.h"
#include "outputgen.h"
#include "code.h"
+#include "dot.h"
-/*! Concrete visitor implementation for pretty printing */
+/*! @brief Concrete visitor implementation for HTML output. */
class HtmlDocVisitor : public DocVisitor
{
public:
@@ -34,6 +35,8 @@ class HtmlDocVisitor : public DocVisitor
: m_t(t), m_ci(ci), m_insidePre(FALSE), m_hide(FALSE) {}
//--------------------------------------
+ // visitor functions for leaf nodes
+ //--------------------------------------
void visit(DocWord *w)
{
@@ -91,7 +94,7 @@ class HtmlDocVisitor : public DocVisitor
void visit(DocURL *u)
{
if (m_hide) return;
- m_t << "<a href=\"" << u->url() << "\">" << u->url() << "</a> ";
+ m_t << "<a href=\"" << u->url() << "\">" << u->url() << "</a>";
}
void visit(DocLineBreak *)
{
@@ -159,39 +162,50 @@ class HtmlDocVisitor : public DocVisitor
if (m_hide) return;
m_t << "<a name=\"%s\"/></a>";
}
- void visit(DocCopy *c)
- {
- if (m_hide) return;
- // TODO
- printf("<copy link=\"%s\"/>",c->link().data());
- }
void visit(DocInclude *inc)
{
if (m_hide) return;
- // TODO
- printf("<include file=\"%s\" type=\"",inc->file().data());
switch(inc->type())
{
- case DocInclude::Include: printf("include"); break;
- case DocInclude::DontInclude: printf("dontinclude"); break;
- case DocInclude::HtmlInclude: printf("htmlinclude"); break;
- case DocInclude::VerbInclude: printf("verbinclude"); break;
+ case DocInclude::Include:
+ m_t << "<div class=\"fragment\"><pre>";
+ parseCode(m_ci,inc->context(),inc->text(),FALSE,0);
+ m_t << "</pre></div>";
+ break;
+ case DocInclude::DontInclude:
+ break;
+ case DocInclude::HtmlInclude:
+ m_t << inc->text();
+ break;
+ case DocInclude::VerbInclude:
+ m_t << "<div class=\"fragment\"><pre>";
+ filter(inc->text());
+ m_t << "</pre></div>";
+ break;
}
- printf("\"/>");
}
void visit(DocIncOperator *op)
{
- if (m_hide) return;
- // TODO
- printf("<incoperator pattern=\"%s\" type=\"",op->pattern().data());
- switch(op->type())
+ //printf("DocIncOperator: type=%d first=%d, last=%d text=`%s'\n",
+ // op->type(),op->isFirst(),op->isLast(),op->text().data());
+ if (op->isFirst())
+ {
+ m_t << "<div class=\"fragment\"><pre>";
+ m_hide = TRUE;
+ }
+ if (op->type()!=DocIncOperator::Skip)
+ {
+ parseCode(m_ci,op->context(),op->text(),FALSE,0);
+ }
+ if (op->isLast())
+ {
+ m_hide = FALSE;
+ m_t << "</pre></div>";
+ }
+ else
{
- case DocIncOperator::Line: printf("line"); break;
- case DocIncOperator::Skip: printf("skip"); break;
- case DocIncOperator::SkipLine: printf("skipline"); break;
- case DocIncOperator::Until: printf("until"); break;
+ m_t << endl;
}
- printf("\"/>");
}
void visit(DocFormula *f)
{
@@ -205,9 +219,15 @@ class HtmlDocVisitor : public DocVisitor
m_t << "\"middle\""; // assume Windows users use IE or HtmlHelp which on
// displays formulas nicely with align == "middle"
#endif
- m_t << " src=\"" << f->name() << ".png\">" << endl;
- if (f->text().at(0)=='\\') m_t << "</center><p>" << endl;
+ m_t << " src=\"" << f->name() << ".png\">";
+ if (f->text().at(0)=='\\')
+ m_t << endl << "</center><p>" << endl;
+ else
+ m_t << " ";
}
+
+ //--------------------------------------
+ // visitor functions for compound nodes
//--------------------------------------
void visitPre(DocAutoList *l)
@@ -249,15 +269,15 @@ class HtmlDocVisitor : public DocVisitor
!(p->parent() && // and for parameter sections
p->parent()->kind()==DocNode::Kind_ParamSect
)
- ) m_t << "<p>\n";
+ ) m_t << "\n<p>\n";
}
void visitPre(DocRoot *)
{
- m_t << "<hr><h4><font color=\"red\">New parser:</font></h4>\n";
+ //m_t << "<hr><h4><font color=\"red\">New parser:</font></h4>\n";
}
void visitPost(DocRoot *)
{
- m_t << "<hr><h4><font color=\"red\">Old parser:</font></h4>\n";
+ //m_t << "<hr><h4><font color=\"red\">Old parser:</font></h4>\n";
}
void visitPre(DocSimpleSect *s)
{
@@ -295,12 +315,11 @@ class HtmlDocVisitor : public DocVisitor
case DocSimpleSect::User: break;
case DocSimpleSect::Unknown: break;
}
- m_t << ":";
// special case 1: user defined title
if (s->type()!=DocSimpleSect::User)
{
- m_t << "</b></dt><dd>";
+ m_t << ":</b></dt><dd>";
}
}
void visitPost(DocSimpleSect *)
@@ -332,11 +351,14 @@ class HtmlDocVisitor : public DocVisitor
}
void visitPre(DocSection *s)
{
- m_t << "<h%d>",s->level();
+ m_t << "<h" << s->level()+1 << ">";
+ m_t << "<a name=\"" << s->anchor();
+ filter(s->title());
+ m_t << "\"</a>" << endl;
+ m_t << "</h" << s->level()+1 << ">\n";
}
- void visitPost(DocSection *s)
+ void visitPost(DocSection *)
{
- m_t << "</h%d>\n",s->level();
}
void visitPre(DocHtmlList *s)
{
@@ -449,7 +471,7 @@ class HtmlDocVisitor : public DocVisitor
}
void visitPost(DocHRef *)
{
- m_t << "</a>\n";
+ m_t << "</a>";
}
void visitPre(DocHtmlHeader *header)
{
@@ -461,18 +483,68 @@ class HtmlDocVisitor : public DocVisitor
}
void visitPre(DocImage *img)
{
- m_t << "<img src=\"" << img->name() << "\">\n";
+ if (img->type()==DocImage::Html)
+ {
+ QCString baseName=img->name();
+ int i;
+ if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1)
+ {
+ baseName=baseName.right(baseName.length()-i-1);
+ }
+ m_t << "<div align=\"center\">" << endl;
+ m_t << "<img src=\"" << img->name() << "\" alt=\""
+ << baseName << "\">" << endl;
+ if (img->hasCaption())
+ {
+ m_t << "<p><strong>";
+ }
+ }
+ else // other format -> skip
+ {
+ m_hide=TRUE;
+ }
}
- void visitPost(DocImage *)
+ void visitPost(DocImage *img)
{
+ if (img->type()==DocImage::Html)
+ {
+ if (img->hasCaption())
+ {
+ m_t << "</strong></p>";
+ }
+ m_t << "</div>" << endl;
+ }
+ else // other format
+ {
+ m_hide=FALSE;
+ }
}
- void visitPre(DocDotFile *)
+ void visitPre(DocDotFile *df)
{
- // TODO
+ QCString baseName=df->file();
+ int i;
+ if ((i=baseName.findRev('/'))!=-1)
+ {
+ baseName=baseName.right(baseName.length()-i-1);
+ }
+ QCString outDir = Config_getString("HTML_OUTPUT");
+ writeDotGraphFromFile(df->file(),outDir,baseName,BITMAP);
+ m_t << "<div align=\"center\">" << endl;
+ m_t << "<img src=\"" << baseName << "."
+ << Config_getEnum("DOT_IMAGE_FORMAT") << "\" alt=\""
+ << baseName << "\">" << endl;
+ if (df->hasCaption())
+ {
+ m_t << "<p><strong>";
+ }
}
- void visitPost(DocDotFile *)
+ void visitPost(DocDotFile *df)
{
- // TODO
+ if (df->hasCaption())
+ {
+ m_t << "</strong></p>" << endl;
+ }
+ m_t << "</div>" << endl;
}
void visitPre(DocLink *lnk)
{
@@ -490,30 +562,37 @@ class HtmlDocVisitor : public DocVisitor
void visitPost(DocRef *)
{
endLink();
+ m_t << " ";
}
- void visitPre(DocSecRefItem *)
+ void visitPre(DocSecRefItem *ref)
{
- // TODO
+ QCString refName=ref->file();
+ if (refName.right(Doxygen::htmlFileExtension.length())!=Doxygen::htmlFileExtension)
+ {
+ refName+=Doxygen::htmlFileExtension;
+ }
+ m_t << "<li><a href=\"" << refName << "#" << ref->anchor() << "\">";
+
}
void visitPost(DocSecRefItem *)
{
- // TODO
+ m_t << "</a> ";
}
void visitPre(DocSecRefList *)
{
- // TODO
+ m_t << "<multicol cols=3>" << endl;
+ m_t << "<ul>" << endl;
}
void visitPost(DocSecRefList *)
{
- // TODO
+ m_t << "</ul>" << endl;
+ m_t << "</multicol>" << endl;
}
void visitPre(DocLanguage *)
{
- // TODO
}
void visitPost(DocLanguage *)
{
- // TODO
}
void visitPre(DocParamSect *s)
{
@@ -526,6 +605,8 @@ class HtmlDocVisitor : public DocVisitor
m_t << theTranslator->trReturnValues(); break;
case DocParamSect::Exception:
m_t << theTranslator->trExceptions(); break;
+ default:
+ ASSERT(0);
}
m_t << ":";
m_t << "</b></dt><dd>" << endl;
@@ -556,8 +637,9 @@ class HtmlDocVisitor : public DocVisitor
void visitPre(DocXRefItem *x)
{
m_t << "<dl compact><dt><b><a class=\"el\" href=\""
- << x->file() << Doxygen::htmlFileExtension << "#" << x->anchor() << "\">"
- << x->title() << ":</a></b></dt><dd>";
+ << x->file() << Doxygen::htmlFileExtension << "#" << x->anchor() << "\">";
+ filter(x->title());
+ m_t << ":</a></b></dt><dd>";
}
void visitPost(DocXRefItem *)
{
@@ -570,54 +652,30 @@ class HtmlDocVisitor : public DocVisitor
void visitPost(DocInternalRef *)
{
endLink();
+ m_t << " ";
}
-
- private:
- void filter(const char *str)
- {
- if (str==0) return;
- const char *p=str;
- char c;
- while (*p)
- {
- c=*p++;
- switch(c)
- {
- case '<': m_t << "&lt;"; break;
- case '>': m_t << "&gt;"; break;
- case '&': m_t << "&amp;"; break;
- default: m_t << c;
- }
- }
- }
-
- void startLink(const QCString &ref,const QCString &file,const QCString &anchor)
+ void visitPre(DocCopy *)
{
- QCString *dest;
- if (!ref.isEmpty()) // link to entity imported via tag file
- {
- m_t << "<a class=\"elRef\" ";
- m_t << "doxygen=\"" << ref << ":";
- if ((dest=Doxygen::tagDestinationDict[ref])) m_t << *dest << "/";
- m_t << "\" ";
- }
- else // local link
- {
- m_t << "<a class=\"el\" ";
- }
- m_t << "href=\"";
- if (!ref.isEmpty())
- {
- if ((dest=Doxygen::tagDestinationDict[ref])) m_t << *dest << "/";
- }
- if (!file.isEmpty()) m_t << file << Doxygen::htmlFileExtension;
- if (!anchor.isEmpty()) m_t << "#" << anchor;
- m_t << "\">";
}
- void endLink()
+ void visitPost(DocCopy *)
{
- m_t << "</a> ";
}
+
+ private:
+
+ //--------------------------------------
+ // helper functions
+ //--------------------------------------
+
+ void filter(const char *str);
+ void startLink(const QCString &ref,const QCString &file,
+ const QCString &anchor);
+ void endLink();
+
+ //--------------------------------------
+ // state variables
+ //--------------------------------------
+
QTextStream &m_t;
BaseCodeDocInterface &m_ci;
bool m_insidePre;