docbookgen.cpp 59.7 KB
Newer Older
1 2 3 4
/******************************************************************************
*
* 
*
Dimitri van Heesch's avatar
Dimitri van Heesch committed
5
* Copyright (C) 1997-2014 by Dimitri van Heesch.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
*
* 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 <stdlib.h>

#include <qdir.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qintdict.h>
#include "docbookgen.h"
#include "doxygen.h"
#include "message.h"
#include "config.h"
#include "classlist.h"
#include "util.h"
#include "defargs.h"
#include "outputgen.h"
#include "dot.h"
#include "pagedef.h"
#include "filename.h"
#include "version.h"
#include "docbookvisitor.h"
#include "docparser.h"
#include "language.h"
#include "parserintf.h"
#include "arguments.h"
#include "memberlist.h"
#include "groupdef.h"
#include "memberdef.h"
#include "namespacedef.h"
#include "membername.h"
#include "membergroup.h"
#include "dirdef.h"
#include "section.h"

// no debug info
#define Docbook_DB(x) do {} while(0)
// debug to stdout
//#define Docbook_DB(x) printf x
// debug inside output
//#define Docbook_DB(x) QCString __t;__t.sprintf x;m_t << __t

//------------------

class DocbookSectionMapper : public QIntDict<char>
{
  public:
    DocbookSectionMapper() : QIntDict<char>(47)
  {
    insert(MemberListType_pubTypes,"public-type");
    insert(MemberListType_pubMethods,"public-func");
    insert(MemberListType_pubAttribs,"public-attrib");
    insert(MemberListType_pubSlots,"public-slot");
    insert(MemberListType_signals,"signal");
    insert(MemberListType_dcopMethods,"dcop-func");
    insert(MemberListType_properties,"property");
    insert(MemberListType_events,"event");
    insert(MemberListType_pubStaticMethods,"public-static-func");
    insert(MemberListType_pubStaticAttribs,"public-static-attrib");
    insert(MemberListType_proTypes,"protected-type");
    insert(MemberListType_proMethods,"protected-func");
    insert(MemberListType_proAttribs,"protected-attrib");
    insert(MemberListType_proSlots,"protected-slot");
    insert(MemberListType_proStaticMethods,"protected-static-func");
    insert(MemberListType_proStaticAttribs,"protected-static-attrib");
    insert(MemberListType_pacTypes,"package-type");
    insert(MemberListType_pacMethods,"package-func");
    insert(MemberListType_pacAttribs,"package-attrib");
    insert(MemberListType_pacStaticMethods,"package-static-func");
    insert(MemberListType_pacStaticAttribs,"package-static-attrib");
    insert(MemberListType_priTypes,"private-type");
    insert(MemberListType_priMethods,"private-func");
    insert(MemberListType_priAttribs,"private-attrib");
    insert(MemberListType_priSlots,"private-slot");
    insert(MemberListType_priStaticMethods,"private-static-func");
    insert(MemberListType_priStaticAttribs,"private-static-attrib");
    insert(MemberListType_friends,"friend");
    insert(MemberListType_related,"related");
    insert(MemberListType_decDefineMembers,"define");
    insert(MemberListType_decProtoMembers,"prototype");
    insert(MemberListType_decTypedefMembers,"typedef");
    insert(MemberListType_decEnumMembers,"enum");
    insert(MemberListType_decFuncMembers,"func");
    insert(MemberListType_decVarMembers,"var");
  }
};

static DocbookSectionMapper g_docbookSectionMapper;


inline void writeDocbookString(FTextStream &t,const char *s)
{
  t << convertToXML(s);
}

inline void writeDocbookCodeString(FTextStream &t,const char *s, int &col)
{
  char c;
  while ((c=*s++))
  {
    switch(c)
    {
      case '\t':
        {
          static int tabSize = Config_getInt("TAB_SIZE");
          int spacesToNextTabStop = tabSize - (col%tabSize);
          col+=spacesToNextTabStop;
          while (spacesToNextTabStop--) t << "&#32;";
          break;
        }
      case ' ':  t << "&#32;"; col++;  break;
      case '<':  t << "&lt;"; col++;   break;
      case '>':  t << "&gt;"; col++;   break;
      case '&':  t << "&amp;"; col++;  break;
      case '\'': t << "&apos;"; col++; break;
      case '"':  t << "&quot;"; col++; break;
      default:   t << c; col++;        break;
    }
  }
}

static void writeDocbookHeaderMainpage(FTextStream &t)
{
  t << "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" << endl;;
  t << "<chapter xmlns=\"http://docbook.org/ns/docbook\" version=\"5.0\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">" << endl;
}

static void writeDocbookHeader_ID(FTextStream &t, QCString id)
{
  t << "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" << endl;;
  t << "<section xmlns=\"http://docbook.org/ns/docbook\" version=\"5.0\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xml:id=\"" << id << "\">" << endl;
}

void writeDocbookLink(FTextStream &t,const char * /*extRef*/,const char *compoundId,
    const char *anchorId,const char * text,const char * /*tooltip*/)
{
  t << "<link linkend=\"" << compoundId;
  if (anchorId) t << "_1" << anchorId;
  t << "\"";
  t << ">";
  writeDocbookString(t,text);
  t << "</link>";
}

class TextGeneratorDocbookImpl : public TextGeneratorIntf
{
  public:
    TextGeneratorDocbookImpl(FTextStream &t): m_t(t) {}
    void writeString(const char *s,bool /*keepSpaces*/) const
    {
      writeDocbookString(m_t,s);
    }
    void writeBreak(int) const {}
    void writeLink(const char *extRef,const char *file,
        const char *anchor,const char *text
        ) const
    {
      writeDocbookLink(m_t,extRef,file,anchor,text,0);
    }
  private:
    FTextStream &m_t;
};

class DocbookCodeGenerator : public CodeOutputInterface
{
  public:
    DocbookCodeGenerator(FTextStream &t) : m_t(t), m_lineNumber(-1),
182
    m_insideCodeLine(FALSE), m_insideSpecialHL(FALSE) {}
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
    virtual ~DocbookCodeGenerator() {}

    void codify(const char *text)
    {
      Docbook_DB(("(codify \"%s\")\n",text));
      writeDocbookCodeString(m_t,text,col);
    }
    void writeCodeLink(const char *ref,const char *file,
        const char *anchor,const char *name,
        const char *tooltip)
    {
      Docbook_DB(("(writeCodeLink)\n"));
      writeDocbookLink(m_t,ref,file,anchor,name,tooltip);
      col+=strlen(name);
    }
198 199 200 201 202 203
    void writeTooltip(const char *, const DocLinkInfo &, const char *,
                      const char *, const SourceLinkInfo &, const SourceLinkInfo &
                     )
    {
      Docbook_DB(("(writeToolTip)\n"));
    }
204 205 206 207 208 209 210 211 212
    void startCodeLine(bool)
    {
      Docbook_DB(("(startCodeLine)\n"));
      if (m_lineNumber!=-1)
      {
        if (!m_refId.isEmpty())
        {
          m_t << "<link linkend=\"" << m_refId << "\">";
        }
213
        m_t << m_lineNumber << " ";
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
        if (!m_refId.isEmpty())
        {
          m_t << "</link>";
        }
      }
      m_insideCodeLine=TRUE;
      col=0;
    }
    void endCodeLine()
    {
      m_t << endl;
      Docbook_DB(("(endCodeLine)\n"));
      m_lineNumber = -1;
      m_refId.resize(0);
      m_external.resize(0);
      m_insideCodeLine=FALSE;
    }
231
    void startFontClass(const char *colorClass)
232 233
    {
      Docbook_DB(("(startFontClass)\n"));
234
      m_t << "<emphasis class=\"" << colorClass << "\">";
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
      m_insideSpecialHL=TRUE;
    }
    void endFontClass()
    {
      Docbook_DB(("(endFontClass)\n"));
      m_t << "</emphasis>"; // non DocBook
      m_insideSpecialHL=FALSE;
    }
    void writeCodeAnchor(const char *)
    {
      Docbook_DB(("(writeCodeAnchor)\n"));
    }
    void writeLineNumber(const char *extRef,const char *compId,
        const char *anchorId,int l)
    {
      Docbook_DB(("(writeLineNumber)\n"));
      // we remember the information provided here to use it
      // at the <codeline> start tag.
      m_lineNumber = l;
      if (compId)
      {
        m_refId=compId;
        if (anchorId) m_refId+=(QCString)"_1"+anchorId;
        m_isMemberRef = anchorId!=0;
        if (extRef) m_external=extRef;
      }
    }
    void setCurrentDoc(Definition *,const char *,bool)
    {
    }
    void addWord(const char *,bool)
    {
    }
    void finish()
    {
      if (m_insideCodeLine) endCodeLine();
    }

  private:
    FTextStream &m_t;
    QCString m_refId;
    QCString m_external;
    int m_lineNumber;
    bool m_isMemberRef;
    int col;
    bool m_insideCodeLine;
    bool m_insideSpecialHL;
};


static void writeTemplateArgumentList(ArgumentList *al,
    FTextStream &t,
    Definition *scope,
    FileDef *fileScope,
    int indent)
{
  QCString indentStr;
  indentStr.fill(' ',indent);
  if (al)
  {
    t << indentStr << "<templateparamlist>" << endl;
    ArgumentListIterator ali(*al);
    Argument *a;
    for (ali.toFirst();(a=ali.current());++ali)
    {
      t << indentStr << "  <param>" << endl;
      if (!a->type.isEmpty())
      {
        t << indentStr <<  "    <type>";
        linkifyText(TextGeneratorDocbookImpl(t),scope,fileScope,0,a->type);
        t << "</type>" << endl;
      }
      if (!a->name.isEmpty())
      {
        t << indentStr <<  "    <declname>" << a->name << "</declname>" << endl;
        t << indentStr <<  "    <defname>" << a->name << "</defname>" << endl;
      }
      if (!a->defval.isEmpty())
      {
        t << indentStr << "    <defval>";
        linkifyText(TextGeneratorDocbookImpl(t),scope,fileScope,0,a->defval);
        t << "</defval>" << endl;
      }
      t << indentStr << "  </param>" << endl;
    }
    t << indentStr << "</templateparamlist>" << endl;
  }
}

static void writeTemplateList(ClassDef *cd,FTextStream &t)
{
  writeTemplateArgumentList(cd->templateArguments(),t,cd,0,4);
}

static void writeDocbookDocBlock(FTextStream &t,
    const QCString &fileName,
    int lineNr,
    Definition *scope,
    MemberDef * md,
    const QCString &text)
{
  QCString stext = text.stripWhiteSpace();
  if (stext.isEmpty()) return;
  // convert the documentation string into an abstract syntax tree
339
  DocNode *root = validatingParseDoc(fileName,lineNr,scope,md,text,FALSE,FALSE);
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
  // create a code generator
  DocbookCodeGenerator *docbookCodeGen = new DocbookCodeGenerator(t);
  // create a parse tree visitor for Docbook
  DocbookDocVisitor *visitor = new DocbookDocVisitor(t,*docbookCodeGen);
  // visit all nodes
  root->accept(visitor);
  // clean up
  delete visitor;
  delete docbookCodeGen;
  delete root;
}

void writeDocbookCodeBlock(FTextStream &t,FileDef *fd)
{
  ParserInterface *pIntf=Doxygen::parserManager->getParser(fd->getDefFileExtension());
355
  SrcLangExt langExt = getLanguageFromFileName(fd->getDefFileExtension());
356 357 358 359 360
  pIntf->resetCodeParserState();
  DocbookCodeGenerator *docbookGen = new DocbookCodeGenerator(t);
  pIntf->parseCode(*docbookGen,  // codeOutIntf
      0,           // scopeName
      fileToString(fd->absFilePath(),Config_getBool("FILTER_SOURCE_FILES")),
361
      langExt,     // lang
362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422
      FALSE,       // isExampleBlock
      0,           // exampleName
      fd,          // fileDef
      -1,          // startLine
      -1,          // endLine
      FALSE,       // inlineFragement
      0,           // memberDef
      TRUE         // showLineNumbers
      );
  docbookGen->finish();
  delete docbookGen;
}

static QCString classOutputFileBase(ClassDef *cd)
{
  //static bool inlineGroupedClasses = Config_getBool("INLINE_GROUPED_CLASSES");
  //if (inlineGroupedClasses && cd->partOfGroups()!=0)
  return cd->getOutputFileBase();
  //else
  //  return cd->getOutputFileBase();
}

static QCString memberOutputFileBase(MemberDef *md)
{
  //static bool inlineGroupedClasses = Config_getBool("INLINE_GROUPED_CLASSES");
  //if (inlineGroupedClasses && md->getClassDef() && md->getClassDef()->partOfGroups()!=0)
  //  return md->getClassDef()->getDocbookOutputFileBase();
  //else
  //  return md->getOutputFileBase();
  return md->getOutputFileBase();
}


static void generateDocbookForMember(MemberDef *md,FTextStream &t,Definition *def, bool detailed=0)
{

  // + declaration/definition arg lists
  // + reimplements
  // + reimplementedBy
  // + exceptions
  // + const/volatile specifiers
  // - examples
  // + source definition
  // + source references
  // + source referenced by
  // - body code
  // + template arguments
  //     (templateArguments(), definitionTemplateParameterLists())
  // - call graph

  // enum values are written as part of the enum
  if (md->memberType()==MemberType_EnumValue) return;
  if (md->isHidden()) return;
  //if (md->name().at(0)=='@') return; // anonymous member

  // group members are only visible in their group
  //if (def->definitionType()!=Definition::TypeGroup && md->getGroupDef()) return;
  QCString memType;
  switch (md->memberType())
  {
    case MemberType_Define:      memType="define";    break;
423
    case MemberType_Function:    memType="function";  break;
424 425 426
    case MemberType_Variable:    memType="variable";  break;
    case MemberType_Typedef:     memType="typedef";   break;
    case MemberType_Enumeration: memType="enum";      break;
427 428 429 430 431 432 433 434 435
    case MemberType_EnumValue:   ASSERT(0);           break;
    case MemberType_Signal:      memType="signal";    break;
    case MemberType_Slot:        memType="slot";      break;
    case MemberType_Friend:      memType="friend";    break;
    case MemberType_DCOP:        memType="dcop";      break;
    case MemberType_Property:    memType="property";  break;
    case MemberType_Event:       memType="event";     break;
    case MemberType_Interface:   memType="interface"; break;
    case MemberType_Service:     memType="service";   break;
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
  }
  QCString scopeName;
  if (md->getClassDef())
  {
    scopeName=md->getClassDef()->name();
  }
  else if (md->getNamespaceDef())
  {
    scopeName=md->getNamespaceDef()->name();
  }
  if (detailed==0) 
  {
    t << "            <para>" << endl;
    t << "                <itemizedlist>" << endl;
    t << "                    <listitem>" << endl;
    //enum
    bool closePara=TRUE;
    if (md->memberType()==MemberType_Enumeration) 
    {
455
      MemberList *enumFields = md->enumFieldList();
456
      t << "                            <para><literallayout>" << memType << " <link linkend=\"";
457 458 459 460 461 462 463 464 465 466 467 468 469
      if (md->getGroupDef() && def->definitionType()==Definition::TypeGroup)
      {
        t << md->getGroupDef()->getOutputFileBase();
      }
      else
      {
        t << memberOutputFileBase(md);
      }
      t << "_1" << md->anchor() << "\">" << convertToXML(md->name()) << "</link>";
      if (enumFields!=0) 
      {
        MemberListIterator emli(*enumFields);
        MemberDef *emd;
470
        t << " {" << endl;
471 472 473 474 475
        int cnt=0;
        for (emli.toFirst();(emd=emli.current());++emli) 
        {
          if (cnt!=0) 
          {
476
            t << "," << endl;
477 478 479 480 481 482 483 484 485 486
          }
          t << "<link linkend=\"" << memberOutputFileBase(emd) << "_1" << emd->anchor() << "\">";
          writeDocbookString(t,emd->name());
          t << "</link>";
          if (!emd->initializer().isEmpty()) 
          {
            writeDocbookString(t,emd->initializer());
          }
          cnt++;
        }
487 488
        t << endl << "}";
        t << "</literallayout>" << endl;
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574
      }
    }
    else if (md->memberType()==MemberType_Define) 
    {
      t << "                            <para>" << "#" << memType << " <link linkend=\"";
      if (md->getGroupDef() && def->definitionType()==Definition::TypeGroup)
      {
        t << md->getGroupDef()->getOutputFileBase();
      }
      else
      {
        t << memberOutputFileBase(md);
      }
      t << "_1" << md->anchor() << "\">" << convertToXML(md->name()) << "</link>";
      if (!md->initializer().isEmpty() && md->initializer().length()<2000) 
      {
        t << " ";
        linkifyText(TextGeneratorDocbookImpl(t),def,md->getBodyDef(),md,md->initializer());
      }
      if (md->briefDescription()) 
      {
        t << "<para><emphasis>";
        writeDocbookString(t,md->briefDescription());
        t << "</emphasis></para>" << endl;
      }
    }
    else if (md->memberType()==MemberType_Variable) 
    {
      if (md->getClassDef()) 
      {
        t << "                        <para>" << convertToXML(md->declaration());
        if (md->briefDescription()) 
        {
          t << "<para><emphasis>";
          writeDocbookString(t,md->briefDescription());
          t << "</emphasis></para>";
        }
      } 
      else 
      {
        t << "                        <para>";
        linkifyText(TextGeneratorDocbookImpl(t),def,md->getBodyDef(),md,md->typeString());
        t << " <link linkend=\"";
        if (md->getGroupDef() && def->definitionType()==Definition::TypeGroup)
        {
          t << md->getGroupDef()->getOutputFileBase();
        }
        else
        {
          t << memberOutputFileBase(md);
        }
        t << "_1" << md->anchor() << "\">" << convertToXML(md->name()) << "</link>";
      }
    }
    else if (md->memberType()==MemberType_Typedef) 
    {
      t << "                            <para>" << memType;
      t << " ";
      linkifyText(TextGeneratorDocbookImpl(t),def,md->getBodyDef(),md,md->typeString());
      t << " ";
      t << " <link linkend=\"";
      if (md->getGroupDef() && def->definitionType()==Definition::TypeGroup)
      {
        t << md->getGroupDef()->getOutputFileBase();
      }
      else
      {
        t << memberOutputFileBase(md);
      }
      t << "_1" << md->anchor() << "\">" << convertToXML(md->name()) << "</link>";
    }
    else if (md->memberType()==MemberType_Function) 
    {
      t << "                        <para>";
      linkifyText(TextGeneratorDocbookImpl(t),def,md->getBodyDef(),md,md->typeString());
      t << " <link linkend=\"";
      if (md->getGroupDef() && def->definitionType()==Definition::TypeGroup)
      {
        t << md->getGroupDef()->getOutputFileBase();
      }
      else
      {
        t << memberOutputFileBase(md);
      }
      t << "_1" << md->anchor() << "\">" << convertToXML(md->name()) << "</link>";
      t << " (" << endl;
575 576 577
      ArgumentList *declAl = md->declArgumentList();
      ArgumentList *defAl = md->argumentList();
      if (declAl && declAl->count()>0)
578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610
      {
        ArgumentListIterator declAli(*declAl);
        ArgumentListIterator defAli(*defAl);
        Argument *a;
        int cnt=0;
        for (declAli.toFirst();(a=declAli.current());++declAli)
        {
          if (cnt!=0) 
          {
            t << ", ";
          }
          if (!a->type.isEmpty())
          {
            linkifyText(TextGeneratorDocbookImpl(t),def,md->getBodyDef(),md,a->type);
          }
          t << " ";
          if (!a->name.isEmpty())
          {
            writeDocbookString(t,a->name);
          }
          cnt++;
        }
      }
      t << ")";
    }
    else
    {
      closePara = FALSE;
    }
    if (closePara) t << "</para>" << endl;
    t << "                    </listitem>" << endl;
    t << "                </itemizedlist>" << endl;
    t << "            </para>" << endl;
611 612
  }
  else
613
  {
614
    if (md->memberType()==MemberType_Enumeration)
615
    {
616
      MemberList *enumFields = md->enumFieldList();
617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655
      t << "            <section xml:id=\"";
      if (md->getGroupDef() && def->definitionType()==Definition::TypeGroup)
      {
        t << md->getGroupDef()->getOutputFileBase();
      }
      else
      {
        t << memberOutputFileBase(md);
      }
      t << "_1" << md->anchor() << "\">" << endl;
      t << "               <title>" << memType << " " << convertToXML(md->name()) << " " << "</title>" << endl;
      t << "               ";
      writeDocbookDocBlock(t,md->docFile(),md->docLine(),md->getOuterScope(),md,md->documentation());
      t << endl;
      if (enumFields!=0) 
      {
        MemberListIterator emli(*enumFields);
        MemberDef *emd;
        t << "               <formalpara>" << endl;
        t << "                    <title>Enumerator:</title>" << endl;
        t << "                    <variablelist>" << endl;
        for (emli.toFirst();(emd=emli.current());++emli) 
        {
          t << "                        <varlistentry xml:id=\"";
          t << memberOutputFileBase(emd) << "_1" << emd->anchor() << "\">" << endl;
          t << "                            <term>";
          writeDocbookString(t,emd->name());
          t << "</term>" << endl;
          t << "                            <listitem>" << endl;
          t << "                                <para>";
          writeDocbookString(t,emd->briefDescription());
          t << "</para>" << endl;
          t << "                            </listitem>" << endl;
          t << "                        </varlistentry>" << endl;
        }
        t << "                     </variablelist>" << endl;
        t << "                </formalpara>" << endl;
        t << "                <para>";
        t << "Definition at line " << md->getDefLine() << " of file " << stripPath(md->getDefFileName()) << endl;
656
        t << "                    <computeroutput><literallayout>" << endl;
657 658 659 660 661 662 663 664 665 666 667
        t << "{" << endl;
        for (emli.toFirst();(emd=emli.current());++emli) 
        {
          writeDocbookString(t,emd->name());
          if (!emd->initializer().isEmpty()) 
          {
            writeDocbookString(t,emd->initializer());
          }
          t << ", " << endl;
        }
        t << "}" << convertToXML(md->name()) << ";" << endl;
668
        t << "                    </literallayout></computeroutput>" << endl;
669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128
        t << "                </para>" << endl;
        t << "            </section>" << endl;
      }
    }
    else if (md->memberType()==MemberType_Typedef) 
    {
      t << "            <section xml:id=\"";
      if (md->getGroupDef() && def->definitionType()==Definition::TypeGroup)
      {
        t << md->getGroupDef()->getOutputFileBase();
      }
      else
      {
        t << memberOutputFileBase(md);
      }
      t << "_1" << md->anchor() << "\">" << endl;
      t << "                <title>" << convertToXML(md->definition()) << "</title>";
      t << " <emphasis>";
      writeDocbookString(t,md->briefDescription());
      t << "</emphasis>" << endl;
      t << "                ";
      writeDocbookDocBlock(t,md->docFile(),md->docLine(),md->getOuterScope(),md,md->documentation());
      t << endl;
      t << "            </section>" << endl;
    }
    else if (md->memberType()==MemberType_Function) 
    {
      t << "            <section xml:id=\"";
      if (md->getGroupDef() && def->definitionType()==Definition::TypeGroup)
      {
        t << md->getGroupDef()->getOutputFileBase();
      }
      else
      {
        t << memberOutputFileBase(md);
      }
      t << "_1" << md->anchor() << "\">" << endl;
      t << "                <title>" << convertToXML(md->definition()) << " " << convertToXML(md->argsString()) << "</title>";
      t << " <emphasis>";
      writeDocbookString(t,md->briefDescription());
      t << "</emphasis>" << endl;
      t << "                ";
      writeDocbookDocBlock(t,md->docFile(),md->docLine(),md->getOuterScope(),md,md->documentation());
      t << endl;
      t << "            </section>" << endl;
    }
    else if (md->memberType()==MemberType_Define) 
    {
      if (md->documentation()) 
      {
        t << "            <section xml:id=\"";
        if (md->getGroupDef() && def->definitionType()==Definition::TypeGroup)
        {
          t << md->getGroupDef()->getOutputFileBase();
        }
        else
        {
          t << memberOutputFileBase(md);
        }
        t << "_1" << md->anchor() << "\">" << endl;
        t << "                <title>" << convertToXML(md->definition()) << "</title>";
        t << "                ";
        writeDocbookDocBlock(t,md->docFile(),md->docLine(),md->getOuterScope(),md,md->documentation());
        t << endl;
        t << "                <para>Definition at line " << md->getDefLine() << " of file " << stripPath(md->getDefFileName()) << "</para>" << endl;
        t << "                <para>The Documentation for this define was generated from the following file: </para>" << endl;
        t << "                <para><itemizedlist><listitem><para>" << stripPath(md->getDefFileName()) << "</para></listitem></itemizedlist></para>" << endl;
        t << "            </section>" << endl;
      }
    }
    else if (md->memberType()==MemberType_Variable) 
    {
      if (md->getClassDef()) 
      {
        if (md->documentation()) 
        {
          t << "            <simplesect>" << endl;
          t << "                <title>" << convertToXML(md->definition()) << "</title>";
          t << "                ";
          writeDocbookDocBlock(t,md->docFile(),md->docLine(),md->getOuterScope(),md,md->documentation());
          t << endl;
          t << "                <para>Definition at line " << md->getDefLine() << " of file " << stripPath(md->getDefFileName()) << "</para>" << endl;
          t << "                <para>The Documentation for this struct was generated from the following file: </para>" << endl;
          t << "                <para><itemizedlist><listitem><para>" << stripPath(md->getDefFileName()) << "</para></listitem></itemizedlist></para>" << endl;
          t << "            </simplesect>" << endl;
        }
      }
      else 
      {
        t << "            <section xml:id=\"";
        if (md->getGroupDef() && def->definitionType()==Definition::TypeGroup)
        {
          t << md->getGroupDef()->getOutputFileBase();
        }
        else
        {
          t << memberOutputFileBase(md);
        }
        t << "_1" << md->anchor() << "\">" << endl;
        t << "                <title>" << convertToXML(md->definition()) << "</title>";
        t << " <emphasis>";
        writeDocbookString(t,md->briefDescription());
        t << "</emphasis>" << endl;
        t << "                ";
        writeDocbookDocBlock(t,md->docFile(),md->docLine(),md->getOuterScope(),md,md->documentation());
        t << endl;
        t << "            </section>" << endl;
      }
    }
  }
}

static void generateDocbookSection(Definition *d,FTextStream &t,MemberList *ml,const char *kind,
    bool detailed=0, const char *header=0,const char *documentation=0)
{
  if (ml==0) return;
  MemberListIterator mli(*ml);
  MemberDef *md;
  int count=0;
  int doc_count=0;
  QCString compkind = kind;
  QCString title, desctitle;

  for (mli.toFirst();(md=mli.current());++mli) 
  {
    // namespace members are also inserted in the file scope, but
    // to prevent this duplication in the Docbook output, we filter those here.
    if (d->definitionType()!=Definition::TypeFile || md->getNamespaceDef()==0) 
    {
      count++;
    }
  }

  switch (ml->listType())
  {
    case MemberListType_decDefineMembers:  title="Defines";             desctitle="Define Documentation";              break;
    case MemberListType_decTypedefMembers: title="Typedefs";            desctitle="Typedef Documentation";             break;
    case MemberListType_decEnumMembers:    title="Enumerations";        desctitle="Enumeration Type documentation";    break;
    case MemberListType_decFuncMembers:    title="Functions";           desctitle="Function Documentation";            break;
    case MemberListType_decVarMembers:     title="Variables";           desctitle="Variable Documentation";            break;
    case MemberListType_pubAttribs:        title="Public Attributes";   desctitle="Member Documentation";              break;
    case MemberListType_priAttribs:        title="Private Attributes";  desctitle="Member Documentation";              break;
    case MemberListType_proAttribs:        title="Protected Attributes";desctitle="Member Documentation";              break;
    default:                               title="";                    desctitle="";                                  break;
  }

  if (count==0) return; // empty list

  for (mli.toFirst();(md=mli.current());++mli) 
  {
    if (md->documentation()) 
    {
      doc_count++;
    }
  }

  if (detailed) 
  {
    if (desctitle) 
    {
      if (desctitle=="Member Documentation") 
      {
        if (doc_count > 0) 
        {
          t << "        <simplesect>" << endl;
          t << "            <title>" << desctitle << "</title>" << endl;
        }
      } 
      else if (desctitle=="Define Documentation") 
      {
        if (doc_count > 0) 
        {
          t << "        <section>" << endl;
          t << "            <title>" << desctitle << "</title>" << endl;
        }
      } 
      else 
      {
        t << "        <section>" << endl;
        t << "            <title>" << desctitle << "</title>" << endl;
      }
    }
  } else 
  {
    t << "        <simplesect>" << endl;
    if (header) 
    {
      t << "            <title>" << convertToXML(header) << "</title>" << endl;
    } 
    else 
    {
      t << "            <title>" << title << "</title>" << endl;
    }
  }

  if (documentation) 
  {
    t << "      <description>";
    writeDocbookDocBlock(t,d->docFile(),d->docLine(),d,0,documentation);
    t << "</description>" << endl;
  }
  for (mli.toFirst();(md=mli.current());++mli) 
  {
    // namespace members are also inserted in the file scope, but
    // to prevent this duplication in the Docbook output, we filter those here.
    if (d->definitionType()!=Definition::TypeFile || md->getNamespaceDef()==0) 
    {
      generateDocbookForMember(md,t,d,detailed);
    }
  }
  if (detailed) 
  {
    if (desctitle) 
    {
      if (desctitle=="Member Documentation") 
      {
        if (doc_count > 0) 
        {
          t << "        </simplesect>" << endl;
        }
      } 
      else if (desctitle=="Define Documentation") 
      {
        if (doc_count > 0) 
        {
          t << "        </section>" << endl;
        }
      } 
      else 
      {
        t << "        </section>" << endl;
      }
    }
  } 
  else 
  {
    t << "        </simplesect>" << endl;
  }
}

static void writeInnerClasses(const ClassSDict *cl,FTextStream &t)
{
  if (cl)
  {
    ClassSDict::Iterator cli(*cl);
    ClassDef *cd;
    QCString title = "Classes";

    if (cli.toFirst()) 
    {
      t << "        <simplesect>" << endl;
      t << "            <title> " << title << " </title>" << endl;
    }
    for (cli.toFirst();(cd=cli.current());++cli)
    {
      if (!cd->isHidden() && cd->name().find('@')==-1) 
      {
        t << "            <para>" << endl;
        t << "                <itemizedlist>" << endl;
        t << "                    <listitem>" << endl;
        t << "                        <para>" << "struct <link linkend=\"" << classOutputFileBase(cd) << "\">" << convertToXML(cd->name()) << "</link>";
        t << "</para>" << endl;
        t << "                    </listitem>" << endl;
        t << "                </itemizedlist>" << endl;
        t << "            </para>" << endl;
      }
    }
    if (cli.toFirst()) 
    {
      t << "        </simplesect>" << endl;
    }
  }
}

static void writeInnerNamespaces(const NamespaceSDict *nl,FTextStream &t)
{
  if (nl)
  {
    NamespaceSDict::Iterator nli(*nl);
    NamespaceDef *nd;
    QCString title = "Namespaces";

    if (nli.toFirst()) 
    {
      t << "        <simplesect>" << endl;
      t << "            <title> " << title << " </title>" << endl;
    }
    for (nli.toFirst();(nd=nli.current());++nli)
    {
      if (!nd->isHidden() && nd->name().find('@')==-1) // skip anonymouse scopes
      {
        t << "            <para>" << endl;
        t << "                <itemizedlist>" << endl;
        t << "                    <listitem>" << endl;
        t << "                        <para>" << "struct <link linkend=\"" << nd->getOutputFileBase() << "\">" << convertToXML(nd->name()) << "</link>";
        t << "</para>" << endl;
        t << "                    </listitem>" << endl;
        t << "                </itemizedlist>" << endl;
        t << "            </para>" << endl;
      }
    }
    if (nli.toFirst()) 
    {
      t << "        </simplesect>" << endl;
    }
  }
}

static void writeInnerFiles(const FileList *fl,FTextStream &t)
{
  if (fl)
  {
    QListIterator<FileDef> fli(*fl);
    FileDef *fd;
    QCString title = "Files";

    if (fli.toFirst()) 
    {
      t << "        <simplesect>" << endl;
      t << "            <title> " << title << " </title>" << endl;
    }
    for (fli.toFirst();(fd=fli.current());++fli) 
    {
      t << "            <para>" << endl;
      t << "                <itemizedlist>" << endl;
      t << "                    <listitem>" << endl;
      t << "                        <para>" << "file <link linkend=\"" << fd->getOutputFileBase() << "\">" << convertToXML(fd->name()) << "</link>";
      t << "</para>" << endl;
      t << "                    </listitem>" << endl;
      t << "                </itemizedlist>" << endl;
      t << "            </para>" << endl;
    }
    if (fli.toFirst()) 
    {
      t << "        </simplesect>" << endl;
    }
  }
}

static void writeInnerPages(const PageSDict *pl,FTextStream &t)
{
  if (pl)
  {
    PageSDict::Iterator pli(*pl);
    PageDef *pd;

    for (pli.toFirst();(pd=pli.current());++pli)
    {
      t << "<xi:include href=\"" << pd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>"  << endl;
    }
  }
}

static void writeInnerGroups(const GroupList *gl,FTextStream &t)
{
  if (gl)
  {
    GroupListIterator gli(*gl);
    GroupDef *sgd;

    //Docbook header tags for inner groups
    if (gli.toFirst()) 
    {
      t << "    <simplesect>" << endl;
      t << "        <title>Modules</title>" << endl;
      t << "    </simplesect>" << endl;
      t << "    <para>" << endl;
      t << "        <itemizedlist>" << endl;
    }

    for (gli.toFirst();(sgd=gli.current());++gli)
    {
      t << "            <listitem><para><link linkend=\"" << sgd->getOutputFileBase() << "\">" << convertToXML(sgd->groupTitle()) << "</link></para></listitem>" << endl;
    }

    //Docbook footer tags for inner groups
    if (gli.toFirst()) 
    {
      t << "        </itemizedlist>" << endl;
      t << "    </para>" << endl;
    }

  }
}

static void writeInnerDirs(const DirList *dl,FTextStream &t)
{
  if (dl)
  {
    QListIterator<DirDef> subdirs(*dl);
    DirDef *subdir;
    QCString title = "Directories";
    if (subdirs.toFirst()) 
    {
      t << "        <simplesect>" << endl;
      t << "            <title> " << title << " </title>" << endl;
    }
    for (subdirs.toFirst();(subdir=subdirs.current());++subdirs)
    {
      t << "            <para>" << endl;
      t << "                <itemizedlist>" << endl;
      t << "                    <listitem>" << endl;
      t << "                        <para>" << "dir <link linkend=\"" << subdir->getOutputFileBase() << "\">" << convertToXML(subdir->displayName()) << "</link>";
      t << "</para>" << endl;
      t << "                    </listitem>" << endl;
      t << "                </itemizedlist>" << endl;
      t << "            </para>" << endl;
    }
    if (subdirs.toFirst()) 
    {
      t << "        </simplesect>" << endl;
    }
  }
}

static void writeInnerGroupFiles(const GroupList *gl,FTextStream &t)
{
  if (gl)
  {
    GroupListIterator gli(*gl);
    GroupDef *sgd;

    for (gli.toFirst();(sgd=gli.current());++gli)
    {
      t << "<xi:include href=\"" << sgd->getOutputFileBase() << ".xml\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>"  << endl;
    }
  }
}

static void generateDocbookForClass(ClassDef *cd,FTextStream &ti)
{
  // + brief description
  // + detailed description
  // + template argument list(s)
  // - include file
  // + member groups
  // + inheritance diagram
  // + list of direct super classes
  // + list of direct sub classes
  // + list of inner classes
  // + collaboration diagram
  // + list of all members
  // + user defined member sections
  // + standard member sections
  // + detailed member documentation
  // - examples using the class

  if (cd->isReference())        return; // skip external references.
  if (cd->isHidden())           return; // skip hidden classes.
  if (cd->name().find('@')!=-1) return; // skip anonymous compounds.
  if (cd->templateMaster()!=0)  return; // skip generated template instances.

  msg("Generating Docbook output for class %s\n",cd->name().data());

  QCString fileDocbook=cd->getOutputFileBase()+".xml";
  //Add the file Documentation info to index file
  ti << "        <xi:include href=\"" << fileDocbook << "\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;

  QCString outputDirectory = Config_getString("DOCBOOK_OUTPUT");
  QCString fileName=outputDirectory+"/"+ classOutputFileBase(cd)+".xml";
1129
  QCString relPath = relativePathToRoot(fileName);
1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157
  QFile f(fileName);
  if (!f.open(IO_WriteOnly))
  {
    err("Cannot open file %s for writing!\n",fileName.data());
    return;
  }
  FTextStream t(&f);
  //t.setEncoding(FTextStream::UnicodeUTF8);

  writeDocbookHeader_ID(t, classOutputFileBase(cd));
  t << "<title>";
  writeDocbookString(t,cd->name());
  t << " " << cd->compoundTypeString() << " Reference";
  t << "</title>" << endl;

  IncludeInfo *ii=cd->includeInfo();
  if (ii)
  {
    QCString nm = ii->includeName;
    if (nm.isEmpty() && ii->fileDef) nm = ii->fileDef->docName();
    if (!nm.isEmpty())
    {
      t << "<para>" << endl;
      t << "    <programlisting>#include ";
      if (ii->fileDef && !ii->fileDef->isReference()) // TODO: support external references
      {
        t << "<link linkend=\"" << ii->fileDef->getOutputFileBase() << "\">";
      }
1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178
      if (ii->local)
      {
        t << "&quot;";
      }
      else
      {
        t << "&lt;";
      }
      t << convertToXML(nm);
      if (ii->local)
      {
        t << "&quot;";
      }
      else
      {
        t << "&gt;";
      }
      if (ii->fileDef && !ii->fileDef->isReference())
      {
        t << "</link>";
      }
1179 1180 1181 1182 1183
      t << "</programlisting>" << endl;
      t << "</para>" << endl;
    }
  }

1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197
  if (Config_getBool("HAVE_DOT") && (Config_getBool("CLASS_DIAGRAMS") || Config_getBool("CLASS_GRAPH")))
  {
    t << "<para>Inheritance diagram for " << convertToXML(cd->name()) << "</para>" << endl;
    DotClassGraph inheritanceGraph(cd,DotNode::Inheritance);
    inheritanceGraph.writeGraph(t,GOF_BITMAP,EOF_DocBook,Config_getString("DOCBOOK_OUTPUT"),fileName,relPath,TRUE,FALSE);
  }

  if (Config_getBool("HAVE_DOT") && Config_getBool("COLLABORATION_GRAPH"))
  {
    t << "<para>Collaboration diagram for " << convertToXML(cd->name()) << "</para>" << endl;
    DotClassGraph collaborationGraph(cd,DotNode::Collaboration);
    collaborationGraph.writeGraph(t,GOF_BITMAP,EOF_DocBook,Config_getString("DOCBOOK_OUTPUT"),fileName,relPath,TRUE,FALSE);
  }

1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385
  writeInnerClasses(cd->getClassSDict(),t);

  writeTemplateList(cd,t);
  if (cd->getMemberGroupSDict())
  {
    MemberGroupSDict::Iterator mgli(*cd->getMemberGroupSDict());
    MemberGroup *mg;
    for (;(mg=mgli.current());++mgli)
    {
      generateDocbookSection(cd,t,mg->members(),"user-defined",0,mg->header(),
          mg->documentation());
    }
  }


  QListIterator<MemberList> mli(cd->getMemberLists());
  MemberList *ml;
  for (mli.toFirst();(ml=mli.current());++mli)
  {
    if ((ml->listType()&MemberListType_detailedLists)==0)
    {
      generateDocbookSection(cd,t,ml,g_docbookSectionMapper.find(ml->listType()));
    }
  }
  if (cd->briefDescription()) 
  {
    t << "    <simplesect>" << endl;
    t << "        <title>Brief Description</title>" << endl;
    writeDocbookDocBlock(t,cd->briefFile(),cd->briefLine(),cd,0,cd->briefDescription());
    t << "    </simplesect>" << endl;
  }

  if (cd->documentation()) 
  {
    t << "        <simplesect>" << endl;
    t << "            <title>Detailed Description</title>" << endl;
    writeDocbookDocBlock(t,cd->docFile(),cd->docLine(),cd,0,cd->documentation());
    t << "                <para>Definition at line " << cd->getDefLine() << " of file " << stripPath(cd->getDefFileName()) << "</para>" << endl;
    t << "                <para>The Documentation for this struct was generated from the following file: </para>" << endl;
    t << "                <para><itemizedlist><listitem><para>" << stripPath(cd->getDefFileName()) << "</para></listitem></itemizedlist></para>" << endl;
    t << "        </simplesect>" << endl;
  }
  for (mli.toFirst();(ml=mli.current());++mli)
  {
    if ((ml->listType()&MemberListType_detailedLists)==0)
    {
      generateDocbookSection(cd,t,ml,g_docbookSectionMapper.find(ml->listType()),1);
    }
  }

  /*// TODO: Handling of Inheritance and Colloboration graph for Docbook to be implemented
    DotClassGraph inheritanceGraph(cd,DotNode::Inheritance);
    if (!inheritanceGraph.isTrivial())
    {
    t << "    <inheritancegraph>" << endl;
    inheritanceGraph.writeDocbook(t);
    t << "    </inheritancegraph>" << endl;
    }
    DotClassGraph collaborationGraph(cd,DotNode::Collaboration);
    if (!collaborationGraph.isTrivial())
    {
    t << "    <collaborationgraph>" << endl;
    collaborationGraph.writeDocbook(t);
    t << "    </collaborationgraph>" << endl;
    }
    t << "    <location file=\""
    << cd->getDefFileName() << "\" line=\""
    << cd->getDefLine() << "\"";
    if (cd->getStartBodyLine()!=-1)
    {
    FileDef *bodyDef = cd->getBodyDef();
    if (bodyDef)
    {
    t << " bodyfile=\"" << bodyDef->absFilePath() << "\"";
    }
    t << " bodystart=\"" << cd->getStartBodyLine() << "\" bodyend=\""
    << cd->getEndBodyLine() << "\"";
    }
    t << "/>" << endl;
    writeListOfAllMembers(cd,t);
   */

  t << "</section>" << endl;

}

static void generateDocbookForNamespace(NamespaceDef *nd,FTextStream &ti)
{
  // + contained class definitions
  // + contained namespace definitions
  // + member groups
  // + normal members
  // + brief desc
  // + detailed desc
  // + location
  // - files containing (parts of) the namespace definition

  if (nd->isReference() || nd->isHidden()) return; // skip external references

  QCString fileDocbook=nd->getOutputFileBase()+".xml";
  //Add the file Documentation info to index file
  ti << "        <xi:include href=\"" << fileDocbook << "\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;

  QCString outputDirectory = Config_getString("DOCBOOK_OUTPUT");
  QCString fileName=outputDirectory+"/"+nd->getOutputFileBase()+".xml";
  QFile f(fileName);
  if (!f.open(IO_WriteOnly))
  {
    err("Cannot open file %s for writing!\n",fileName.data());
    return;
  }
  FTextStream t(&f);
  //t.setEncoding(FTextStream::UnicodeUTF8);

  writeDocbookHeader_ID(t, nd->getOutputFileBase());
  t << "<title>";
  writeDocbookString(t,nd->name());
  t << "</title>" << endl;

  writeInnerClasses(nd->getClassSDict(),t);
  writeInnerNamespaces(nd->getNamespaceSDict(),t);

  if (nd->getMemberGroupSDict())
  {
    MemberGroupSDict::Iterator mgli(*nd->getMemberGroupSDict());
    MemberGroup *mg;
    for (;(mg=mgli.current());++mgli)
    {
      generateDocbookSection(nd,t,mg->members(),"user-defined",0,mg->header(),
          mg->documentation());
    }
  }

  QListIterator<MemberList> mli(nd->getMemberLists());
  MemberList *ml;
  for (mli.toFirst();(ml=mli.current());++mli)
  {
    if ((ml->listType()&MemberListType_declarationLists)!=0)
    {
      generateDocbookSection(nd,t,ml,g_docbookSectionMapper.find(ml->listType()));
    }
  }

  if (nd->briefDescription()) 
  {
    t << "    <simplesect>" << endl;
    t << "        <title>Brief Description</title>" << endl;
    writeDocbookDocBlock(t,nd->briefFile(),nd->briefLine(),nd,0,nd->briefDescription());
    t << "    </simplesect>" << endl;
  }

  if (nd->documentation()) 
  {
    t << "        <simplesect>" << endl;
    t << "            <title>Detailed Description</title>" << endl;
    writeDocbookDocBlock(t,nd->docFile(),nd->docLine(),nd,0,nd->documentation());
    t << "                <para>Definition at line " << nd->getDefLine() << " of file " << stripPath(nd->getDefFileName()) << "</para>" << endl;
    t << "                <para>The Documentation for this struct was generated from the following file: </para>" << endl;
    t << "                <para><itemizedlist><listitem><para>" << stripPath(nd->getDefFileName()) << "</para></listitem></itemizedlist></para>" << endl;
    t << "        </simplesect>" << endl;
  }
  t << "</section>" << endl;
}

static void generateDocbookForFile(FileDef *fd,FTextStream &ti)
{
  // + includes files
  // + includedby files
  // + include graph
  // + included by graph
  // + contained class definitions
  // + contained namespace definitions
  // + member groups
  // + normal members
  // + brief desc
  // + detailed desc
  // + source code
  // + location
  // - number of lines

  if (fd->isReference()) return; // skip external references

  QCString fileDocbook=fd->getOutputFileBase()+".xml";
  //Add the file Documentation info to index file
  ti << "        <xi:include href=\"" << fileDocbook << "\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;

  QCString outputDirectory = Config_getString("DOCBOOK_OUTPUT");
  QCString fileName=outputDirectory+"/"+fd->getOutputFileBase()+".xml";
1386
  QCString relPath = relativePathToRoot(fileName);
1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410

  QFile f(fileName);
  if (!f.open(IO_WriteOnly))
  {
    err("Cannot open file %s for writing!\n",fileName.data());
    return;
  }
  FTextStream t(&f);
  //t.setEncoding(FTextStream::UnicodeUTF8);
  writeDocbookHeader_ID(t, fd->getOutputFileBase());

  t << "    <title>";
  writeDocbookString(t,fd->name());
  t << " File Reference";
  t << "</title>" << endl;

  IncludeInfo *inc;

  if (fd->includeFileList())
  {
    QListIterator<IncludeInfo> ili1(*fd->includeFileList());
    for (ili1.toFirst();(inc=ili1.current());++ili1)
    {
      t << "    <programlisting>#include ";
1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427
      if (inc->local)
      {
        t << "&quot;";
      }
      else
      {
        t << "&lt;";
      }
      t << convertToXML(inc->includeName);
      if (inc->local)
      {
        t << "&quot;";
      }
      else
      {
        t << "&gt;";
      }
1428 1429 1430
      t << "</programlisting>" << endl;
    }
  }
1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445
  if (Config_getBool("HAVE_DOT"))
  {
    if (Config_getBool("INCLUDE_GRAPH"))
    {
      t << "<para>Include dependency diagram for " << convertToXML(fd->name()) << "</para>" << endl;
      DotInclDepGraph idepGraph(fd, FALSE);
      idepGraph.writeGraph(t,GOF_BITMAP,EOF_DocBook,Config_getString("DOCBOOK_OUTPUT"),fileName,relPath,FALSE);
    }
    if (Config_getBool("INCLUDED_BY_GRAPH"))
    {
      t << "<para>Included by dependency diagram for " << convertToXML(fd->name()) << "</para>" << endl;
      DotInclDepGraph ibdepGraph(fd, TRUE);
      ibdepGraph.writeGraph(t,GOF_BITMAP,EOF_DocBook,Config_getString("DOCBOOK_OUTPUT"),fileName,relPath,FALSE);
    }
  }
1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480

  if (fd->getClassSDict())
  {
    writeInnerClasses(fd->getClassSDict(),t);
  }
  if (fd->getNamespaceSDict())
  {
    writeInnerNamespaces(fd->getNamespaceSDict(),t);
  }

  if (fd->getMemberGroupSDict())
  {
    MemberGroupSDict::Iterator mgli(*fd->getMemberGroupSDict());
    MemberGroup *mg;
    for (;(mg=mgli.current());++mgli)
    {
      generateDocbookSection(fd,t,mg->members(),"user-defined",0,mg->header(),
          mg->documentation());
    }
  }

  QListIterator<MemberList> mli(fd->getMemberLists());
  MemberList *ml;
  for (mli.toFirst();(ml=mli.current());++mli)
  {
    if ((ml->listType()&MemberListType_declarationLists)!=0)
    {
      generateDocbookSection(fd,t,ml,g_docbookSectionMapper.find(ml->listType()));
    }
  }

  t << "    <simplesect>" << endl;
  t << "        <title>Detailed Description</title>" << endl;
  writeDocbookDocBlock(t,fd->briefFile(),fd->briefLine(),fd,0,fd->briefDescription());
  writeDocbookDocBlock(t,fd->docFile(),fd->docLine(),fd,0,fd->documentation());
1481 1482 1483 1484 1485 1486 1487 1488
  if (Config_getBool("FULL_PATH_NAMES")) 
  {
    t << "    <para>Definition in file " << fd->getDefFileName() << "</para>" << endl;
  }
  else
  {
    t << "    <para>Definition in file " << stripPath(fd->getDefFileName()) << "</para>" << endl;
  }
1489 1490
  t << "    </simplesect>" << endl;

1491 1492 1493
  if (Config_getBool("DOCBOOK_PROGRAMLISTING"))
  {
    t << "    <literallayout><computeroutput>" << endl;
1494
    writeDocbookCodeBlock(t,fd);
1495 1496
    t << "    </computeroutput></literallayout>" << endl;
  }
1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525

  t << "</section>" << endl;
}

static void generateDocbookForGroup(GroupDef *gd,FTextStream &ti)
{
  // + members
  // + member groups
  // + files
  // + classes
  // + namespaces
  // - packages
  // + pages
  // + child groups
  // - examples
  // + brief description
  // + detailed description

  if (gd->isReference()) return; // skip external references

  if (!gd->isASubGroup()) 
  {
    QCString fileDocbook=gd->getOutputFileBase()+".xml";
    //Add the file Documentation info to index file
    ti << "        <xi:include href=\"" << fileDocbook << "\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;
  }

  QCString outputDirectory = Config_getString("DOCBOOK_OUTPUT");
  QCString fileName=outputDirectory+"/"+gd->getOutputFileBase()+".xml";
1526
  QCString relPath = relativePathToRoot(fileName);
1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540

  QFile f(fileName);
  if (!f.open(IO_WriteOnly))
  {
    err("Cannot open file %s for writing!\n",fileName.data());
    return;
  }

  FTextStream t(&f);
  //t.setEncoding(FTextStream::UnicodeUTF8);
  writeDocbookHeader_ID(t, gd->getOutputFileBase());

  t << "    <title>" << convertToXML(gd->groupTitle()) << "</title>" << endl;

1541 1542 1543 1544 1545 1546 1547
  if (Config_getBool("GROUP_GRAPHS") && Config_getBool("HAVE_DOT"))
  {
    t << "<para>Collaboration diagram for " << convertToXML(gd->groupTitle()) << "</para>" << endl;
    DotGroupCollaboration collaborationGraph(gd);
    collaborationGraph.writeGraph(t,GOF_BITMAP,EOF_DocBook,Config_getString("DOCBOOK_OUTPUT"),fileName,relPath,FALSE);
  }

1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614
  if (gd->briefDescription()) 
  {
    t << "    <simplesect>" << endl;
    t << "        <title>Brief Description</title>" << endl;
    writeDocbookDocBlock(t,gd->briefFile(),gd->briefLine(),gd,0,gd->briefDescription());
    t << "    </simplesect>" << endl;
  }

  if (gd->documentation()) 
  {
    t << "        <simplesect>" << endl;
    t << "            <title>Detailed Description</title>" << endl;
    writeDocbookDocBlock(t,gd->docFile(),gd->docLine(),gd,0,gd->documentation());
    t << "        </simplesect>" << endl;
  }

  writeInnerFiles(gd->getFiles(),t);
  writeInnerClasses(gd->getClasses(),t);
  writeInnerNamespaces(gd->getNamespaces(),t);
  writeInnerPages(gd->getPages(),t);
  writeInnerGroups(gd->getSubGroups(),t);

  if (gd->getMemberGroupSDict())
  {
    MemberGroupSDict::Iterator mgli(*gd->getMemberGroupSDict());
    MemberGroup *mg;
    for (;(mg=mgli.current());++mgli)
    {
      generateDocbookSection(gd,t,mg->members(),"user-defined",0,mg->header(),
          mg->documentation());
    }
  }

  QListIterator<MemberList> mli(gd->getMemberLists());
  MemberList *ml;
  for (mli.toFirst();(ml=mli.current());++mli)
  {
    if ((ml->listType()&MemberListType_declarationLists)!=0)
    {
      generateDocbookSection(gd,t,ml,g_docbookSectionMapper.find(ml->listType()));
    }
  }
  for (mli.toFirst();(ml=mli.current());++mli)
  {
    if ((ml->listType()&MemberListType_declarationLists)!=0)
    {
      generateDocbookSection(gd,t,ml,g_docbookSectionMapper.find(ml->listType()),1);
    }
  }

  writeInnerGroupFiles(gd->getSubGroups(),t);

  t << "</section>" << endl;

}

static void generateDocbookForDir(DirDef *dd,FTextStream &ti)
{
  if (dd->isReference()) return; // skip external references

  QCString fileDocbook=dd->getOutputFileBase()+".xml";
  //Add the file Documentation info to index file
  ti << "        <xi:include href=\"" << fileDocbook << "\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;

  QCString outputDirectory = Config_getString("DOCBOOK_OUTPUT");
  QCString fileName=outputDirectory+"/"+dd->getOutputFileBase()+".xml";
  QFile f(fileName);
1615 1616
  QCString relPath = relativePathToRoot(fileName);

1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630
  if (!f.open(IO_WriteOnly))
  {
    err("Cannot open file %s for writing!\n",fileName.data());
    return;
  }

  FTextStream t(&f);
  //t.setEncoding(FTextStream::UnicodeUTF8);
  writeDocbookHeader_ID(t, dd->getOutputFileBase());

  t << "    <title>";
  writeDocbookString(t, dd->displayName());
  t << " Directory Reference";
  t << "</title>" << endl;
1631 1632 1633 1634 1635 1636
  if (Config_getBool("DIRECTORY_GRAPH") && Config_getBool("HAVE_DOT"))
  {
    t << "<para>Directory dependency diagram for " << convertToXML(dd->displayName()) << "</para>" << endl;
    DotDirDeps dirdepGraph(dd);
    dirdepGraph.writeGraph(t,GOF_BITMAP,EOF_DocBook,Config_getString("DOCBOOK_OUTPUT"),fileName,relPath,FALSE);
  }
1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680

  writeInnerDirs(&dd->subDirs(),t);
  writeInnerFiles(dd->getFiles(),t);

  t << "    <simplesect>" << endl;
  t << "        <title>Detailed Description</title>" << endl;
  writeDocbookDocBlock(t,dd->briefFile(),dd->briefLine(),dd,0,dd->briefDescription());
  writeDocbookDocBlock(t,dd->docFile(),dd->docLine(),dd,0,dd->documentation());
  t << "    <para>Directory location is " << dd->name() << "</para>" << endl;
  t << "    </simplesect>" << endl;

  t << "</section>" << endl;
}

static void generateDocbookForPage(PageDef *pd,FTextStream &ti,bool isExample)
{
  // + name
  // + title
  // + documentation

  if (pd->isReference()) return;

  QCString pageName = pd->getOutputFileBase();
  if (pd->getGroupDef())
  {
    pageName+=(QCString)"_"+pd->name();
  }
  if (pageName=="index") 
  {
    pageName="mainpage"; // to prevent overwriting the generated index page.
  }

  QCString outputDirectory = Config_getString("DOCBOOK_OUTPUT");
  QCString fileName=outputDirectory+"/"+pageName+".xml";
  QFile f(fileName);
  if (!f.open(IO_WriteOnly))
  {
    err("Cannot open file %s for writing!\n",fileName.data());
    return;
  }

  FTextStream t(&f);
  //t.setEncoding(FTextStream::UnicodeUTF8);

1681 1682 1683 1684 1685 1686 1687
  if(isExample)
  {
    QCString fileDocbook=pageName+".xml";
    ti << "        <xi:include href=\"" << fileDocbook << "\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;
  }

  if (!pd->hasParentPage() && !isExample)
1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712
  {
    QCString fileDocbook=pageName+".xml";
    //Add the file Documentation info to index file
    ti << "        <xi:include href=\"" << fileDocbook << "\" xmlns:xi=\"http://www.w3.org/2001/XInclude\"/>" << endl;
    writeDocbookHeaderMainpage(t);
  } 
  else 
  {
    QCString pid = pageName+"_1"+pageName;
    writeDocbookHeader_ID(t, pid);
  }

  SectionInfo *si = Doxygen::sectionDict->find(pd->name());
  if (si)
  {
    t << "    <title>" << convertToXML(si->title) << "</title>" << endl;
  } 
  else 
  {
    t << "    <title>" << convertToXML(pd->name()) << "</title>" << endl;
  }

  if (isExample)
  {
    writeDocbookDocBlock(t,pd->docFile(),pd->docLine(),pd,0,
1713
        pd->documentation()+"\n\\include "+pd->name());
1714 1715 1716 1717 1718 1719 1720 1721
  }
  else
  {
    writeDocbookDocBlock(t,pd->docFile(),pd->docLine(),pd,0,
        pd->documentation());
  }
  writeInnerPages(pd->getSubPages(),t);

1722
  if (!pd->hasParentPage() && !isExample)
1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754
  {
    t << endl << "</chapter>" << endl;
  } 
  else 
  {
    t << endl << "</section>" << endl;
  }
}

void generateDocbook()
{

  // + classes
  // + namespaces
  // + files
  // + groups
  // + related pages
  // - examples

  QCString outputDirectory = Config_getString("DOCBOOK_OUTPUT");
  if (outputDirectory.isEmpty())
  {
    outputDirectory=QDir::currentDirPath().utf8();
  }
  else
  {
    QDir dir(outputDirectory);
    if (!dir.exists())
    {
      dir.setPath(QDir::currentDirPath());
      if (!dir.mkdir(outputDirectory))
      {
1755
        err("tag DOCBOOK_OUTPUT: Output directory `%s' does not "
1756 1757 1758
            "exist and cannot be created\n",outputDirectory.data());
        exit(1);
      }
1759
      else
1760
      {
1761
        msg("Notice: Output directory `%s' does not exist. "
1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895
            "I have created it for you.\n", outputDirectory.data());
      }
      dir.cd(outputDirectory);
    }
    outputDirectory=dir.absPath().utf8();
  }

  QDir dir(outputDirectory);
  if (!dir.exists())
  {
    dir.setPath(QDir::currentDirPath());
    if (!dir.mkdir(outputDirectory))
    {
      err("Cannot create directory %s\n",outputDirectory.data());
      return;
    }
  }
  QDir docbookDir(outputDirectory);
  createSubDirs(docbookDir);

  QCString fileName=outputDirectory+"/index.xml";
  QCString dbk_projectName = Config_getString("PROJECT_NAME");
  QFile f(fileName);

  f.setName(fileName);
  if (!f.open(IO_WriteOnly))
  {
    err("Cannot open file %s for writing!\n",fileName.data());
    return;
  }
  FTextStream t(&f);
  //t.setEncoding(FTextStream::UnicodeUTF8);

  // write index header for Docbook which calls the structure file
  t << "<?xml version='1.0' encoding='UTF-8' standalone='no'?>" << endl;;
  t << "<book xmlns=\"http://docbook.org/ns/docbook\" version=\"5.0\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">" << endl;
  t << "    <info>" << endl;
  t << "    <title>" << dbk_projectName << "</title>" << endl;
  t << "    </info>" << endl;

  // NAMESPACE DOCUMENTATION
  NamespaceSDict::Iterator nli(*Doxygen::namespaceSDict);
  NamespaceDef *nd;

  //Namespace Documentation index header
  if (nli.toFirst()) 
  {
    t << "    <chapter>" << endl;
    t << "        <title>Namespace Documentation</title>" << endl;
  }

  for (nli.toFirst();(nd=nli.current());++nli)
  {
    msg("Generating Docbook output for namespace %s\n",nd->name().data());
    generateDocbookForNamespace(nd,t);
  }

  //Namespace Documentation index footer
  if (nli.toFirst()) 
  {
    t << "    </chapter>" << endl;
  }

  /** MAINPAGE DOCUMENTATION **/

  if (Doxygen::mainPage)
  {
    msg("Generating Docbook output for the main page\n");
    generateDocbookForPage(Doxygen::mainPage,t,FALSE);
  }

  // PAGE DOCUMENTATION
  {
    PageSDict::Iterator pdi(*Doxygen::pageSDict);
    PageDef *pd=0;

    for (pdi.toFirst();(pd=pdi.current());++pdi)
    {
      msg("Generating Docbook output for page %s\n",pd->name().data());
      generateDocbookForPage(pd,t,FALSE);
    }
  }

  /** MODULE GROUP DOCUMENTATION **/

  GroupSDict::Iterator gli(*Doxygen::groupSDict);
  GroupDef *gd;

  //Module group Documentation index header
  if (gli.toFirst()) 
  {
    t << "    <chapter>" << endl;
    t << "        <title>Module Documentation</title>" << endl;
  }

  for (;(gd=gli.current());++gli)
  {
    msg("Generating Docbook output for group %s\n",gd->name().data());
    generateDocbookForGroup(gd,t);
  }

  //Module group Documentation index footer
  if (gli.toFirst()) 
  {
    t << "    </chapter>" << endl;
  }

  //CLASS DOCUMENTATION

  {
    ClassSDict::Iterator cli(*Doxygen::classSDict);
    ClassDef *cd;

    //Class Documentation index header
    if (cli.toFirst()) 
    {
      t << "    <chapter>" << endl;
      t << "        <title>Class Documentation</title>" << endl;
    }

    for (cli.toFirst();(cd=cli.current());++cli)
    {
      generateDocbookForClass(cd,t);
    }

    //Class Documentation index footer
    if (cli.toFirst()) 
    {
      t << "    </chapter>" << endl;
    }
  }

  // FILE DOCUMENTATION

1896 1897
  static bool showFiles = Config_getBool("SHOW_FILES");
  if (showFiles)
1898
  {
1899 1900
    FileNameListIterator fnli(*Doxygen::inputNameList);
    FileName *fn;
1901

1902 1903
    //File Documentation index header
    if (fnli.toFirst()) 
1904
    {
1905 1906
      t << "    <chapter>" << endl;
      t << "        <title>File Documentation</title>" << endl;
1907 1908
    }

1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924
    for (;(fn=fnli.current());++fnli)
    {
      FileNameIterator fni(*fn);
      FileDef *fd;
      for (;(fd=fni.current());++fni)
      {
        msg("Generating Docbook output for file %s\n",fd->name().data());
        generateDocbookForFile(fd,t);
      }
    }

    //File Documentation index footer
    if (fnli.toFirst()) 
    {
      t << "    </chapter>" << endl;
    }
1925 1926 1927
  }

  // DIRECTORY DOCUMENTATION
1928
  if (Config_getBool("DIRECTORY_GRAPH") && Config_getBool("HAVE_DOT"))
1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983
  {
    DirDef *dir;
    DirSDict::Iterator sdi(*Doxygen::directories);

    //Directory Documentation index header
    if (sdi.toFirst()) 
    {
      t << "    <chapter>" << endl;
      t << "        <title>Directory Documentation</title>" << endl;
    }

    for (sdi.toFirst();(dir=sdi.current());++sdi)
    {
      msg("Generate Docbook output for dir %s\n",dir->name().data());
      generateDocbookForDir(dir,t);
    }

    //Module group Documentation index footer
    if (sdi.toFirst()) 
    {
      t << "    </chapter>" << endl;
    }
  }

  // EXAMPLE PAGE DOCUMENTATION

  {
    PageSDict::Iterator pdi(*Doxygen::exampleSDict);
    PageDef *pd=0;

    //Example Page Documentation index header
    if (pdi.toFirst()) 
    {
      t << "    <chapter>" << endl;
      t << "        <title>Example Documentation</title>" << endl;
    }

    for (pdi.toFirst();(pd=pdi.current());++pdi)
    {
      msg("Generating Docbook output for example %s\n",pd->name().data());
      generateDocbookForPage(pd,t,TRUE);
    }

    //Example Page Documentation index footer
    if (pdi.toFirst()) 
    {
      t << "    </chapter>" << endl;
    }
  }

  t << "</book>" << endl;

}