/****************************************************************************** * * * * Copyright (C) 1997-2002 by Dimitri van Heesch. * * Permission to use, copy, modify, and distribute this software and its * documentation under the terms of the GNU General Public License is hereby * granted. No representations are made about the suitability of this software * for any purpose. It is provided "as is" without express or implied warranty. * See the GNU General Public License for more details. * * Documents produced by Doxygen are derivative works derived from the * input used in their production; they are not affected by this license. * */ #include #include "qtbc.h" #include #include "message.h" #include "htmlgen.h" #include "config.h" #include "util.h" #include "doxygen.h" #include "logos.h" #include "diagram.h" #include "version.h" #include "dot.h" #include "language.h" #include "htmlhelp.h" #include "htmldocvisitor.h" // #define GROUP_COLOR "#ff8080" //#define DBG_HTML(x) x; #define DBG_HTML(x) /* changed default stylesheet, startIndexKey(), startIndexValue() 02 jan 2002, jh */ static const char *defaultStyleSheet = "H1 { text-align: center; }\n" "CAPTION { font-weight: bold }\n" "A.qindex {}\n" "A.qindexRef {}\n" "A.el { text-decoration: none; font-weight: bold }\n" "A.elRef { font-weight: bold }\n" "A.code { text-decoration: none; font-weight: normal; color: #4444ee }\n" "A.codeRef { font-weight: normal; color: #4444ee }\n" "A:hover { text-decoration: none; background-color: #f2f2ff }\n" "DL.el { margin-left: -1cm }\n" "DIV.fragment { width: 100%; border: none; background-color: #eeeeee }\n" "DIV.ah { background-color: black; font-weight: bold; color: #ffffff; margin-bottom: 3px; margin-top: 3px }\n" "TD.md { background-color: #f2f2ff; font-weight: bold; }\n" "TD.mdname1 { background-color: #f2f2ff; font-weight: bold; color: #602020; }\n" "TD.mdname { background-color: #f2f2ff; font-weight: bold; color: #602020; width: 600px; }\n" "DIV.groupHeader { margin-left: 16px; margin-top: 12px; margin-bottom: 6px; font-weight: bold }\n" "DIV.groupText { margin-left: 16px; font-style: italic; font-size: smaller }\n" "BODY { background: white }\n" "TD.indexkey { \n" " background-color: #eeeeff; \n" " font-weight: bold; \n" " padding-right : 10px; \n" " padding-top : 2px; \n" " padding-left : 10px; \n" " padding-bottom : 2px; \n" " margin-left : 0px; \n" " margin-right : 0px; \n" " margin-top : 2px; \n" " margin-bottom : 2px \n" "}\n" "TD.indexvalue { \n" " background-color: #eeeeff; \n" " font-style: italic; \n" " padding-right : 10px; \n" " padding-top : 2px; \n" " padding-left : 10px; \n" " padding-bottom : 2px; \n" " margin-left : 0px; \n" " margin-right : 0px; \n" " margin-top : 2px; \n" " margin-bottom : 2px \n" "}\n" "span.keyword { color: #008000 }\n" "span.keywordtype { color: #604020 }\n" "span.keywordflow { color: #e08000 }\n" "span.comment { color: #800000 }\n" "span.preprocessor { color: #806020 }\n" "span.stringliteral { color: #002080 }\n" "span.charliteral { color: #008080 }\n"; static QCString g_header; static QCString g_footer; HtmlGenerator::HtmlGenerator() : OutputGenerator() { dir=Config_getString("HTML_OUTPUT"); col=0; } HtmlGenerator::~HtmlGenerator() { //printf("HtmlGenerator::~HtmlGenerator()\n"); } void HtmlGenerator::append(const OutputGenerator *g) { t << g->getContents(); col+=((HtmlGenerator *)g)->col; } void HtmlGenerator::init() { QCString dname=Config_getString("HTML_OUTPUT"); QDir d(dname); if (!d.exists() && !d.mkdir(dname)) { err("Could not create output directory %s\n",dname.data()); exit(1); } writeLogo(dname); if (!Config_getString("HTML_HEADER").isEmpty()) g_header=fileToString(Config_getString("HTML_HEADER")); if (!Config_getString("HTML_FOOTER").isEmpty()) g_footer=fileToString(Config_getString("HTML_FOOTER")); } void HtmlGenerator::writeStyleSheetFile(QFile &file) { QTextStream t(&file); t << defaultStyleSheet; } static void writeDefaultHeaderFile(QTextStream &t, const char *title, bool external) { t << "\n" "" /*"\n"*/ "idLanguageCharset() << "\">\n" ""; t << convertToHtml(title); t << "\n"; t << "\n" "\n"; } void HtmlGenerator::writeHeaderFile(QFile &file) { QTextStream t(&file); #if QT_VERSION >= 200 t.setEncoding(QTextStream::Latin1); #endif writeDefaultHeaderFile(t,"$title",FALSE); } void HtmlGenerator::writeFooterFile(QFile &file) { QTextStream t(&file); t << "
\n"; t << theTranslator->trGeneratedAt( "$datetime", "$projectname" ); t << " \n" << "\"doxygen\"\n" << " $doxygenversion"; // << " " << theTranslator->trWrittenBy() // << " Dimitri van Heesch,\n" // << " © 1997-2002" t << "
\n" << "\n" << "\n"; } void HtmlGenerator::startFile(const char *name,const char *, const char *title,bool external) { //printf("HtmlGenerator::startFile(%s)\n",name); QCString fileName=name; lastTitle=title; if (fileName.right(Doxygen::htmlFileExtension.length())!=Doxygen::htmlFileExtension) { fileName+=Doxygen::htmlFileExtension; } startPlainFile(fileName); if (Config_getBool("GENERATE_HTMLHELP")) { HtmlHelp::getInstance()->addIndexFile(fileName); } lastFile = fileName; if (g_header.isEmpty()) { writeDefaultHeaderFile(t,title,external); } else { t << substituteKeywords(g_header,convertToHtml(lastTitle)); } t << "" << endl; } void HtmlGenerator::startQuickIndexItem(const char *s,const char *l) { QCString *dest; if (s) { t << ""; } void HtmlGenerator::endQuickIndexItem() { t << "   "; } void HtmlGenerator::writeFooter(int part,bool external) { switch (part) { case 0: if (g_footer.isEmpty()) t << "
"; else t << substituteKeywords(g_footer,convertToHtml(lastTitle)); break; case 1: if (g_footer.isEmpty()) { t << endl << ""; t << endl << "\"doxygen\"" << versionString <<" "; } break; default: if (g_footer.isEmpty()) { //t << " Dimitri van Heesch,\n © 1997-2002"; t << "
\n\n\n"; } break; } } void HtmlGenerator::endFile() { endPlainFile(); } void HtmlGenerator::startProjectNumber() { t << "

"; } void HtmlGenerator::endProjectNumber() { t << "

"; } void HtmlGenerator::writeStyleInfo(int part) { if (part==0) { if (Config_getString("HTML_STYLESHEET").isEmpty()) // write default style sheet { startPlainFile("doxygen.css"); // alternative, cooler looking titles //t << "H1 { text-align: center; border-width: thin none thin none;" << endl; //t << " border-style : double; border-color : blue; padding-left : 1em; padding-right : 1em }" << endl; t << defaultStyleSheet; endPlainFile(); } else // write user defined style sheet { QCString cssname=Config_getString("HTML_STYLESHEET"); QFileInfo cssfi(cssname); if (!cssfi.exists() || !cssfi.isFile() || !cssfi.isReadable()) { err("Error: style sheet %s does not exist or is not readable!", Config_getString("HTML_STYLESHEET").data()); } else { startPlainFile(cssfi.fileName()); t << fileToString(cssname); endPlainFile(); } } } } void HtmlGenerator::startDoxyAnchor(const char *,const char *, const char *anchor, const char *name) { t << ""; } void HtmlGenerator::endDoxyAnchor(const char *,const char *) { } void HtmlGenerator::newParagraph() { t << endl << "

" << endl; } void HtmlGenerator::writeString(const char *text) { t << text; } void HtmlGenerator::writeIndexItem(const char *ref,const char *f, const char *name) { //printf("HtmlGenerator::writeIndexItem(%s,%s,%s)\n",ref,f,name); QCString *dest; t << "

  • "; if (ref || f) { if (ref) { t << ""; } else { t << ""; } docify(name); if (ref || f) { t << "" << endl; } else { t << ""; } //if (Config_getBool("GENERATE_HTMLHELP") && f) //{ // htmlHelp->addItem(name,((QCString)f)+htmlFileExtension); //} } void HtmlGenerator::writeStartAnnoItem(const char *,const char *f, const char *path,const char *name) { t << "
  • "; if (path) docify(path); t << ""; docify(name); t << " "; //if (Config_getBool("GENERATE_HTMLHELP") && f) //{ // htmlHelp->addItem(name, ((QCString)f)+htmlFileExtension); //} } void HtmlGenerator::writeObjectLink(const char *ref,const char *f, const char *anchor, const char *name) { QCString *dest; if (ref) { t << ""; docify(name); t << ""; } void HtmlGenerator::writeCodeLink(const char *ref,const char *f, const char *anchor, const char *name) { QCString *dest; if (ref) { t << ""; docify(name); t << ""; col+=strlen(name); } void HtmlGenerator::startTextLink(const char *f,const char *anchor) { t << ""; } void HtmlGenerator::endTextLink() { t << ""; } void HtmlGenerator::startHtmlLink(const char *url) { t << ""; } void HtmlGenerator::endHtmlLink() { t << ""; } void HtmlGenerator::writeMailLink(const char *url) { t << ""; docify(url); t << ""; } void HtmlGenerator::startGroupHeader() { t << "

    "; } void HtmlGenerator::endGroupHeader() { t << "

    " << endl; } void HtmlGenerator::startSection(const char *lab,const char *,SectionInfo::SectionType type) { switch(type) { case SectionInfo::Page: t << "

    "; break; case SectionInfo::Section: t << "

    "; break; case SectionInfo::Subsection: t << "

    "; break; default: ASSERT(0); break; } t << ""; } void HtmlGenerator::endSection(const char *,SectionInfo::SectionType type) { t << "" << endl; switch(type) { case SectionInfo::Page: t << "

    "; break; case SectionInfo::Section: t << ""; break; case SectionInfo::Subsection: t << ""; break; default: ASSERT(0); break; } } void HtmlGenerator::writeSectionRef(const char *ref,const char *name, const char *anchor,const char *title) { QCString *dest; //printf("writeSectionRef(%s,%s,%s,%s)\n",ref,name,anchor,title); QCString refName=name; if (refName.right(Doxygen::htmlFileExtension.length())!=Doxygen::htmlFileExtension) { refName+=Doxygen::htmlFileExtension; } t << ""; docify(title); t << ""; } void HtmlGenerator::writeSectionRefItem(const char *name,const char *lab, const char *title) { QCString refName=name; if (refName.right(Doxygen::htmlFileExtension.length())!=Doxygen::htmlFileExtension) { refName+=Doxygen::htmlFileExtension; } t << "
  • "; docify(title); t << ""; } void HtmlGenerator::docify(const char *str) { if (str) { const char *p=str; char c; while (*p) { c=*p++; switch(c) { case '<': t << "<"; break; case '>': t << ">"; break; case '&': t << "&"; break; case '\\': if (*p=='<') { t << "<"; p++; } else if (*p=='>') { t << ">"; p++; } else t << "\\"; break; default: t << c; } } } } void HtmlGenerator::codify(const char *str) { //docify(str); //static char spaces[]=" "; if (str) { const char *p=str; char c; int spacesToNextTabStop; while (*p) { c=*p++; switch(c) { case '\t': spacesToNextTabStop = Config_getInt("TAB_SIZE") - (col%Config_getInt("TAB_SIZE")); t << spaces.left(spacesToNextTabStop); col+=spacesToNextTabStop; break; case '\n': t << '\n'; col=0; break; case '\r': break; case '<': t << "<"; col++; break; case '>': t << ">"; col++; break; case '&': t << "&"; col++; break; case '\\': if (*p=='<') { t << "<"; p++; } else if (*p=='>') { t << ">"; p++; } else t << "\\"; col++; break; default: t << c; col++; break; } } } } void HtmlGenerator::writeChar(char c) { char cs[2]; cs[0]=c; cs[1]=0; docify(cs); } void HtmlGenerator::startClassDiagram() { t << "

    "; } void HtmlGenerator::endClassDiagram(ClassDiagram &d, const char *fileName,const char *name) { t << "\n

    \"\"
    " << endl << "" << endl; d.writeImage(t,dir,fileName); } //void HtmlGenerator::startColorFont(uchar red,uchar green,uchar blue) //{ // QCString colorString; // colorString.sprintf("%02x%02x%02x",red,green,blue); // t << ""; //} // //void HtmlGenerator::endColorFont() //{ // t << ""; //} void HtmlGenerator::writeFormula(const char *n,const char *text) { if (text && text[0]=='\\') t << "

    " << endl; t << "" << endl; if (text && text[0]=='\\') t << "

    " << endl; } void HtmlGenerator::startMemberList() { DBG_HTML(t << "" << endl) if (Config_getBool("HTML_ALIGN_MEMBERS")) { } else { t << "

      " << endl; } } void HtmlGenerator::endMemberList() { DBG_HTML(t << "" << endl) if (Config_getBool("HTML_ALIGN_MEMBERS")) { } else { t << "
    " << endl; } } // annonymous type: // 0 = single column right aligned // 1 = double column left aligned // 2 = single column left aligned void HtmlGenerator::startMemberItem(int annoType) { DBG_HTML(t << "" << endl) if (Config_getBool("HTML_ALIGN_MEMBERS")) { t << ""; switch(annoType) { case 0: t << ""; break; case 1: t << ""; break; default: t << ""; break; } } else { t << "
  • "; } } void HtmlGenerator::endMemberItem(bool) { //DBG_HTML(t << "" << endl) if (Config_getBool("HTML_ALIGN_MEMBERS")) { t << ""; } t << endl; } void HtmlGenerator::insertMemberAlign() { DBG_HTML(t << "" << endl) if (Config_getBool("HTML_ALIGN_MEMBERS")) { t << " "; } } void HtmlGenerator::startMemberDescription() { DBG_HTML(t << "" << endl) if (Config_getBool("HTML_ALIGN_MEMBERS")) { t << " "; } else { t << "
    "; } } void HtmlGenerator::endMemberDescription() { DBG_HTML(t << "" << endl) if (Config_getBool("HTML_ALIGN_MEMBERS")) { t << "

    " << endl; } else { t << "

    "; } } void HtmlGenerator::startMemberSections() { DBG_HTML(t << "" << endl) if (Config_getBool("HTML_ALIGN_MEMBERS")) { t << "" << endl; // HTML is not recursively decomposable, sorry t << "" << endl; } } void HtmlGenerator::endMemberSections() { DBG_HTML(t << "" << endl) if (Config_getBool("HTML_ALIGN_MEMBERS")) { t << "
    " << endl; } } void HtmlGenerator::startMemberHeader() { DBG_HTML(t << "" << endl) if (Config_getBool("HTML_ALIGN_MEMBERS")) { t << "

    "; } else { startGroupHeader(); } } void HtmlGenerator::endMemberHeader() { DBG_HTML(t << "" << endl) if (Config_getBool("HTML_ALIGN_MEMBERS")) { t << "

    " << endl; } else { endGroupHeader(); } } void HtmlGenerator::startMemberSubtitle() { DBG_HTML(t << "" << endl) if (Config_getBool("HTML_ALIGN_MEMBERS")) t << ""; } void HtmlGenerator::endMemberSubtitle() { DBG_HTML(t << "" << endl) if (Config_getBool("HTML_ALIGN_MEMBERS")) t << "

    " << endl; } void HtmlGenerator::startIndexList() { t << "" << endl; } void HtmlGenerator::endIndexList() { t << "
    " << endl; } void HtmlGenerator::startIndexKey() { // inserted 'class = ...', 02 jan 2002, jh t << " "; } void HtmlGenerator::endIndexKey() { t << ""; } void HtmlGenerator::startIndexValue(bool) { // inserted 'class = ...', 02 jan 2002, jh t << ""; } void HtmlGenerator::endIndexValue(const char *,bool) { t << "" << endl; } void HtmlGenerator::startAlphabeticalIndexList() { t << "" << endl; } void HtmlGenerator::endAlphabeticalIndexList() { t << "
    " << endl; } void HtmlGenerator::writeIndexHeading(const char *s) { t << "
      " << s << "  
    "; } void HtmlGenerator::startImage(const char *name,const char *,bool hasCaption) { QCString baseName=name; int i; if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1) { baseName=baseName.right(baseName.length()-i-1); } t << "
    " << endl; t << "\""" << endl; if (hasCaption) { t << "

    "; } } void HtmlGenerator::endImage(bool hasCaption) { if (hasCaption) { t << "

    " << endl; } t << "
    " << endl; } void HtmlGenerator::startDotFile(const char *name,bool hasCaption) { QCString baseName=name; int i; if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1) { baseName=baseName.right(baseName.length()-i-1); } QCString outDir = Config_getString("HTML_OUTPUT"); writeDotGraphFromFile(name,outDir,baseName,BITMAP); t << "
    " << endl; t << "\""" << endl; if (hasCaption) { t << "

    "; } } void HtmlGenerator::endDotFile(bool hasCaption) { if (hasCaption) { t << "

    " << endl; } t << "
    " << endl; } void HtmlGenerator::startMemberDoc(const char *,const char *,const char *,const char *) { DBG_HTML(t << "" << endl;) t << "

    " << endl; t << "" << endl; t << " " << endl; t << " " << endl; t << " " << endl; t << "
    " << endl; t << " " << endl; } void HtmlGenerator::startMemberDocPrefixItem() { DBG_HTML(t << "" << endl;) t << " " << endl; t << " " << endl; t << " " << endl; } void HtmlGenerator::startMemberDocName() { DBG_HTML(t << "" << endl;) t << " " << endl; t << " " << endl; } void HtmlGenerator::startParameterList() { DBG_HTML(t << "" << endl;) t << " " << endl; } void HtmlGenerator::startParameterType(bool first) { if (first) { DBG_HTML(t << "" << endl;) t << " " << endl; t << " " << endl; t << " " << endl; t << " " << endl; } void HtmlGenerator::startParameterName(bool oneArgOnly) { DBG_HTML(t << "" << endl;) t << " " << endl; t << " " << endl; t << " " << endl; t << " " << endl; t << " " << endl; t << " " << endl; t << " " << endl; t << " " << endl; t << " " << endl; } } void HtmlGenerator::endParameterList() { DBG_HTML(t << "" << endl;) t << "" << endl; t << " " << endl; } void HtmlGenerator::endMemberDoc() { DBG_HTML(t << "" << endl;) t << endl; t << "
    " << endl; } void HtmlGenerator::endMemberDocPrefixItem() { DBG_HTML(t << "" << endl;) t << "
    "; } void HtmlGenerator::endMemberDocName() { DBG_HTML(t << "" << endl;) t << ""; } else { DBG_HTML(t << "" << endl;) t << "
    "; } } void HtmlGenerator::endParameterType() { DBG_HTML(t << "" << endl;) t << "  "; } void HtmlGenerator::endParameterName(bool last,bool emptyList) { DBG_HTML(t << "" << endl;) if (last) { if (emptyList) { t << " "; } else { t << "
    "; } } else { t << "
    " << endl; t << "
    " << endl; } void HtmlGenerator::startDotGraph() { } void HtmlGenerator::endDotGraph(DotClassGraph &g) { g.writeGraph(t,BITMAP,Config_getString("HTML_OUTPUT")); } void HtmlGenerator::startInclDepGraph() { } void HtmlGenerator::endInclDepGraph(DotInclDepGraph &g) { g.writeGraph(t,BITMAP,Config_getString("HTML_OUTPUT")); } void HtmlGenerator::writeGraphicalHierarchy(DotGfxHierarchyTable &g) { g.writeGraph(t,Config_getString("HTML_OUTPUT")); } void HtmlGenerator::startMemberGroupHeader(bool) { t << "

    "; } void HtmlGenerator::endMemberGroupHeader() { t << "
    " << endl; } void HtmlGenerator::startMemberGroupDocs() { t << "
    "; } void HtmlGenerator::endMemberGroupDocs() { t << "

    " << endl; } void HtmlGenerator::startMemberGroup() { } void HtmlGenerator::endMemberGroup(bool) { } void HtmlGenerator::startIndent() { // I really wanted to use CSS here to provide an indented section, but // alas, Netscape is buggy enough to sometimes "forget" to end the // indent cause a staircase effect where the indent continuously increases. // It's back to abusing tables :-( //t << "
    " << endl; t << "\n" " \n" " \n" " \n" " \n" "
    \n" "  \n" " \n"; } void HtmlGenerator::endIndent() { t << "
    \n"; //t << "
    " << endl; } void HtmlGenerator::addIndexItem(const char *,const char *) { } void HtmlGenerator::writeNonBreakableSpace(int n) { int i; for (i=0;i
    "; if (file) { writeObjectLink(0,file,anchor,title); } else { docify(title); } t << "
    "; } void HtmlGenerator::endSimpleSect() { t << ""; } void HtmlGenerator::startParamList(ParamListTypes, const char *title) { t << "
    "; docify(title); t << "
    "; } void HtmlGenerator::endParamList() { t << "
    "; } void HtmlGenerator::startSectionRefList() { t << "" << endl; t << "
      " << endl; } void HtmlGenerator::endSectionRefList() { t << "
    " << endl; t << "
    " << endl; } void HtmlGenerator::printDoc(DocNode *n) { #ifdef ENABLE_NEW_PARSER HtmlDocVisitor *visitor = new HtmlDocVisitor(t,*this); n->accept(visitor); delete visitor; #else n=n; #endif }