perlmodgen.cpp 81.9 KB
Newer Older
1 2 3 4 5
/******************************************************************************
 *
 *
 *
 *
Dimitri van Heesch's avatar
Dimitri van Heesch committed
6
 * Copyright (C) 1997-2014 by Dimitri van Heesch.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
 * Authors: Dimitri van Heesch, Miguel Lobo.
 *
 * 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>

22 23 24 25 26
#include <qdir.h>
#include <qstack.h>
#include <qdict.h>
#include <qfile.h>

27 28 29 30
#include "perlmodgen.h"
#include "docparser.h"
#include "message.h"
#include "doxygen.h"
31
#include "pagedef.h"
32
#include "memberlist.h"
Dimitri van Heesch's avatar
Dimitri van Heesch committed
33
#include "ftextstream.h"
34
#include "arguments.h"
35 36 37 38 39 40 41 42 43
#include "config.h"
#include "groupdef.h"
#include "classdef.h"
#include "classlist.h"
#include "filename.h"
#include "membername.h"
#include "namespacedef.h"
#include "membergroup.h"
#include "section.h"
44
#include "util.h"
45
#include "htmlentity.h"
46 47 48 49 50 51 52

#define PERLOUTPUT_MAX_INDENTATION 40

class PerlModOutputStream
{
public:

53
  QCString m_s;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
54
  FTextStream *m_t;
55

Dimitri van Heesch's avatar
Dimitri van Heesch committed
56
  PerlModOutputStream(FTextStream *t = 0) : m_t(t) { }
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

  void add(char c);
  void add(const char *s);
  void add(QCString &s);
  void add(int n);
  void add(unsigned int n);
};

void PerlModOutputStream::add(char c)
{
  if (m_t != 0)
    (*m_t) << c;
  else
    m_s += c;
}

void PerlModOutputStream::add(const char *s)
{
  if (m_t != 0)
    (*m_t) << s;
  else
    m_s += s;
}

void PerlModOutputStream::add(QCString &s)
{
  if (m_t != 0)
    (*m_t) << s;
  else
    m_s += s;
}

void PerlModOutputStream::add(int n)
{
  if (m_t != 0)
    (*m_t) << n;
  else
    m_s += n;
}

void PerlModOutputStream::add(unsigned int n)
{
  if (m_t != 0)
    (*m_t) << n;
  else
    m_s += n;
}

class PerlModOutput
{
public:

109 110 111 112 113 114 115 116
  bool m_pretty;

  inline PerlModOutput(bool pretty)
    : m_pretty(pretty), m_stream(0), m_indentation(false), m_blockstart(true)
  {
    m_spaces[0] = 0;
  }

117 118
  virtual ~PerlModOutput() { }

119 120
  inline void setPerlModOutputStream(PerlModOutputStream *os) { m_stream = os; }

121
  inline PerlModOutput &openSave() { iopenSave(); return *this; }
122
  inline PerlModOutput &closeSave(QCString &s) { icloseSave(s); return *this; }
123 124 125 126 127 128 129 130 131 132 133

  inline PerlModOutput &continueBlock()
  {
    if (m_blockstart)
      m_blockstart = false;
    else
      m_stream->add(',');
    indent();
    return *this;
  }

134 135 136 137 138 139 140
  inline PerlModOutput &add(char c) { m_stream->add(c); return *this; }
  inline PerlModOutput &add(const char *s) { m_stream->add(s); return *this; }
  inline PerlModOutput &add(QCString &s) { m_stream->add(s); return *this; }
  inline PerlModOutput &add(int n) { m_stream->add(n); return *this; }
  inline PerlModOutput &add(unsigned int n) { m_stream->add(n); return *this; }

  PerlModOutput &addQuoted(const char *s) { iaddQuoted(s); return *this; }
141 142 143 144 145 146 147 148 149

  inline PerlModOutput &indent()
  {
    if (m_pretty) {
      m_stream->add('\n');
      m_stream->add(m_spaces);
    }
    return *this;
  }
150 151 152 153 154

  inline PerlModOutput &open(char c, const char *s = 0) { iopen(c, s); return *this; }
  inline PerlModOutput &close(char c = 0) { iclose(c); return *this; }

  inline PerlModOutput &addField(const char *s) { iaddField(s); return *this; }
155 156 157 158
  inline PerlModOutput &addFieldQuotedChar(const char *field, char content)
  {
    iaddFieldQuotedChar(field, content); return *this;
  }
159
  inline PerlModOutput &addFieldQuotedString(const char *field, const char *content)
160
  {
161 162 163 164 165
    iaddFieldQuotedString(field, content); return *this;
  }
  inline PerlModOutput &addFieldBoolean(const char *field, bool content)
  {
    return addFieldQuotedString(field, content ? "yes" : "no");
166 167 168 169 170 171 172 173 174
  }
  inline PerlModOutput &openList(const char *s = 0) { open('[', s); return *this; }
  inline PerlModOutput &closeList() { close(']'); return *this; }
  inline PerlModOutput &openHash(const char *s = 0 ) { open('{', s); return *this; }
  inline PerlModOutput &closeHash() { close('}'); return *this; }

protected:
  
  void iopenSave();
175
  void icloseSave(QCString &);
176 177 178 179 180
  
  void incIndent();
  void decIndent();

  void iaddQuoted(const char *);
181
  void iaddFieldQuotedChar(const char *, char);
182
  void iaddFieldQuotedString(const char *, const char *);
183 184 185 186 187 188 189 190 191
  void iaddField(const char *);

  void iopen(char, const char *);
  void iclose(char);

private:
  
  PerlModOutputStream *m_stream;
  int m_indentation;
192
  bool m_blockstart;
193 194 195 196 197 198 199 200 201 202 203

  QStack<PerlModOutputStream> m_saved;
  char m_spaces[PERLOUTPUT_MAX_INDENTATION * 2 + 2];
};

void PerlModOutput::iopenSave()
{
  m_saved.push(m_stream);
  m_stream = new PerlModOutputStream();
}

204
void PerlModOutput::icloseSave(QCString &s)
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
{
  s = m_stream->m_s;
  delete m_stream;
  m_stream = m_saved.pop();
}

void PerlModOutput::incIndent()
{
  if (m_indentation < PERLOUTPUT_MAX_INDENTATION)
  {
    char *s = &m_spaces[m_indentation * 2];
    *s++ = ' '; *s++ = ' '; *s = 0;
  }
  m_indentation++;
}

void PerlModOutput::decIndent()
{
  m_indentation--;
  if (m_indentation < PERLOUTPUT_MAX_INDENTATION)
    m_spaces[m_indentation * 2] = 0;
}

void PerlModOutput::iaddQuoted(const char *s) 
{
  char c;
  while ((c = *s++) != 0) {
232
    if ((c == '\'') || (c == '\\'))
233 234 235 236 237
      m_stream->add('\\');
    m_stream->add(c);
  }
}
  
238
void PerlModOutput::iaddField(const char *s)
239
{
240
  continueBlock();
241
  m_stream->add(s);
242 243 244 245 246 247 248
  m_stream->add(m_pretty ? " => " : "=>");
}

void PerlModOutput::iaddFieldQuotedChar(const char *field, char content)
{
  iaddField(field);
  m_stream->add('\'');
249
  if ((content == '\'') || (content == '\\'))
250 251 252
    m_stream->add('\\');
  m_stream->add(content);
  m_stream->add('\'');
253 254
}

255
void PerlModOutput::iaddFieldQuotedString(const char *field, const char *content)
256
{
257 258
  if (content == 0)
    return;
259 260 261
  iaddField(field);
  m_stream->add('\'');
  iaddQuoted(content);
262
  m_stream->add('\'');
263 264 265 266 267 268 269
}

void PerlModOutput::iopen(char c, const char *s)
{
  if (s != 0)
    iaddField(s);
  else
270
    continueBlock();
271 272
  m_stream->add(c);
  incIndent();
273
  m_blockstart = true;
274 275 276 277 278 279 280 281
}

void PerlModOutput::iclose(char c)
{
  decIndent(); 
  indent();
  if (c != 0)
    m_stream->add(c); 
282
  m_blockstart = false;
283 284
}

285
/*! @brief Concrete visitor implementation for PerlMod output. */
286 287 288 289
class PerlModDocVisitor : public DocVisitor
{
public:
  PerlModDocVisitor(PerlModOutput &);
290
  virtual ~PerlModDocVisitor() { }
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311

  void finish();
  
  //--------------------------------------
  // visitor functions for leaf nodes
  //--------------------------------------
   
  void visit(DocWord *);
  void visit(DocLinkedWord *);
  void visit(DocWhiteSpace *);
  void visit(DocSymbol *);
  void visit(DocURL *);
  void visit(DocLineBreak *);
  void visit(DocHorRuler *);
  void visit(DocStyleChange *);
  void visit(DocVerbatim *);
  void visit(DocAnchor *);
  void visit(DocInclude *);
  void visit(DocIncOperator *);
  void visit(DocFormula *);
  void visit(DocIndexEntry *);
312
  void visit(DocSimpleSectSep *);
313
  void visit(DocCite *);
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 339 340

  //--------------------------------------
  // visitor functions for compound nodes
  //--------------------------------------
   
  void visitPre(DocAutoList *);
  void visitPost(DocAutoList *);
  void visitPre(DocAutoListItem *);
  void visitPost(DocAutoListItem *);
  void visitPre(DocPara *) ;
  void visitPost(DocPara *);
  void visitPre(DocRoot *);
  void visitPost(DocRoot *);
  void visitPre(DocSimpleSect *);
  void visitPost(DocSimpleSect *);
  void visitPre(DocTitle *);
  void visitPost(DocTitle *);
  void visitPre(DocSimpleList *);
  void visitPost(DocSimpleList *);
  void visitPre(DocSimpleListItem *);
  void visitPost(DocSimpleListItem *);
  void visitPre(DocSection *);
  void visitPost(DocSection *);
  void visitPre(DocHtmlList *);
  void visitPost(DocHtmlList *) ;
  void visitPre(DocHtmlListItem *);
  void visitPost(DocHtmlListItem *);
341 342
  //void visitPre(DocHtmlPre *);
  //void visitPost(DocHtmlPre *);
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366
  void visitPre(DocHtmlDescList *);
  void visitPost(DocHtmlDescList *);
  void visitPre(DocHtmlDescTitle *);
  void visitPost(DocHtmlDescTitle *);
  void visitPre(DocHtmlDescData *);
  void visitPost(DocHtmlDescData *);
  void visitPre(DocHtmlTable *);
  void visitPost(DocHtmlTable *);
  void visitPre(DocHtmlRow *);
  void visitPost(DocHtmlRow *) ;
  void visitPre(DocHtmlCell *);
  void visitPost(DocHtmlCell *);
  void visitPre(DocHtmlCaption *);
  void visitPost(DocHtmlCaption *);
  void visitPre(DocInternal *);
  void visitPost(DocInternal *);
  void visitPre(DocHRef *);
  void visitPost(DocHRef *);
  void visitPre(DocHtmlHeader *);
  void visitPost(DocHtmlHeader *);
  void visitPre(DocImage *);
  void visitPost(DocImage *);
  void visitPre(DocDotFile *);
  void visitPost(DocDotFile *);
367 368
  void visitPre(DocMscFile *);
  void visitPost(DocMscFile *);
369 370
  void visitPre(DocDiaFile *);
  void visitPost(DocDiaFile *);
371 372 373 374 375 376 377 378
  void visitPre(DocLink *);
  void visitPost(DocLink *);
  void visitPre(DocRef *);
  void visitPost(DocRef *);
  void visitPre(DocSecRefItem *);
  void visitPost(DocSecRefItem *);
  void visitPre(DocSecRefList *);
  void visitPost(DocSecRefList *);
379 380
  //void visitPre(DocLanguage *);
  //void visitPost(DocLanguage *);
381 382 383 384 385 386 387 388 389 390 391 392
  void visitPre(DocParamSect *);
  void visitPost(DocParamSect *);
  void visitPre(DocParamList *);
  void visitPost(DocParamList *);
  void visitPre(DocXRefItem *);
  void visitPost(DocXRefItem *);
  void visitPre(DocInternalRef *);
  void visitPost(DocInternalRef *);
  void visitPre(DocCopy *);
  void visitPost(DocCopy *);
  void visitPre(DocText *);
  void visitPost(DocText *);
393 394
  void visitPre(DocHtmlBlockQuote *);
  void visitPost(DocHtmlBlockQuote *);
395 396
  void visitPre(DocVhdlFlow *);
  void visitPost(DocVhdlFlow *);
397 398
  void visitPre(DocParBlock *);
  void visitPost(DocParBlock *);
399 400 401 402 403 404 405

private:

  //--------------------------------------
  // helper functions
  //--------------------------------------

406 407
  void addLink(const QCString &ref, const QCString &file,
	       const QCString &anchor);
408 409 410 411 412 413 414 415 416
   
  void enterText();
  void leaveText();

  void openItem(const char *);
  void closeItem();
  void singleItem(const char *);
  void openSubBlock(const char * = 0);
  void closeSubBlock();
417 418
  void openOther();
  void closeOther();
419 420 421 422 423 424 425

  //--------------------------------------
  // state variables
  //--------------------------------------

  PerlModOutput &m_output;
  bool m_textmode;
426
  bool m_textblockstart;
427
  QCString m_other;
428 429 430
};

PerlModDocVisitor::PerlModDocVisitor(PerlModOutput &output)
Dimitri van Heesch's avatar
Dimitri van Heesch committed
431
  : DocVisitor(DocVisitor_Other), m_output(output), m_textmode(false)
432 433 434 435 436 437 438 439 440 441 442
{
  m_output.openList("doc");
}

void PerlModDocVisitor::finish()
{
  leaveText();
  m_output.closeList()
    .add(m_other);
}

443
void PerlModDocVisitor::addLink(const QCString &,const QCString &file,const QCString &anchor)
444
{
445
  QCString link = file;
446 447
  if (!anchor.isEmpty())
    (link += "_1") += anchor;
448
  m_output.addFieldQuotedString("link", link);
449 450 451 452 453
}

void PerlModDocVisitor::openItem(const char *name)
{
  leaveText();
454
  m_output.openHash().addFieldQuotedString("type", name);
455 456 457 458
}

void PerlModDocVisitor::closeItem()
{
459
  leaveText();
460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476
  m_output.closeHash();
}

void PerlModDocVisitor::enterText()
{
  if (m_textmode)
    return;
  openItem("text");
  m_output.addField("content").add('\'');
  m_textmode = true;
}

void PerlModDocVisitor::leaveText()
{
  if (!m_textmode)
    return;
  m_textmode = false;
477 478 479
  m_output
    .add('\'')
    .closeHash();
480 481 482 483 484 485 486 487 488 489
}

void PerlModDocVisitor::singleItem(const char *name)
{
  openItem(name);
  closeItem();
}

void PerlModDocVisitor::openSubBlock(const char *s)
{
490
  leaveText();
491
  m_output.openList(s);
492
  m_textblockstart = true;
493 494 495 496 497 498 499 500
}

void PerlModDocVisitor::closeSubBlock()
{
  leaveText();
  m_output.closeList();
}

501 502
void PerlModDocVisitor::openOther()
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
503 504 505
  // Using a secondary text stream will corrupt the perl file. Instead of
  // printing doc => [ data => [] ], it will print doc => [] data => [].
  /*
506 507
  leaveText();
  m_output.openSave();
Dimitri van Heesch's avatar
Dimitri van Heesch committed
508
  */
509 510 511 512
}

void PerlModDocVisitor::closeOther()
{
Dimitri van Heesch's avatar
Dimitri van Heesch committed
513 514 515
  // Using a secondary text stream will corrupt the perl file. Instead of
  // printing doc => [ data => [] ], it will print doc => [] data => [].
  /*
516
  QCString other;
517 518 519
  leaveText();
  m_output.closeSave(other);
  m_other += other;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
520
  */
521 522
}

523 524 525 526 527 528 529 530 531 532
void PerlModDocVisitor::visit(DocWord *w)
{
  enterText();
  m_output.addQuoted(w->word());
}

void PerlModDocVisitor::visit(DocLinkedWord *w)
{
  openItem("url");
  addLink(w->ref(), w->file(), w->anchor());
533
  m_output.addFieldQuotedString("content", w->word());
534 535 536 537 538 539 540 541 542 543 544
  closeItem();
}

void PerlModDocVisitor::visit(DocWhiteSpace *)
{
  enterText();
  m_output.add(' ');
}

void PerlModDocVisitor::visit(DocSymbol *sy)
{
545 546
  const DocSymbol::PerlSymb *res = HtmlEntityMapper::instance()->perl(sy->symbol());
  const char *accent=0;
547
  if (res-> symb)
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 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591
    switch (res->type)
    {
      case DocSymbol::Perl_string:
        enterText();
        m_output.add(res->symb);
        break;
      case DocSymbol::Perl_char:
        enterText();
        m_output.add(res->symb[0]);
        break;
      case DocSymbol::Perl_symbol:
        leaveText();
        openItem("symbol");
        m_output.addFieldQuotedString("symbol", res->symb);
        closeItem();
        break;
      default:
        switch(res->type)
        {
          case DocSymbol::Perl_umlaut:
            accent = "umlaut";
            break;
          case DocSymbol::Perl_acute:
            accent = "acute";
            break;
          case DocSymbol::Perl_grave:
            accent = "grave";
            break;
          case DocSymbol::Perl_circ:
            accent = "circ";
            break;
          case DocSymbol::Perl_slash:
            accent = "slash";
            break;
          case DocSymbol::Perl_tilde:
            accent = "tilde";
            break;
          case DocSymbol::Perl_cedilla:
            accent = "cedilla";
            break;
          case DocSymbol::Perl_ring:
            accent = "ring";
            break;
592 593
          default:
            break;
594 595
        }
        leaveText();
596 597 598 599 600 601 602 603
        if (accent)
        {
          openItem("accent");
          m_output
            .addFieldQuotedString("accent", accent)
            .addFieldQuotedChar("letter", res->symb[0]);
          closeItem();
        }
604 605
        break;
    }
606
  }
607
  else
608
  {
609
    err("perl: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(sy->symbol(),TRUE));
610
  }
611 612 613 614 615
}

void PerlModDocVisitor::visit(DocURL *u)
{
  openItem("url");
616
  m_output.addFieldQuotedString("content", u->url());
617 618 619 620 621
  closeItem();
}

void PerlModDocVisitor::visit(DocLineBreak *) { singleItem("linebreak"); }
void PerlModDocVisitor::visit(DocHorRuler *) { singleItem("hruler"); }
622

623 624
void PerlModDocVisitor::visit(DocStyleChange *s)
{
625
  const char *style = 0;
626 627
  switch (s->style())
  {
628 629 630 631 632 633 634 635
    case DocStyleChange::Bold:          style = "bold"; break;
    case DocStyleChange::Italic:        style = "italic"; break;
    case DocStyleChange::Code:          style = "code"; break;
    case DocStyleChange::Subscript:     style = "subscript"; break;
    case DocStyleChange::Superscript:   style = "superscript"; break;
    case DocStyleChange::Center:        style = "center"; break;
    case DocStyleChange::Small:         style = "small"; break;
    case DocStyleChange::Preformatted:  style = "preformatted"; break;
636 637
    case DocStyleChange::Div:           style = "div"; break;
    case DocStyleChange::Span:          style = "span"; break;
638
                                        
639
  }
640 641 642 643
  openItem("style");
  m_output.addFieldQuotedString("style", style)
    .addFieldBoolean("enable", s->enable());
  closeItem();
644 645 646 647 648
}

void PerlModDocVisitor::visit(DocVerbatim *s)
{
  const char *type = 0;
649
  switch (s->type())
650
  {
651
    case DocVerbatim::Code:
652
#if 0
653 654 655
      m_output.add("<programlisting>");
      parseCode(m_ci,s->context(),s->text(),FALSE,0);
      m_output.add("</programlisting>");
656
#endif
657
      return;
658 659 660 661
    case DocVerbatim::Verbatim:  type = "preformatted"; break;
    case DocVerbatim::HtmlOnly:  type = "htmlonly";     break;
    case DocVerbatim::RtfOnly:   type = "rtfonly";      break;
    case DocVerbatim::ManOnly:   type = "manonly";      break;
662
    case DocVerbatim::LatexOnly: type = "latexonly";    break;
663 664
    case DocVerbatim::XmlOnly:   type = "xmlonly";      break;
    case DocVerbatim::DocbookOnly: type = "docbookonly"; break;
665
    case DocVerbatim::Dot:       type = "dot";          break;
666
    case DocVerbatim::Msc:       type = "msc";          break;
667
    case DocVerbatim::PlantUML:  type = "plantuml";     break;
668 669
  }
  openItem(type);
670
  m_output.addFieldQuotedString("content", s->text());
671 672 673 674 675
  closeItem();
}

void PerlModDocVisitor::visit(DocAnchor *anc)
{
676
  QCString anchor = anc->file() + "_1" + anc->anchor();
677
  openItem("anchor");
678
  m_output.addFieldQuotedString("id", anchor);
679 680 681 682 683 684 685 686
  closeItem();
}

void PerlModDocVisitor::visit(DocInclude *inc)
{
  const char *type = 0;
  switch(inc->type())
  {
687 688 689 690 691 692 693 694 695 696 697 698
  case DocInclude::IncWithLines:
  #if 0
      { 
         m_t << "<div class=\"fragment\"><pre>";
         QFileInfo cfi( inc->file() );
         FileDef fd( cfi.dirPath(), cfi.fileName() );
         parseCode(m_ci,inc->context(),inc->text().latin1(),inc->isExample(),inc->exampleFile(), &fd);
         m_t << "</pre></div>"; 
      }
      break;
  #endif
    return;
699 700 701 702 703 704 705 706 707
  case DocInclude::Include:
#if 0
    m_output.add("<programlisting>");
    parseCode(m_ci,inc->context(),inc->text(),FALSE,0);
    m_output.add("</programlisting>");
#endif
    return;
  case DocInclude::DontInclude:	return;
  case DocInclude::HtmlInclude:	type = "htmlonly"; break;
708
  case DocInclude::LatexInclude: type = "latexonly"; break;
709
  case DocInclude::VerbInclude:	type = "preformatted"; break;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
710
  case DocInclude::Snippet: return;
711 712
  }
  openItem(type);
713
  m_output.addFieldQuotedString("content", inc->text());
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
  closeItem();
}

void PerlModDocVisitor::visit(DocIncOperator *)
{
#if 0
  //printf("DocIncOperator: type=%d first=%d, last=%d text=`%s'\n",
  //    op->type(),op->isFirst(),op->isLast(),op->text().data());
  if (op->isFirst())
  {
    m_output.add("<programlisting>");
  }
  if (op->type()!=DocIncOperator::Skip)
  {
    parseCode(m_ci,op->context(),op->text(),FALSE,0);
  }
  if (op->isLast()) 
  {
    m_output.add("</programlisting>");
  }
  else
  {
    m_output.add('\n');
  }
#endif
}

void PerlModDocVisitor::visit(DocFormula *f)
{
  openItem("formula");
744
  QCString id;
745
  id += f->id();
746
  m_output.addFieldQuotedString("id", id).addFieldQuotedString("content", f->text());
747 748 749 750 751 752 753 754 755 756 757 758 759 760 761
  closeItem();
}

void PerlModDocVisitor::visit(DocIndexEntry *)
{
#if 0
  m_output.add("<indexentry>"
	       "<primaryie>");
  m_output.addQuoted(ie->entry());
  m_output.add("</primaryie>"
	       "<secondaryie></secondaryie>"
	       "</indexentry>");
#endif
}

762 763 764 765
void PerlModDocVisitor::visit(DocSimpleSectSep *)
{
}

766 767 768 769 770 771 772 773
void PerlModDocVisitor::visit(DocCite *cite)
{
  openItem("cite");
  m_output.addFieldQuotedString("text", cite->text());
  closeItem();
}


774 775 776 777 778 779
//--------------------------------------
// visitor functions for compound nodes
//--------------------------------------

void PerlModDocVisitor::visitPre(DocAutoList *l)
{
780 781
  openItem("list");
  m_output.addFieldQuotedString("style", l->isEnumList() ? "ordered" : "itemized");
782 783 784
  openSubBlock("content");
}

785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800
void PerlModDocVisitor::visitPost(DocAutoList *)
{
  closeSubBlock();
  closeItem();
}

void PerlModDocVisitor::visitPre(DocAutoListItem *)
{
  openSubBlock();
}

void PerlModDocVisitor::visitPost(DocAutoListItem *)
{
  closeSubBlock();
}

801 802
void PerlModDocVisitor::visitPre(DocPara *)
{
803 804 805 806 807
  if (m_textblockstart)
    m_textblockstart = false;
  else
    singleItem("parbreak");
  /*
808 809
  openItem("para");
  openSubBlock("content");
810
  */
811
}
812

813 814
void PerlModDocVisitor::visitPost(DocPara *)
{
815
  /*
816 817
  closeSubBlock();
  closeItem();
818
  */
819 820 821 822 823 824 825 826 827 828 829 830
}

void PerlModDocVisitor::visitPre(DocRoot *)
{
}

void PerlModDocVisitor::visitPost(DocRoot *)
{
}

void PerlModDocVisitor::visitPre(DocSimpleSect *s)
{
831
  const char *type = 0;
832 833 834 835 836 837 838 839 840
  switch (s->type())
  {
  case DocSimpleSect::See:		type = "see"; break;
  case DocSimpleSect::Return:		type = "return"; break;
  case DocSimpleSect::Author:		type = "author"; break;
  case DocSimpleSect::Authors:		type = "authors"; break;
  case DocSimpleSect::Version:		type = "version"; break;
  case DocSimpleSect::Since:		type = "since"; break;
  case DocSimpleSect::Date:		type = "date"; break;
841
  case DocSimpleSect::Note:		type = "note"; break;
842 843 844
  case DocSimpleSect::Warning:		type = "warning"; break;
  case DocSimpleSect::Pre:		type = "pre"; break;
  case DocSimpleSect::Post:		type = "post"; break;
845
  case DocSimpleSect::Copyright:	type = "copyright"; break;
846 847 848 849
  case DocSimpleSect::Invar:		type = "invariant"; break;
  case DocSimpleSect::Remark:		type = "remark"; break;
  case DocSimpleSect::Attention:	type = "attention"; break;
  case DocSimpleSect::User:		type = "par"; break;
850
  case DocSimpleSect::Rcs:		type = "rcs"; break;
851
  case DocSimpleSect::Unknown:
852
    err("unknown simple section found\n");
853
    break;
854
  }
855 856
  leaveText();
  m_output.openHash();
857 858
  openOther();
  openSubBlock(type);
859 860 861 862
}

void PerlModDocVisitor::visitPost(DocSimpleSect *)
{
863 864
  closeSubBlock();
  closeOther();
865
  m_output.closeHash();
866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881
}

void PerlModDocVisitor::visitPre(DocTitle *)
{
  openItem("title");
  openSubBlock("content");
}

void PerlModDocVisitor::visitPost(DocTitle *)
{
  closeSubBlock();
  closeItem();
}

void PerlModDocVisitor::visitPre(DocSimpleList *) 
{
882 883
  openItem("list");
  m_output.addFieldQuotedString("style", "itemized");
884 885
  openSubBlock("content");
}
886 887 888 889 890 891 892

void PerlModDocVisitor::visitPost(DocSimpleList *)
{
  closeSubBlock();
  closeItem();
}

893 894 895 896 897
void PerlModDocVisitor::visitPre(DocSimpleListItem *) { openSubBlock(); }
void PerlModDocVisitor::visitPost(DocSimpleListItem *) { closeSubBlock(); }

void PerlModDocVisitor::visitPre(DocSection *s)
{
898
  QCString sect = QCString().sprintf("sect%d",s->level());
899 900 901 902
  openItem(sect);
  openSubBlock("content");
}

903
void PerlModDocVisitor::visitPost(DocSection *)
904
{
905 906
  closeSubBlock();
  closeItem();
907 908
}

909
void PerlModDocVisitor::visitPre(DocHtmlList *l)
910
{
911 912
  openItem("list");
  m_output.addFieldQuotedString("style", (l->type() == DocHtmlList::Ordered) ? "ordered" : "itemized");
913 914 915
  openSubBlock("content");
}

916
void PerlModDocVisitor::visitPost(DocHtmlList *)
917 918 919 920 921
{
  closeSubBlock();
  closeItem();
}

922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938
void PerlModDocVisitor::visitPre(DocHtmlListItem *) { openSubBlock(); }
void PerlModDocVisitor::visitPost(DocHtmlListItem *) { closeSubBlock(); }

//void PerlModDocVisitor::visitPre(DocHtmlPre *)
//{
//  openItem("preformatted");
//  openSubBlock("content");
//  //m_insidePre=TRUE;
//}

//void PerlModDocVisitor::visitPost(DocHtmlPre *)
//{
//  //m_insidePre=FALSE;
//  closeSubBlock();
//  closeItem();
//}

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 1129 1130 1131 1132 1133 1134
void PerlModDocVisitor::visitPre(DocHtmlDescList *)
{
#if 0
  m_output.add("<variablelist>\n");
#endif
}

void PerlModDocVisitor::visitPost(DocHtmlDescList *)
{
#if 0
  m_output.add("</variablelist>\n");
#endif
}

void PerlModDocVisitor::visitPre(DocHtmlDescTitle *)
{
#if 0
  m_output.add("<varlistentry><term>");
#endif
}

void PerlModDocVisitor::visitPost(DocHtmlDescTitle *)
{
#if 0
  m_output.add("</term></varlistentry>\n");
#endif
}

void PerlModDocVisitor::visitPre(DocHtmlDescData *)
{
#if 0
  m_output.add("<listitem>");
#endif
}

void PerlModDocVisitor::visitPost(DocHtmlDescData *)
{
#if 0
  m_output.add("</listitem>\n");
#endif
}

void PerlModDocVisitor::visitPre(DocHtmlTable *)
{
#if 0
  m_output.add("<table rows=\""); m_output.add(t->numRows());
  m_output.add("\" cols=\""); m_output.add(t->numCols()); m_output.add("\">");
#endif
}

void PerlModDocVisitor::visitPost(DocHtmlTable *)
{
#if 0
  m_output.add("</table>\n");
#endif
}

void PerlModDocVisitor::visitPre(DocHtmlRow *)
{
#if 0
  m_output.add("<row>\n");
#endif
}

void PerlModDocVisitor::visitPost(DocHtmlRow *)
{
#if 0
  m_output.add("</row>\n");
#endif
}

void PerlModDocVisitor::visitPre(DocHtmlCell *)
{
#if 0
  if (c->isHeading()) m_output.add("<entry thead=\"yes\">"); else m_output.add("<entry thead=\"no\">");
#endif
}

void PerlModDocVisitor::visitPost(DocHtmlCell *)
{
#if 0
  m_output.add("</entry>");
#endif
}

void PerlModDocVisitor::visitPre(DocHtmlCaption *)
{
#if 0
  m_output.add("<caption>");
#endif
}

void PerlModDocVisitor::visitPost(DocHtmlCaption *)
{
#if 0
  m_output.add("</caption>\n");
#endif
}

void PerlModDocVisitor::visitPre(DocInternal *)
{
#if 0
  m_output.add("<internal>");
#endif
}

void PerlModDocVisitor::visitPost(DocInternal *)
{
#if 0
  m_output.add("</internal>");
#endif
}

void PerlModDocVisitor::visitPre(DocHRef *)
{
#if 0
  m_output.add("<ulink url=\""); m_output.add(href->url()); m_output.add("\">");
#endif
}

void PerlModDocVisitor::visitPost(DocHRef *)
{
#if 0
  m_output.add("</ulink>");
#endif
}

void PerlModDocVisitor::visitPre(DocHtmlHeader *)
{
#if 0
  m_output.add("<sect"); m_output.add(header->level()); m_output.add(">");
#endif
}

void PerlModDocVisitor::visitPost(DocHtmlHeader *)
{
#if 0
  m_output.add("</sect"); m_output.add(header->level()); m_output.add(">\n");
#endif
}

void PerlModDocVisitor::visitPre(DocImage *)
{
#if 0
  m_output.add("<image type=\"");
  switch(img->type())
  {
  case DocImage::Html:  m_output.add("html"); break;
  case DocImage::Latex: m_output.add("latex"); break;
  case DocImage::Rtf:   m_output.add("rtf"); break;
  }
  m_output.add("\"");
  
  QCString baseName=img->name();
  int i;
  if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1)
  {
    baseName=baseName.right(baseName.length()-i-1);
  }
  m_output.add(" name=\""); m_output.add(baseName); m_output.add("\"");
  if (!img->width().isEmpty())
  {
    m_output.add(" width=\"");
    m_output.addQuoted(img->width());
    m_output.add("\"");
  }
  else if (!img->height().isEmpty())
  {
    m_output.add(" height=\"");
    m_output.addQuoted(img->height());
    m_output.add("\"");
  }
  m_output.add(">");
#endif
}

void PerlModDocVisitor::visitPost(DocImage *)
{
#if 0
  m_output.add("</image>");
#endif
}

void PerlModDocVisitor::visitPre(DocDotFile *)
{
#if 0
  m_output.add("<dotfile name=\""); m_output.add(df->file()); m_output.add("\">");
#endif
}

void PerlModDocVisitor::visitPost(DocDotFile *)
{
#if 0
  m_output.add("</dotfile>");
#endif
}
1135 1136 1137 1138 1139 1140 1141 1142 1143 1144
void PerlModDocVisitor::visitPre(DocMscFile *)
{
#if 0
  m_output.add("<mscfile name=\""); m_output.add(df->file()); m_output.add("\">");
#endif
}

void PerlModDocVisitor::visitPost(DocMscFile *)
{
#if 0
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1145
  m_output.add("<mscfile>");
1146 1147 1148
#endif
}

1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162
void PerlModDocVisitor::visitPre(DocDiaFile *)
{
#if 0
  m_output.add("<diafile name=\""); m_output.add(df->file()); m_output.add("\">");
#endif
}

void PerlModDocVisitor::visitPost(DocDiaFile *)
{
#if 0
  m_output.add("</diafile>");
#endif
}

1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178

void PerlModDocVisitor::visitPre(DocLink *lnk)
{
  openItem("link");
  addLink(lnk->ref(), lnk->file(), lnk->anchor());
}

void PerlModDocVisitor::visitPost(DocLink *)
{
  closeItem();
}

void PerlModDocVisitor::visitPre(DocRef *ref)
{
  openItem("ref");
  if (!ref->hasLinkText())
1179
    m_output.addFieldQuotedString("text", ref->targetTitle());
1180
  openSubBlock("content");
1181 1182 1183 1184
}

void PerlModDocVisitor::visitPost(DocRef *)
{
1185
  closeSubBlock();
1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216
  closeItem();
}

void PerlModDocVisitor::visitPre(DocSecRefItem *)
{
#if 0
  m_output.add("<tocitem id=\""); m_output.add(ref->file()); m_output.add("_1"); m_output.add(ref->anchor()); m_output.add("\">");
#endif
}

void PerlModDocVisitor::visitPost(DocSecRefItem *)
{
#if 0
  m_output.add("</tocitem>");
#endif
}

void PerlModDocVisitor::visitPre(DocSecRefList *)
{
#if 0
  m_output.add("<toclist>");
#endif
}

void PerlModDocVisitor::visitPost(DocSecRefList *)
{
#if 0
  m_output.add("</toclist>");
#endif
}

1217 1218 1219 1220 1221 1222 1223 1224 1225 1226
//void PerlModDocVisitor::visitPre(DocLanguage *l)
//{
//  openItem("language");
//  m_output.addFieldQuotedString("id", l->id());
//}
//
//void PerlModDocVisitor::visitPost(DocLanguage *)
//{
//  closeItem();
//}
1227 1228 1229 1230 1231 1232 1233 1234 1235 1236

void PerlModDocVisitor::visitPre(DocParamSect *s)
{
  leaveText();
  const char *type = 0;
  switch(s->type())
  {
  case DocParamSect::Param:     type = "params"; break;
  case DocParamSect::RetVal:    type = "retvals"; break;
  case DocParamSect::Exception: type = "exceptions"; break;
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1237
  case DocParamSect::TemplateParam: type = "templateparam"; break;
1238
  case DocParamSect::Unknown:
1239
    err("unknown parameter section found\n");
1240
    break;
1241
  }
1242 1243
  openOther();
  openSubBlock(type);
1244 1245 1246 1247
}

void PerlModDocVisitor::visitPost(DocParamSect *)
{
1248 1249
  closeSubBlock();
  closeOther();
1250 1251 1252 1253 1254 1255 1256
}

void PerlModDocVisitor::visitPre(DocParamList *pl)
{
  leaveText();
  m_output.openHash()
    .openList("parameters");
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1257 1258 1259 1260 1261
  //QStrListIterator li(pl->parameters());
  //const char *s;
  QListIterator<DocNode> li(pl->parameters());
  DocNode *param;
  for (li.toFirst();(param=li.current());++li)
1262
  {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1263 1264 1265 1266 1267 1268 1269 1270 1271
    QCString s;
    if (param->kind()==DocNode::Kind_Word)
    {
      s = ((DocWord*)param)->word(); 
    }
    else if (param->kind()==DocNode::Kind_LinkedWord)
    {
      s = ((DocLinkedWord*)param)->word(); 
    }
1272
    m_output.openHash()
1273
      .addFieldQuotedString("name", s)
1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286
      .closeHash();
  }
  m_output.closeList()
    .openList("doc");
}

void PerlModDocVisitor::visitPost(DocParamList *)
{
  leaveText();
  m_output.closeList()
    .closeHash();
}

1287
void PerlModDocVisitor::visitPre(DocXRefItem *x)
1288 1289 1290 1291 1292 1293 1294 1295 1296 1297
{
#if 0
  m_output.add("<xrefsect id=\"");
  m_output.add(x->file()); m_output.add("_1"); m_output.add(x->anchor());
  m_output.add("\">");
  m_output.add("<xreftitle>");
  m_output.addQuoted(x->title());
  m_output.add("</xreftitle>");
  m_output.add("<xrefdescription>");
#endif
1298
  if (x->title().isEmpty()) return;
1299 1300
  openItem("xrefitem");
  openSubBlock("content");
1301 1302
}

1303
void PerlModDocVisitor::visitPost(DocXRefItem *x)
1304
{
1305
  if (x->title().isEmpty()) return;
1306 1307
  closeSubBlock();
  closeItem();
1308 1309 1310 1311 1312 1313 1314 1315 1316 1317
#if 0
  m_output.add("</xrefdescription>");
  m_output.add("</xrefsect>");
#endif
}

void PerlModDocVisitor::visitPre(DocInternalRef *ref)
{
  openItem("ref");
  addLink(0,ref->file(),ref->anchor());
1318
  openSubBlock("content");
1319 1320 1321 1322
}

void PerlModDocVisitor::visitPost(DocInternalRef *)
{
1323
  closeSubBlock();
1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342
  closeItem();
}

void PerlModDocVisitor::visitPre(DocCopy *)
{
}

void PerlModDocVisitor::visitPost(DocCopy *)
{
}

void PerlModDocVisitor::visitPre(DocText *)
{
}

void PerlModDocVisitor::visitPost(DocText *)
{
}

1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354
void PerlModDocVisitor::visitPre(DocHtmlBlockQuote *)
{
  openItem("blockquote");
  openSubBlock("content");
}

void PerlModDocVisitor::visitPost(DocHtmlBlockQuote *)
{
  closeSubBlock();
  closeItem();
}

1355 1356 1357 1358 1359 1360 1361 1362
void PerlModDocVisitor::visitPre(DocVhdlFlow *)
{
}

void PerlModDocVisitor::visitPost(DocVhdlFlow *)
{
}

1363 1364 1365 1366 1367 1368 1369 1370 1371
void PerlModDocVisitor::visitPre(DocParBlock *)
{
}

void PerlModDocVisitor::visitPost(DocParBlock *)
{
}


1372
static void addTemplateArgumentList(ArgumentList *al,PerlModOutput &output,const char *)
1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383
{
  QCString indentStr;
  if (!al)
    return;
  output.openList("template_parameters");
  ArgumentListIterator ali(*al);
  Argument *a;
  for (ali.toFirst();(a=ali.current());++ali)
  {
    output.openHash();
    if (!a->type.isEmpty())
1384
      output.addFieldQuotedString("type", a->type);
1385
    if (!a->name.isEmpty())
1386 1387
      output.addFieldQuotedString("declaration_name", a->name)
	.addFieldQuotedString("definition_name", a->name);
1388
    if (!a->defval.isEmpty())
1389
      output.addFieldQuotedString("default", a->defval);
1390 1391 1392 1393 1394
    output.closeHash();
  }
  output.closeList();
}

1395 1396 1397 1398 1399 1400 1401 1402 1403
#if 0
static void addMemberTemplateLists(MemberDef *md,PerlModOutput &output)
{
  ClassDef *cd = md->getClassDef();
  const char *cname = cd ? cd->name().data() : 0;
  if (md->templateArguments()) // function template prefix
    addTemplateArgumentList(md->templateArguments(),output,cname);
}
#endif
1404 1405 1406 1407 1408 1409 1410 1411 1412 1413

static void addTemplateList(ClassDef *cd,PerlModOutput &output)
{
  addTemplateArgumentList(cd->templateArguments(),output,cd->name());
}

static void addPerlModDocBlock(PerlModOutput &output,
			    const char *name,
			    const QCString &fileName,
			    int lineNr,
1414
			    Definition *scope,
1415 1416 1417 1418 1419
			    MemberDef *md,
			    const QCString &text)
{
  QCString stext = text.stripWhiteSpace();
  if (stext.isEmpty())
1420
    output.addField(name).add("{}");
1421
  else {
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1422
    DocNode *root = validatingParseDoc(fileName,lineNr,scope,md,stext,FALSE,0);
1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439
    output.openHash(name);
    PerlModDocVisitor *visitor = new PerlModDocVisitor(output);
    root->accept(visitor);
    visitor->finish();
    output.closeHash();
    delete visitor;
    delete root;
  }
}

static const char *getProtectionName(Protection prot) 
{
  switch (prot)
  {
  case Public:    return "public";
  case Protected: return "protected";
  case Private:   return "private";
1440
  case Package:   return "package";
1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455
  }
  return 0;
}

static const char *getVirtualnessName(Specifier virt)
{
  switch(virt)
  {
  case Normal:  return "non_virtual";
  case Virtual: return "virtual";
  case Pure:    return "pure_virtual";
  }
  return 0;
}

1456 1457
static QCString pathDoxyfile;
static QCString pathDoxyExec;
1458

1459
void setPerlModDoxyfile(const QCString &qs)
1460 1461
{
  pathDoxyfile = qs;
1462
  pathDoxyExec = QDir::currentDirPath().utf8();
1463 1464 1465 1466 1467 1468
}

class PerlModGenerator
{
public:

1469
  PerlModOutput m_output;
1470

1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482
  QCString pathDoxyStructurePM;
  QCString pathDoxyDocsTex;
  QCString pathDoxyFormatTex;
  QCString pathDoxyLatexTex;
  QCString pathDoxyLatexDVI;
  QCString pathDoxyLatexPDF;
  QCString pathDoxyStructureTex;
  QCString pathDoxyDocsPM;
  QCString pathDoxyLatexPL;
  QCString pathDoxyLatexStructurePL;
  QCString pathDoxyRules;
  QCString pathMakefile;
1483

1484 1485 1486 1487 1488 1489 1490 1491 1492 1493
  inline PerlModGenerator(bool pretty) : m_output(pretty) { }

  void generatePerlModForMember(MemberDef *md, Definition *);
  void generatePerlModSection(Definition *d, MemberList *ml,
			      const char *name, const char *header=0);
  void addListOfAllMembers(ClassDef *cd);
  void generatePerlModForClass(ClassDef *cd);
  void generatePerlModForNamespace(NamespaceDef *nd);
  void generatePerlModForFile(FileDef *fd);
  void generatePerlModForGroup(GroupDef *gd);
1494
  void generatePerlModForPage(PageDef *pi);
1495 1496 1497 1498 1499
  
  bool createOutputFile(QFile &f, const char *s);
  bool createOutputDir(QDir &perlModDir);
  bool generateDoxyLatexTex();
  bool generateDoxyFormatTex();
1500
  bool generateDoxyStructurePM();
1501
  bool generateDoxyLatexPL();
1502
  bool generateDoxyLatexStructurePL();
1503 1504 1505 1506 1507 1508 1509 1510
  bool generateDoxyRules();
  bool generateMakefile();
  bool generatePerlModOutput();

  void generate();
};

void PerlModGenerator::generatePerlModForMember(MemberDef *md,Definition *)
1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528
{
  // + declaration/definition arg lists
  // + reimplements
  // + reimplementedBy
  // + exceptions
  // + const/volatile specifiers
  // - examples
  // - source definition
  // - source references
  // - source referenced by
  // - body code
  // - template arguments
  //     (templateArguments(), definitionTemplateParameterLists())
 
  QCString memType;
  bool isFunc=FALSE;
  switch (md->memberType())
  {
1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541
  case MemberType_Define:      memType="define";    break;
  case MemberType_EnumValue:   memType="enumvalue"; break;
  case MemberType_Property:    memType="property";  break;
  case MemberType_Variable:    memType="variable";  break;
  case MemberType_Typedef:     memType="typedef";   break;
  case MemberType_Enumeration: memType="enum";      break;
  case MemberType_Function:    memType="function";  isFunc=TRUE; break;
  case MemberType_Signal:      memType="signal";    isFunc=TRUE; break;
  //case MemberType_Prototype:   memType="prototype"; isFunc=TRUE; break;
  case MemberType_Friend:      memType="friend";    isFunc=TRUE; break;
  case MemberType_DCOP:        memType="dcop";      isFunc=TRUE; break;
  case MemberType_Slot:        memType="slot";      isFunc=TRUE; break;
  case MemberType_Event:       memType="event";     break;
1542 1543
  case MemberType_Interface:   memType="interface"; break;
  case MemberType_Service:     memType="service";   break;
1544 1545
  }

1546
  m_output.openHash()
1547 1548 1549 1550 1551 1552
    .addFieldQuotedString("kind", memType)
    .addFieldQuotedString("name", md->name())
    .addFieldQuotedString("virtualness", getVirtualnessName(md->virtualness()))
    .addFieldQuotedString("protection", getProtectionName(md->protection()))
    .addFieldBoolean("static", md->isStatic());
  
1553 1554
  addPerlModDocBlock(m_output,"brief",md->getDefFileName(),md->getDefLine(),md->getOuterScope(),md,md->briefDescription());
  addPerlModDocBlock(m_output,"detailed",md->getDefFileName(),md->getDefLine(),md->getOuterScope(),md,md->documentation());
1555 1556
  if (md->memberType()!=MemberType_Define &&
      md->memberType()!=MemberType_Enumeration)
1557
    m_output.addFieldQuotedString("type", md->typeString());
1558
  
1559
  ArgumentList *al = md->argumentList();
1560 1561
  if (isFunc) //function
  {
1562 1563
    m_output.addFieldBoolean("const", al!=0 && al->constSpecifier)
      .addFieldBoolean("volatile", al!=0 && al->volatileSpecifier);
1564

1565
    m_output.openList("parameters");
1566 1567 1568
    ArgumentList *declAl = md->declArgumentList();
    ArgumentList *defAl  = md->argumentList();
    if (declAl && declAl->count()>0)
1569 1570 1571 1572 1573 1574 1575
    {
      ArgumentListIterator declAli(*declAl);
      ArgumentListIterator defAli(*defAl);
      Argument *a;
      for (declAli.toFirst();(a=declAli.current());++declAli)
      {
	Argument *defArg = defAli.current();
1576
	m_output.openHash();
1577 1578

	if (!a->name.isEmpty())
1579
	  m_output.addFieldQuotedString("declaration_name", a->name);
1580 1581

	if (defArg && !defArg->name.isEmpty() && defArg->name!=a->name)
1582
	  m_output.addFieldQuotedString("definition_name", defArg->name);
1583 1584

	if (!a->type.isEmpty())
1585
	  m_output.addFieldQuotedString("type", a->type);
1586 1587

	if (!a->array.isEmpty())
1588
	  m_output.addFieldQuotedString("array", a->array);
1589 1590

	if (!a->defval.isEmpty())
1591
	  m_output.addFieldQuotedString("default_value", a->defval);
1592 1593

	if (!a->attrib.isEmpty())
1594
	  m_output.addFieldQuotedString("attributes", a->attrib);
1595
	
1596
	m_output.closeHash();
1597 1598 1599
	if (defArg) ++defAli;
      }
    }
1600
    m_output.closeList();
1601
  }
1602
  else if (md->memberType()==MemberType_Define &&
1603 1604
	   md->argsString()!=0) // define
  {
1605
    m_output.openList("parameters");
1606
    ArgumentListIterator ali(*al);
1607 1608 1609
    Argument *a;
    for (ali.toFirst();(a=ali.current());++ali)
    {
1610
      m_output.openHash()
1611
	.addFieldQuotedString("name", a->type)
1612 1613
	.closeHash();
    }
1614
    m_output.closeList();
1615
  }
Dimitri van Heesch's avatar
Dimitri van Heesch committed
1616 1617 1618 1619 1620
  else if (md->argsString()!=0) 
  {
    m_output.addFieldQuotedString("arguments", md->argsString());
  }

1621
  if (!md->initializer().isEmpty())
1622
    m_output.addFieldQuotedString("initializer", md->initializer());
1623 1624
  
  if (md->excpString())
1625
    m_output.addFieldQuotedString("exceptions", md->excpString());
1626
  
1627
  if (md->memberType()==MemberType_Enumeration) // enum
1628
  {
1629 1630
    MemberList *enumFields = md->enumFieldList();
    if (enumFields)
1631
    {
1632
      m_output.openList("values");
1633
      MemberListIterator emli(*enumFields);
1634 1635 1636
      MemberDef *emd;
      for (emli.toFirst();(emd=emli.current());++emli)
      {
1637
	m_output.openHash()
1638
	  .addFieldQuotedString("name", emd->name());
1639 1640
	 
	if (!emd->initializer().isEmpty())
1641
	  m_output.addFieldQuotedString("initializer", emd->initializer());
1642

1643
	addPerlModDocBlock(m_output,"brief",emd->getDefFileName(),emd->getDefLine(),emd->getOuterScope(),emd,emd->briefDescription());
1644

1645
	addPerlModDocBlock(m_output,"detailed",emd->getDefFileName(),emd->getDefLine(),emd->getOuterScope(),emd,emd->documentation());
1646

1647
	m_output.closeHash();
1648
      }
1649
      m_output.closeList();
1650 1651 1652 1653 1654
    }
  }

  MemberDef *rmd = md->reimplements();
  if (rmd)
1655
    m_output.openHash("reimplements")
1656
      .addFieldQuotedString("name", rmd->name())
1657 1658
      .closeHash();

1659 1660
  MemberList *rbml = md->reimplementedBy();
  if (rbml)
1661 1662
  {
    MemberListIterator mli(*rbml);
1663
    m_output.openList("reimplemented_by");
1664
    for (mli.toFirst();(rmd=mli.current());++mli)
1665
      m_output.openHash()
1666
	.addFieldQuotedString("name", rmd->name())
1667
	.closeHash();
1668
    m_output.closeList();
1669 1670
  }
  
1671
  m_output.closeHash();
1672 1673
}

1674 1675
void PerlModGenerator::generatePerlModSection(Definition *d,
					      MemberList *ml,const char *name,const char *header)
1676
{
1677
  if (ml==0) return; // empty list
1678

1679
  m_output.openHash(name);
1680 1681

  if (header)
1682
    m_output.addFieldQuotedString("header", header);
1683
  
1684
  m_output.openList("members");
1685 1686 1687 1688
  MemberListIterator mli(*ml);
  MemberDef *md;
  for (mli.toFirst();(md=mli.current());++mli)
  {
1689
    generatePerlModForMember(md,d);
1690
  }
1691
  m_output.closeList()
1692 1693 1694
    .closeHash();
}

1695
void PerlModGenerator::addListOfAllMembers(ClassDef *cd)
1696
{
1697
  m_output.openList("all_members");
1698
  if (cd->memberNameInfoSDict())
1699
  {
1700 1701 1702
    MemberNameInfoSDict::Iterator mnii(*cd->memberNameInfoSDict());
    MemberNameInfo *mni;
    for (mnii.toFirst();(mni=mnii.current());++mnii)
1703
    {
1704 1705 1706 1707 1708 1709 1710 1711
      MemberNameInfoIterator mii(*mni);
      MemberInfo *mi;
      for (mii.toFirst();(mi=mii.current());++mii)
      {
        MemberDef *md=mi->memberDef;
        ClassDef  *cd=md->getClassDef();
        Definition *d=md->getGroupDef();
        if (d==0) d = cd;
1712

1713 1714 1715 1716
        m_output.openHash()
          .addFieldQuotedString("name", md->name())
          .addFieldQuotedString("virtualness", getVirtualnessName(md->virtualness()))
          .addFieldQuotedString("protection", getProtectionName(mi->prot));
1717

1718 1719
        if (!mi->ambiguityResolutionScope.isEmpty())
          m_output.addFieldQuotedString("ambiguity_scope", mi->ambiguityResolutionScope);
1720

1721 1722 1723
        m_output.addFieldQuotedString("scope", cd->name())
          .closeHash();
      }
1724 1725
    }
  }
1726
  m_output.closeList();
1727 1728
}

1729
void PerlModGenerator::generatePerlModForClass(ClassDef *cd)
1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750
{
  // + 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->name().find('@')!=-1) return; // skip anonymous compounds.
  if (cd->templateMaster()!=0)  return; // skip generated template instances.

1751
  m_output.openHash()
1752
    .addFieldQuotedString("name", cd->name());
1753
  
1754
  if (cd->baseClasses())
1755
  {
1756
    m_output.openList("base");
1757 1758 1759
    BaseClassListIterator bcli(*cd->baseClasses());
    BaseClassDef *bcd;
    for (bcli.toFirst();(bcd=bcli.current());++bcli)
1760
      m_output.openHash()
1761 1762 1763
	.addFieldQuotedString("name", bcd->classDef->displayName())
	.addFieldQuotedString("virtualness", getVirtualnessName(bcd->virt))
	.addFieldQuotedString("protection", getProtectionName(bcd->prot))
1764
	.closeHash();
1765
    m_output.closeList();
1766 1767
  }

1768
  if (cd->subClasses())
1769
  {
1770
    m_output.openList("derived");
1771
    BaseClassListIterator bcli(*cd->subClasses());
1772 1773
    BaseClassDef *bcd;
    for (bcli.toFirst();(bcd=bcli.current());++bcli)
1774
      m_output.openHash()
1775 1776 1777
	.addFieldQuotedString("name", bcd->classDef->displayName())
	.addFieldQuotedString("virtualness", getVirtualnessName(bcd->virt))
	.addFieldQuotedString("protection", getProtectionName(bcd->prot))
1778
	.closeHash();
1779
    m_output.closeList();
1780 1781
  }

1782
  ClassSDict *cl = cd->getClassSDict();
1783 1784
  if (cl)
  {
1785
    m_output.openList("inner");
1786 1787 1788
    ClassSDict::Iterator cli(*cl);
    ClassDef *cd;
    for (cli.toFirst();(cd=cli.current());++cli)
1789
      m_output.openHash()
1790
	.addFieldQuotedString("name", cd->name())
1791
	.closeHash();
1792
    m_output.closeList();
1793 1794 1795 1796 1797 1798 1799 1800 1801
  }

  IncludeInfo *ii=cd->includeInfo();
  if (ii)
  {
    QCString nm = ii->includeName;
    if (nm.isEmpty() && ii->fileDef) nm = ii->fileDef->docName();
    if (!nm.isEmpty())
    {
1802
      m_output.openHash("includes");
1803 1804 1805 1806
#if 0
      if (ii->fileDef && !ii->fileDef->isReference()) // TODO: support external references
        t << " id=\"" << ii->fileDef->getOutputFileBase() << "\"";
#endif
1807
      m_output.addFieldBoolean("local", ii->local)
1808
	.addFieldQuotedString("name", nm)
1809 1810 1811 1812
	.closeHash();
    }
  }

1813 1814
  addTemplateList(cd,m_output);
  addListOfAllMembers(cd);
1815 1816 1817 1818 1819 1820 1821
  if (cd->getMemberGroupSDict())
  {
    MemberGroupSDict::Iterator mgli(*cd->getMemberGroupSDict());
    MemberGroup *mg;
    for (;(mg=mgli.current());++mgli)
      generatePerlModSection(cd,mg->members(),"user_defined",mg->header());
  }
1822

1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845
  generatePerlModSection(cd,cd->getMemberList(MemberListType_pubTypes),"public_typedefs");
  generatePerlModSection(cd,cd->getMemberList(MemberListType_pubMethods),"public_methods");
  generatePerlModSection(cd,cd->getMemberList(MemberListType_pubAttribs),"public_members");
  generatePerlModSection(cd,cd->getMemberList(MemberListType_pubSlots),"public_slots");
  generatePerlModSection(cd,cd->getMemberList(MemberListType_signals),"signals");
  generatePerlModSection(cd,cd->getMemberList(MemberListType_dcopMethods),"dcop_methods");
  generatePerlModSection(cd,cd->getMemberList(MemberListType_properties),"properties");
  generatePerlModSection(cd,cd->getMemberList(MemberListType_pubStaticMethods),"public_static_methods");
  generatePerlModSection(cd,cd->getMemberList(MemberListType_pubStaticAttribs),"public_static_members");
  generatePerlModSection(cd,cd->getMemberList(MemberListType_proTypes),"protected_typedefs");
  generatePerlModSection(cd,cd->getMemberList(MemberListType_proMethods),"protected_methods");
  generatePerlModSection(cd,cd->getMemberList(MemberListType_proAttribs),"protected_members");
  generatePerlModSection(cd,cd->getMemberList(MemberListType_proSlots),"protected_slots");
  generatePerlModSection(cd,cd->getMemberList(MemberListType_proStaticMethods),"protected_static_methods");
  generatePerlModSection(cd,cd->getMemberList(MemberListType_proStaticAttribs),"protected_static_members");
  generatePerlModSection(cd,cd->getMemberList(MemberListType_priTypes),"private_typedefs");
  generatePerlModSection(cd,cd->getMemberList(MemberListType_priMethods),"private_methods");
  generatePerlModSection(cd,cd->getMemberList(MemberListType_priAttribs),"private_members");
  generatePerlModSection(cd,cd->getMemberList(MemberListType_priSlots),"private_slots");
  generatePerlModSection(cd,cd->getMemberList(MemberListType_priStaticMethods),"private_static_methods");
  generatePerlModSection(cd,cd->getMemberList(MemberListType_priStaticAttribs),"private_static_members");
  generatePerlModSection(cd,cd->getMemberList(MemberListType_friends),"friend_methods");
  generatePerlModSection(cd,cd->getMemberList(MemberListType_related),"related_methods");
1846

1847 1848
  addPerlModDocBlock(m_output,"brief",cd->getDefFileName(),cd->getDefLine(),cd,0,cd->briefDescription());
  addPerlModDocBlock(m_output,"detailed",cd->getDefFileName(),cd->getDefLine(),cd,0,cd->documentation());
1849 1850 1851 1852 1853 1854

#if 0
  DotClassGraph inheritanceGraph(cd,DotClassGraph::Inheritance);
  if (!inheritanceGraph.isTrivial())
  {
    t << "    <inheritancegraph>" << endl;
1855
    inheritanceGraph.writePerlMod(t);
1856 1857 1858 1859 1860 1861
    t << "    </inheritancegraph>" << endl;
  }
  DotClassGraph collaborationGraph(cd,DotClassGraph::Implementation);
  if (!collaborationGraph.isTrivial())
  {
    t << "    <collaborationgraph>" << endl;
1862
    collaborationGraph.writePerlMod(t);
1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875
    t << "    </collaborationgraph>" << endl;
  }
  t << "    <location file=\"" 
    << cd->getDefFileName() << "\" line=\"" 
    << cd->getDefLine() << "\"";
    if (cd->getStartBodyLine()!=-1)
    {
      t << " bodystart=\"" << cd->getStartBodyLine() << "\" bodyend=\"" 
        << cd->getEndBodyLine() << "\"";
    }
  t << "/>" << endl;
#endif

1876
  m_output.closeHash();
1877 1878
}

1879
void PerlModGenerator::generatePerlModForNamespace(NamespaceDef *nd)
1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891
{
  // + 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()) return; // skip external references

1892
  m_output.openHash()
1893
    .addFieldQuotedString("name", nd->name());
1894
  
1895
  ClassSDict *cl = nd->getClassSDict();
1896 1897
  if (cl)
  {
1898
    m_output.openList("classes");
1899 1900 1901
    ClassSDict::Iterator cli(*cl);
    ClassDef *cd;
    for (cli.toFirst();(cd=cli.current());++cli)
1902
      m_output.openHash()
1903
	.addFieldQuotedString("name", cd->name())
1904
	.closeHash();
1905
    m_output.closeList();
1906 1907
  }

1908
  NamespaceSDict *nl = nd->getNamespaceSDict();
1909 1910
  if (nl)
  {
1911
    m_output.openList("namespaces");
1912 1913 1914
    NamespaceSDict::Iterator nli(*nl);
    NamespaceDef *nd;
    for (nli.toFirst();(nd=nli.current());++nli)
1915
      m_output.openHash()
1916
	.addFieldQuotedString("name", nd->name())
1917
	.closeHash();
1918
    m_output.closeList();
1919 1920
  }

1921 1922 1923 1924 1925 1926 1927
  if (nd->getMemberGroupSDict())
  {
    MemberGroupSDict::Iterator mgli(*nd->getMemberGroupSDict());
    MemberGroup *mg;
    for (;(mg=mgli.current());++mgli)
      generatePerlModSection(nd,mg->members(),"user-defined",mg->header());
  }
1928

1929 1930 1931 1932 1933 1934
  generatePerlModSection(nd,nd->getMemberList(MemberListType_decDefineMembers),"defines");
  generatePerlModSection(nd,nd->getMemberList(MemberListType_decProtoMembers),"prototypes");
  generatePerlModSection(nd,nd->getMemberList(MemberListType_decTypedefMembers),"typedefs");
  generatePerlModSection(nd,nd->getMemberList(MemberListType_decEnumMembers),"enums");
  generatePerlModSection(nd,nd->getMemberList(MemberListType_decFuncMembers),"functions");
  generatePerlModSection(nd,nd->getMemberList(MemberListType_decVarMembers),"variables");
1935

1936 1937
  addPerlModDocBlock(m_output,"brief",nd->getDefFileName(),nd->getDefLine(),0,0,nd->briefDescription());
  addPerlModDocBlock(m_output,"detailed",nd->getDefFileName(),nd->getDefLine(),0,0,nd->documentation());
1938

1939
  m_output.closeHash();
1940 1941
}

1942
void PerlModGenerator::generatePerlModForFile(FileDef *fd)
1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959
{
  // + 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;

1960
  m_output.openHash()
1961
    .addFieldQuotedString("name", fd->name());
1962 1963
  
  IncludeInfo *inc;
1964
  m_output.openList("includes");
1965
  if (fd->includeFileList())
1966
  {
1967 1968
    QListIterator<IncludeInfo> ili1(*fd->includeFileList());
    for (ili1.toFirst();(inc=ili1.current());++ili1)
1969
    {
1970 1971 1972 1973 1974 1975 1976
      m_output.openHash()
        .addFieldQuotedString("name", inc->includeName);
      if (inc->fileDef && !inc->fileDef->isReference())
      {
        m_output.addFieldQuotedString("ref", inc->fileDef->getOutputFileBase());
      }
      m_output.closeHash();
1977 1978
    }
  }
1979
  m_output.closeList();
1980
  
1981
  m_output.openList("included_by");
1982
  if (fd->includedByFileList())
1983
  {
1984 1985
    QListIterator<IncludeInfo> ili2(*fd->includedByFileList());
    for (ili2.toFirst();(inc=ili2.current());++ili2)
1986
    {
1987 1988 1989 1990 1991 1992 1993
      m_output.openHash()
        .addFieldQuotedString("name", inc->includeName);
      if (inc->fileDef && !inc->fileDef->isReference())
      {
        m_output.addFieldQuotedString("ref", inc->fileDef->getOutputFileBase());
      }
      m_output.closeHash();
1994 1995
    }
  }
1996
  m_output.closeList();
1997
  
1998 1999 2000 2001 2002 2003
  generatePerlModSection(fd,fd->getMemberList(MemberListType_decDefineMembers),"defines");
  generatePerlModSection(fd,fd->getMemberList(MemberListType_decProtoMembers),"prototypes");
  generatePerlModSection(fd,fd->getMemberList(MemberListType_decTypedefMembers),"typedefs");
  generatePerlModSection(fd,fd->getMemberList(MemberListType_decEnumMembers),"enums");
  generatePerlModSection(fd,fd->getMemberList(MemberListType_decFuncMembers),"functions");
  generatePerlModSection(fd,fd->getMemberList(MemberListType_decVarMembers),"variables");
2004

2005 2006
  addPerlModDocBlock(m_output,"brief",fd->getDefFileName(),fd->getDefLine(),0,0,fd->briefDescription());
  addPerlModDocBlock(m_output,"detailed",fd->getDefFileName(),fd->getDefLine(),0,0,fd->documentation());
2007

2008
  m_output.closeHash();
2009 2010
}

2011
void PerlModGenerator::generatePerlModForGroup(GroupDef *gd)
2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026
{
  // + members
  // + member groups
  // + files
  // + classes
  // + namespaces
  // - packages
  // + pages
  // + child groups
  // - examples
  // + brief description
  // + detailed description

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

2027
  m_output.openHash()
2028 2029
    .addFieldQuotedString("name", gd->name())
    .addFieldQuotedString("title", gd->groupTitle());
2030 2031 2032 2033

  FileList *fl = gd->getFiles();
  if (fl)
  {
2034
    m_output.openList("files");
2035
    QListIterator<FileDef> fli(*fl);
2036
    FileDef *fd;
2037
    for (fli.toFirst();(fd=fli.current());++fli)
2038
      m_output.openHash()
2039
	.addFieldQuotedString("name", fd->name())
2040
	.closeHash();
2041
    m_output.closeList();
2042 2043 2044 2045 2046
  }

  ClassSDict *cl = gd->getClasses();
  if (cl)
  {
2047
    m_output.openList("classes");
2048 2049 2050
    ClassSDict::Iterator cli(*cl);
    ClassDef *cd;
    for (cli.toFirst();(cd=cli.current());++cli)
2051
      m_output.openHash()
2052
	.addFieldQuotedString("name", cd->name())
2053
	.closeHash();
2054
    m_output.closeList();
2055 2056
  }

2057
  NamespaceSDict *nl = gd->getNamespaces();
2058 2059
  if (nl)
  {
2060
    m_output.openList("namespaces");
2061
    NamespaceSDict::Iterator nli(*nl);
2062 2063
    NamespaceDef *nd;
    for (nli.toFirst();(nd=nli.current());++nli)
2064
      m_output.openHash()
2065
	.addFieldQuotedString("name", nd->name())
2066
	.closeHash();
2067
    m_output.closeList();
2068 2069 2070 2071 2072
  }

  PageSDict *pl = gd->getPages();
  if (pl)
  {
2073
    m_output.openList("pages");
2074
    PageSDict::Iterator pli(*pl);
2075 2076
    PageDef *pd;
    for (pli.toFirst();(pd=pli.current());++pli)
2077
      m_output.openHash()
2078
	.addFieldQuotedString("title", pd->title())
2079
	.closeHash();
2080
    m_output.closeList();
2081 2082 2083 2084 2085
  }

  GroupList *gl = gd->getSubGroups();
  if (gl)
  {
2086
    m_output.openList("groups");
2087 2088 2089
    GroupListIterator gli(*gl);
    GroupDef *sgd;
    for (gli.toFirst();(sgd=gli.current());++gli)
2090
      m_output.openHash()
2091
	.addFieldQuotedString("title", sgd->groupTitle())
2092
	.closeHash();
2093
    m_output.closeList();
2094 2095
  }

2096 2097 2098 2099 2100 2101 2102
  if (gd->getMemberGroupSDict())
  {
    MemberGroupSDict::Iterator mgli(*gd->getMemberGroupSDict());
    MemberGroup *mg;
    for (;(mg=mgli.current());++mgli)
      generatePerlModSection(gd,mg->members(),"user-defined",mg->header());
  }
2103

2104 2105 2106 2107 2108 2109
  generatePerlModSection(gd,gd->getMemberList(MemberListType_decDefineMembers),"defines");
  generatePerlModSection(gd,gd->getMemberList(MemberListType_decProtoMembers),"prototypes");
  generatePerlModSection(gd,gd->getMemberList(MemberListType_decTypedefMembers),"typedefs");
  generatePerlModSection(gd,gd->getMemberList(MemberListType_decEnumMembers),"enums");
  generatePerlModSection(gd,gd->getMemberList(MemberListType_decFuncMembers),"functions");
  generatePerlModSection(gd,gd->getMemberList(MemberListType_decVarMembers),"variables");
2110

2111 2112
  addPerlModDocBlock(m_output,"brief",gd->getDefFileName(),gd->getDefLine(),0,0,gd->briefDescription());
  addPerlModDocBlock(m_output,"detailed",gd->getDefFileName(),gd->getDefLine(),0,0,gd->documentation());
2113

2114
  m_output.closeHash();
2115 2116
}

2117
void PerlModGenerator::generatePerlModForPage(PageDef *pd)
2118 2119 2120 2121 2122
{
  // + name
  // + title
  // + documentation

2123
  if (pd->isReference()) return;
2124

2125
  m_output.openHash()
2126
    .addFieldQuotedString("name", pd->name());
2127
    
2128
  SectionInfo *si = Doxygen::sectionDict->find(pd->name());
2129
  if (si)
2130
    m_output.addFieldQuotedString("title4", filterTitle(si->title));
2131

2132
  addPerlModDocBlock(m_output,"detailed",pd->docFile(),pd->docLine(),0,0,pd->documentation());
2133
  m_output.closeHash();
2134 2135
}

2136
bool PerlModGenerator::generatePerlModOutput()
2137
{
2138 2139 2140 2141
  QFile outputFile;
  if (!createOutputFile(outputFile, pathDoxyDocsPM))
    return false;
  
Dimitri van Heesch's avatar
Dimitri van Heesch committed
2142
  FTextStream outputTextStream(&outputFile);
2143
  PerlModOutputStream outputStream(&outputTextStream);
2144 2145
  m_output.setPerlModOutputStream(&outputStream);
  m_output.add("$doxydocs=").openHash();
2146
  
2147
  m_output.openList("classes");
2148
  ClassSDict::Iterator cli(*Doxygen::classSDict);
2149 2150
  ClassDef *cd;
  for (cli.toFirst();(cd=cli.current());++cli)
2151 2152
    generatePerlModForClass(cd);
  m_output.closeList();
2153

2154
  m_output.openList("namespaces");
2155
  NamespaceSDict::Iterator nli(*Doxygen::namespaceSDict);
2156 2157
  NamespaceDef *nd;
  for (nli.toFirst();(nd=nli.current());++nli)
2158 2159
    generatePerlModForNamespace(nd);
  m_output.closeList();
2160

2161
  m_output.openList("files");
2162
  FileNameListIterator fnli(*Doxygen::inputNameList);
2163 2164 2165 2166 2167 2168
  FileName *fn;
  for (;(fn=fnli.current());++fnli)
  {
    FileNameIterator fni(*fn);
    FileDef *fd;
    for (;(fd=fni.current());++fni)
2169
      generatePerlModForFile(fd);
2170
  }
2171
  m_output.closeList();
2172

2173
  m_output.openList("groups");
2174
  GroupSDict::Iterator gli(*Doxygen::groupSDict);
2175 2176
  GroupDef *gd;
  for (;(gd=gli.current());++gli)
2177
  {
2178
    generatePerlModForGroup(gd);
2179
  }
2180
  m_output.closeList();
2181

2182
  m_output.openList("pages");
2183
  PageSDict::Iterator pdi(*Doxygen::pageSDict);
2184 2185 2186 2187 2188
  PageDef *pd=0;
  for (pdi.toFirst();(pd=pdi.current());++pdi)
  {
    generatePerlModForPage(pd);
  }
2189
  if (Doxygen::mainPage)
2190
  {
2191
    generatePerlModForPage(Doxygen::mainPage);
2192
  }
2193
  m_output.closeList();
2194

2195
  m_output.closeHash().add(";\n1;\n");
2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208
  return true;
}

bool PerlModGenerator::createOutputFile(QFile &f, const char *s)
{
  f.setName(s);
  if (!f.open(IO_WriteOnly))
  {
    err("Cannot open file %s for writing!\n", s);
    return false;
  }
  return true;
}
2209

2210 2211
bool PerlModGenerator::createOutputDir(QDir &perlModDir)
{
2212 2213 2214
  QCString outputDirectory = Config_getString("OUTPUT_DIRECTORY");
  if (outputDirectory.isEmpty())
  {
2215
    outputDirectory=QDir::currentDirPath().utf8();
2216 2217 2218 2219 2220 2221 2222 2223 2224
  }
  else
  {
    QDir dir(outputDirectory);
    if (!dir.exists())
    {
      dir.setPath(QDir::currentDirPath());
      if (!dir.mkdir(outputDirectory))
      {
2225
	err("tag OUTPUT_DIRECTORY: Output directory `%s' does not "
2226 2227 2228
	    "exist and cannot be created\n",outputDirectory.data());
	exit(1);
      }
2229
      else
2230
      {
2231
	msg("Notice: Output directory `%s' does not exist. "
2232 2233 2234 2235
	    "I have created it for you.\n", outputDirectory.data());
      }
      dir.cd(outputDirectory);
    }
2236
    outputDirectory=dir.absPath().utf8();
2237 2238 2239 2240 2241 2242 2243 2244 2245
  }

  QDir dir(outputDirectory);
  if (!dir.exists())
  {
    dir.setPath(QDir::currentDirPath());
    if (!dir.mkdir(outputDirectory))
    {
      err("Cannot create directory %s\n",outputDirectory.data());
2246
      return false;
2247 2248 2249
    }
  }
 
2250 2251
  perlModDir.setPath(outputDirectory+"/perlmod");
  if (!perlModDir.exists() && !perlModDir.mkdir(outputDirectory+"/perlmod"))
2252 2253
  {
    err("Could not create perlmod directory in %s\n",outputDirectory.data());
2254 2255 2256 2257 2258
    return false;
  }
  return true;
}

2259
bool PerlModGenerator::generateDoxyStructurePM()
2260 2261
{
  QFile doxyModelPM;
2262
  if (!createOutputFile(doxyModelPM, pathDoxyStructurePM))
2263 2264
    return false;

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2265
  FTextStream doxyModelPMStream(&doxyModelPM);
2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321
  doxyModelPMStream << 
    "sub memberlist($) {\n"
    "    my $prefix = $_[0];\n"
    "    return\n"
    "\t[ \"hash\", $prefix . \"s\",\n"
    "\t  {\n"
    "\t    members =>\n"
    "\t      [ \"list\", $prefix . \"List\",\n"
    "\t\t[ \"hash\", $prefix,\n"
    "\t\t  {\n"
    "\t\t    kind => [ \"string\", $prefix . \"Kind\" ],\n"
    "\t\t    name => [ \"string\", $prefix . \"Name\" ],\n"
    "\t\t    static => [ \"string\", $prefix . \"Static\" ],\n"
    "\t\t    virtualness => [ \"string\", $prefix . \"Virtualness\" ],\n"
    "\t\t    protection => [ \"string\", $prefix . \"Protection\" ],\n"
    "\t\t    type => [ \"string\", $prefix . \"Type\" ],\n"
    "\t\t    parameters =>\n"
    "\t\t      [ \"list\", $prefix . \"Params\",\n"
    "\t\t\t[ \"hash\", $prefix . \"Param\",\n"
    "\t\t\t  {\n"
    "\t\t\t    declaration_name => [ \"string\", $prefix . \"ParamName\" ],\n"
    "\t\t\t    type => [ \"string\", $prefix . \"ParamType\" ],\n"
    "\t\t\t  },\n"
    "\t\t\t],\n"
    "\t\t      ],\n"
    "\t\t    detailed =>\n"
    "\t\t      [ \"hash\", $prefix . \"Detailed\",\n"
    "\t\t\t{\n"
    "\t\t\t  doc => [ \"doc\", $prefix . \"DetailedDoc\" ],\n"
    "\t\t\t  return => [ \"doc\", $prefix . \"Return\" ],\n"
    "\t\t\t  see => [ \"doc\", $prefix . \"See\" ],\n"
    "\t\t\t  params =>\n"
    "\t\t\t    [ \"list\", $prefix . \"PDBlocks\",\n"
    "\t\t\t      [ \"hash\", $prefix . \"PDBlock\",\n"
    "\t\t\t\t{\n"
    "\t\t\t\t  parameters =>\n"
    "\t\t\t\t    [ \"list\", $prefix . \"PDParams\",\n"
    "\t\t\t\t      [ \"hash\", $prefix . \"PDParam\",\n"
    "\t\t\t\t\t{\n"
    "\t\t\t\t\t  name => [ \"string\", $prefix . \"PDParamName\" ],\n"
    "\t\t\t\t\t},\n"
    "\t\t\t\t      ],\n"
    "\t\t\t\t    ],\n"
    "\t\t\t\t  doc => [ \"doc\", $prefix . \"PDDoc\" ],\n"
    "\t\t\t\t},\n"
    "\t\t\t      ],\n"
    "\t\t\t    ],\n"
    "\t\t\t},\n"
    "\t\t      ],\n"
    "\t\t  },\n"
    "\t\t],\n"
    "\t      ],\n"
    "\t  },\n"
    "\t];\n"
    "}\n"
    "\n"
2322
    "$doxystructure =\n"
2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341
    "    [ \"hash\", \"Root\",\n"
    "      {\n"
    "\tfiles =>\n"
    "\t  [ \"list\", \"Files\",\n"
    "\t    [ \"hash\", \"File\",\n"
    "\t      {\n"
    "\t\tname => [ \"string\", \"FileName\" ],\n"
    "\t\ttypedefs => memberlist(\"FileTypedef\"),\n"
    "\t\tvariables => memberlist(\"FileVariable\"),\n"
    "\t\tfunctions => memberlist(\"FileFunction\"),\n"
    "\t\tdetailed =>\n"
    "\t\t  [ \"hash\", \"FileDetailed\",\n"
    "\t\t    {\n"
    "\t\t      doc => [ \"doc\", \"FileDetailedDoc\" ],\n"
    "\t\t    },\n"
    "\t\t  ],\n"
    "\t      },\n"
    "\t    ],\n"
    "\t  ],\n"
2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355
    "\tpages =>\n"
    "\t  [ \"list\", \"Pages\",\n"
    "\t    [ \"hash\", \"Page\",\n"
    "\t      {\n"
    "\t\tname => [ \"string\", \"PageName\" ],\n"
    "\t\tdetailed =>\n"
    "\t\t  [ \"hash\", \"PageDetailed\",\n"
    "\t\t    {\n"
    "\t\t      doc => [ \"doc\", \"PageDetailedDoc\" ],\n"
    "\t\t    },\n"
    "\t\t  ],\n"
    "\t      },\n"
    "\t    ],\n"
    "\t  ],\n"
2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373
    "\tclasses =>\n"
    "\t  [ \"list\", \"Classes\",\n"
    "\t    [ \"hash\", \"Class\",\n"
    "\t      {\n"
    "\t\tname => [ \"string\", \"ClassName\" ],\n"
    "\t\tpublic_typedefs => memberlist(\"ClassPublicTypedef\"),\n"
    "\t\tpublic_methods => memberlist(\"ClassPublicMethod\"),\n"
    "\t\tpublic_members => memberlist(\"ClassPublicMember\"),\n"
    "\t\tprotected_typedefs => memberlist(\"ClassProtectedTypedef\"),\n"
    "\t\tprotected_methods => memberlist(\"ClassProtectedMethod\"),\n"
    "\t\tprotected_members => memberlist(\"ClassProtectedMember\"),\n"
    "\t\tprivate_typedefs => memberlist(\"ClassPrivateTypedef\"),\n"
    "\t\tprivate_methods => memberlist(\"ClassPrivateMethod\"),\n"
    "\t\tprivate_members => memberlist(\"ClassPrivateMember\"),\n"
    "\t\tdetailed =>\n"
    "\t\t  [ \"hash\", \"ClassDetailed\",\n"
    "\t\t    {\n"
    "\t\t      doc => [ \"doc\", \"ClassDetailedDoc\" ],\n"
2374
    "\t\t    },\n"
2375 2376 2377 2378
    "\t\t  ],\n"
    "\t      },\n"
    "\t    ],\n"
    "\t  ],\n"
2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434
    "\tgroups =>\n"
    "\t  [ \"list\", \"Groups\",\n"
    "\t    [ \"hash\", \"Group\",\n"
    "\t      {\n"
    "\t\tname => [ \"string\", \"GroupName\" ],\n"
    "\t\ttitle => [ \"string\", \"GroupTitle\" ],\n"
    "\t\tfiles =>\n"
    "\t\t  [ \"list\", \"Files\",\n"
    "\t\t    [ \"hash\", \"File\",\n"
    "\t\t      {\n"
    "\t\t        name => [ \"string\", \"Filename\" ]\n"
    "\t\t      }\n"
    "\t\t    ],\n"
    "\t\t  ],\n"
    "\t\tclasses  =>\n"
    "\t\t  [ \"list\", \"Classes\",\n"
    "\t\t    [ \"hash\", \"Class\",\n"
    "\t\t      {\n" 
    "\t\t        name => [ \"string\", \"Classname\" ]\n"
    "\t\t      }\n"
    "\t\t    ],\n"
    "\t\t  ],\n"
    "\t\tnamespaces =>\n"
    "\t\t  [ \"list\", \"Namespaces\",\n"
    "\t\t    [ \"hash\", \"Namespace\",\n"
    "\t\t      {\n" 
    "\t\t        name => [ \"string\", \"NamespaceName\" ]\n"
    "\t\t      }\n"
    "\t\t    ],\n"
    "\t\t  ],\n"
    "\t\tpages =>\n"
    "\t\t  [ \"list\", \"Pages\",\n"
    "\t\t    [ \"hash\", \"Page\","
    "\t\t      {\n"
    "\t\t        title => [ \"string\", \"PageName\" ]\n"
    "\t\t      }\n"
    "\t\t    ],\n"
    "\t\t  ],\n"
    "\t\tgroups =>\n"
    "\t\t  [ \"list\", \"Groups\",\n"
    "\t\t    [ \"hash\", \"Group\",\n"
    "\t\t      {\n"
    "\t\t        title => [ \"string\", \"GroupName\" ]\n"
    "\t\t      }\n"
    "\t\t    ],\n"
    "\t\t  ],\n"
    "\t\tfunctions => memberlist(\"GroupFunction\"),\n"
    "\t\tdetailed =>\n"
    "\t\t  [ \"hash\", \"GroupDetailed\",\n"
    "\t\t    {\n"
    "\t\t      doc => [ \"doc\", \"GroupDetailedDoc\" ],\n"
    "\t\t    },\n"
    "\t\t  ],\n"
    "\t      }\n"
    "\t    ],\n"
    "\t  ],\n"
2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449
    "      },\n"
    "    ];\n"
    "\n"
    "1;\n";

  return true;
}

bool PerlModGenerator::generateDoxyRules()
{
  QFile doxyRules;
  if (!createOutputFile(doxyRules, pathDoxyRules))
    return false;

  bool perlmodLatex = Config_getBool("PERLMOD_LATEX");
2450
  QCString prefix = Config_getString("PERLMOD_MAKEVAR_PREFIX");
2451

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2452
  FTextStream doxyRulesStream(&doxyRules);
2453
  doxyRulesStream <<
2454 2455 2456 2457 2458
    prefix << "DOXY_EXEC_PATH = " << pathDoxyExec << "\n" <<
    prefix << "DOXYFILE = " << pathDoxyfile << "\n" <<
    prefix << "DOXYDOCS_PM = " << pathDoxyDocsPM << "\n" <<
    prefix << "DOXYSTRUCTURE_PM = " << pathDoxyStructurePM << "\n" <<
    prefix << "DOXYRULES = " << pathDoxyRules << "\n";
2459 2460
  if (perlmodLatex)
    doxyRulesStream <<
2461 2462 2463 2464 2465 2466 2467 2468
      prefix << "DOXYLATEX_PL = " << pathDoxyLatexPL << "\n" <<
      prefix << "DOXYLATEXSTRUCTURE_PL = " << pathDoxyLatexStructurePL << "\n" <<
      prefix << "DOXYSTRUCTURE_TEX = " << pathDoxyStructureTex << "\n" <<
      prefix << "DOXYDOCS_TEX = " << pathDoxyDocsTex << "\n" <<
      prefix << "DOXYFORMAT_TEX = " << pathDoxyFormatTex << "\n" <<
      prefix << "DOXYLATEX_TEX = " << pathDoxyLatexTex << "\n" <<
      prefix << "DOXYLATEX_DVI = " << pathDoxyLatexDVI << "\n" <<
      prefix << "DOXYLATEX_PDF = " << pathDoxyLatexPDF << "\n";
2469 2470 2471 2472

  doxyRulesStream <<
    "\n"
    ".PHONY: clean-perlmod\n"
2473 2474 2475
    "clean-perlmod::\n"
    "\trm -f $(" << prefix << "DOXYSTRUCTURE_PM) \\\n"
    "\t$(" << prefix << "DOXYDOCS_PM)";
2476 2477 2478
  if (perlmodLatex)
    doxyRulesStream <<
      " \\\n"
2479 2480 2481 2482 2483 2484 2485 2486 2487
      "\t$(" << prefix << "DOXYLATEX_PL) \\\n"
      "\t$(" << prefix << "DOXYLATEXSTRUCTURE_PL) \\\n"
      "\t$(" << prefix << "DOXYDOCS_TEX) \\\n"
      "\t$(" << prefix << "DOXYSTRUCTURE_TEX) \\\n"
      "\t$(" << prefix << "DOXYFORMAT_TEX) \\\n"
      "\t$(" << prefix << "DOXYLATEX_TEX) \\\n"
      "\t$(" << prefix << "DOXYLATEX_PDF) \\\n"
      "\t$(" << prefix << "DOXYLATEX_DVI) \\\n"
      "\t$(addprefix $(" << prefix << "DOXYLATEX_TEX:tex=),out aux log)";
2488 2489 2490
  doxyRulesStream << "\n\n";

  doxyRulesStream <<
2491 2492 2493 2494
    "$(" << prefix << "DOXYRULES) \\\n"
    "$(" << prefix << "DOXYMAKEFILE) \\\n"
    "$(" << prefix << "DOXYSTRUCTURE_PM) \\\n"
    "$(" << prefix << "DOXYDOCS_PM)";
2495 2496 2497
  if (perlmodLatex) {
    doxyRulesStream <<
      " \\\n"
2498 2499 2500 2501
      "$(" << prefix << "DOXYLATEX_PL) \\\n"
      "$(" << prefix << "DOXYLATEXSTRUCTURE_PL) \\\n"
      "$(" << prefix << "DOXYFORMAT_TEX) \\\n"
      "$(" << prefix << "DOXYLATEX_TEX)";
2502 2503
  }
  doxyRulesStream <<
2504 2505 2506
    ": \\\n"
    "\t$(" << prefix << "DOXYFILE)\n"
    "\tcd $(" << prefix << "DOXY_EXEC_PATH) ; doxygen \"$<\"\n";
2507 2508 2509 2510

  if (perlmodLatex) {
    doxyRulesStream <<
      "\n"
2511 2512 2513
      "$(" << prefix << "DOXYDOCS_TEX): \\\n"
      "$(" << prefix << "DOXYLATEX_PL) \\\n"
      "$(" << prefix << "DOXYDOCS_PM)\n"
2514 2515
      "\tperl -I\"$(<D)\" \"$<\" >\"$@\"\n"
      "\n"
2516 2517 2518
      "$(" << prefix << "DOXYSTRUCTURE_TEX): \\\n"
      "$(" << prefix << "DOXYLATEXSTRUCTURE_PL) \\\n"
      "$(" << prefix << "DOXYSTRUCTURE_PM)\n"
2519 2520
      "\tperl -I\"$(<D)\" \"$<\" >\"$@\"\n"
      "\n"
2521 2522 2523 2524 2525 2526
      "$(" << prefix << "DOXYLATEX_PDF) \\\n"
      "$(" << prefix << "DOXYLATEX_DVI): \\\n"
      "$(" << prefix << "DOXYLATEX_TEX) \\\n"
      "$(" << prefix << "DOXYFORMAT_TEX) \\\n"
      "$(" << prefix << "DOXYSTRUCTURE_TEX) \\\n"
      "$(" << prefix << "DOXYDOCS_TEX)\n"
2527
      "\n"
2528 2529
      "$(" << prefix << "DOXYLATEX_PDF): \\\n"
      "$(" << prefix << "DOXYLATEX_TEX)\n"
2530 2531
      "\tpdflatex -interaction=nonstopmode \"$<\"\n"
      "\n"
2532 2533
      "$(" << prefix << "DOXYLATEX_DVI): \\\n"
      "$(" << prefix << "DOXYLATEX_TEX)\n"
2534
      "\tlatex -interaction=nonstopmode \"$<\"\n";
2535 2536
  }

2537 2538 2539 2540 2541 2542 2543 2544 2545 2546
  return true;
}

bool PerlModGenerator::generateMakefile()
{
  QFile makefile;
  if (!createOutputFile(makefile, pathMakefile))
    return false;

  bool perlmodLatex = Config_getBool("PERLMOD_LATEX");
2547
  QCString prefix = Config_getString("PERLMOD_MAKEVAR_PREFIX");
2548

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2549
  FTextStream makefileStream(&makefile);
2550 2551 2552 2553 2554 2555 2556 2557 2558 2559
  makefileStream <<
    ".PHONY: default clean" << (perlmodLatex ? " pdf" : "") << "\n"
    "default: " << (perlmodLatex ? "pdf" : "clean") << "\n"
    "\n"
    "include " << pathDoxyRules << "\n"
    "\n"
    "clean: clean-perlmod\n";

  if (perlmodLatex) {
    makefileStream <<
2560 2561
      "pdf: $(" << prefix << "DOXYLATEX_PDF)\n"
      "dvi: $(" << prefix << "DOXYLATEX_DVI)\n";
2562 2563
  }

2564 2565 2566
  return true;
}

2567
bool PerlModGenerator::generateDoxyLatexStructurePL()
2568
{
2569 2570
  QFile doxyLatexStructurePL;
  if (!createOutputFile(doxyLatexStructurePL, pathDoxyLatexStructurePL))
2571 2572
    return false;

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2573
  FTextStream doxyLatexStructurePLStream(&doxyLatexStructurePL);
2574 2575
  doxyLatexStructurePLStream << 
    "use DoxyStructure;\n"
2576
    "\n"
2577 2578 2579 2580 2581 2582 2583 2584 2585 2586
    "sub process($) {\n"
    "\tmy $node = $_[0];\n"
    "\tmy ($type, $name) = @$node[0, 1];\n"
    "\tmy $command;\n"
    "\tif ($type eq \"string\") { $command = \"String\" }\n"
    "\telsif ($type eq \"doc\") { $command = \"Doc\" }\n"
    "\telsif ($type eq \"hash\") {\n"
    "\t\t$command = \"Hash\";\n"
    "\t\tfor my $subnode (values %{$$node[2]}) {\n"
    "\t\t\tprocess($subnode);\n"
2587 2588
    "\t\t}\n"
    "\t}\n"
2589 2590 2591 2592 2593
    "\telsif ($type eq \"list\") {\n"
    "\t\t$command = \"List\";\n"
    "\t\tprocess($$node[2]);\n"
    "\t}\n"
    "\tprint \"\\\\\" . $command . \"Node{\" . $name . \"}%\\n\";\n"
2594 2595
    "}\n"
    "\n"
2596
    "process($doxystructure);\n";
2597 2598 2599 2600 2601 2602 2603 2604 2605 2606

  return true;
}

bool PerlModGenerator::generateDoxyLatexPL()
{
  QFile doxyLatexPL;
  if (!createOutputFile(doxyLatexPL, pathDoxyLatexPL))
    return false;

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2607
  FTextStream doxyLatexPLStream(&doxyLatexPL);
2608
  doxyLatexPLStream << 
2609
    "use DoxyStructure;\n"
2610 2611 2612 2613 2614
    "use DoxyDocs;\n"
    "\n"
    "sub latex_quote($) {\n"
    "\tmy $text = $_[0];\n"
    "\t$text =~ s/\\\\/\\\\textbackslash /g;\n"
2615 2616 2617
    "\t$text =~ s/\\|/\\\\textbar /g;\n"
    "\t$text =~ s/</\\\\textless /g;\n"
    "\t$text =~ s/>/\\\\textgreater /g;\n"
2618
    "\t$text =~ s/~/\\\\textasciitilde /g;\n"
2619
    "\t$text =~ s/\\^/\\\\textasciicircum /g;\n"
2620 2621 2622 2623 2624 2625 2626 2627 2628 2629
    "\t$text =~ s/[\\$&%#_{}]/\\\\$&/g;\n"
    "\tprint $text;\n"
    "}\n"
    "\n"
    "sub generate_doc($) {\n"
    "\tmy $doc = $_[0];\n"
    "\tfor my $item (@$doc) {\n"
    "\t\tmy $type = $$item{type};\n"
    "\t\tif ($type eq \"text\") {\n"
    "\t\t\tlatex_quote($$item{content});\n"
2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666
    "\t\t} elsif ($type eq \"parbreak\") {\n"
    "\t\t\tprint \"\\n\\n\";\n"
    "\t\t} elsif ($type eq \"style\") {\n"
    "\t\t\tmy $style = $$item{style};\n"
    "\t\t\tif ($$item{enable} eq \"yes\") {\n"
    "\t\t\t\tif ($style eq \"bold\") { print '\\bfseries'; }\n"
    "\t\t\t\tif ($style eq \"italic\") { print '\\itshape'; }\n"
    "\t\t\t\tif ($style eq \"code\") { print '\\ttfamily'; }\n"
    "\t\t\t} else {\n"
    "\t\t\t\tif ($style eq \"bold\") { print '\\mdseries'; }\n"
    "\t\t\t\tif ($style eq \"italic\") { print '\\upshape'; }\n"
    "\t\t\t\tif ($style eq \"code\") { print '\\rmfamily'; }\n"
    "\t\t\t}\n"
    "\t\t\tprint '{}';\n"
    "\t\t} elsif ($type eq \"symbol\") {\n"
    "\t\t\tmy $symbol = $$item{symbol};\n"
    "\t\t\tif ($symbol eq \"copyright\") { print '\\copyright'; }\n"
    "\t\t\telsif ($symbol eq \"szlig\") { print '\\ss'; }\n"
    "\t\t\tprint '{}';\n"
    "\t\t} elsif ($type eq \"accent\") {\n"
    "\t\t\tmy ($accent) = $$item{accent};\n"
    "\t\t\tif ($accent eq \"umlaut\") { print '\\\"'; }\n"
    "\t\t\telsif ($accent eq \"acute\") { print '\\\\\\''; }\n"
    "\t\t\telsif ($accent eq \"grave\") { print '\\`'; }\n"
    "\t\t\telsif ($accent eq \"circ\") { print '\\^'; }\n"
    "\t\t\telsif ($accent eq \"tilde\") { print '\\~'; }\n"
    "\t\t\telsif ($accent eq \"cedilla\") { print '\\c'; }\n"
    "\t\t\telsif ($accent eq \"ring\") { print '\\r'; }\n"
    "\t\t\tprint \"{\" . $$item{letter} . \"}\"; \n"
    "\t\t} elsif ($type eq \"list\") {\n"
    "\t\t\tmy $env = ($$item{style} eq \"ordered\") ? \"enumerate\" : \"itemize\";\n"
    "\t\t\tprint \"\\n\\\\begin{\" . $env .\"}\";\n"
    "\t\t  \tfor my $subitem (@{$$item{content}}) {\n"
    "\t\t\t\tprint \"\\n\\\\item \";\n"
    "\t\t\t\tgenerate_doc($subitem);\n"
    "\t\t  \t}\n"
    "\t\t\tprint \"\\n\\\\end{\" . $env .\"}\";\n"
2667 2668 2669 2670 2671 2672 2673
    "\t\t} elsif ($type eq \"url\") {\n"
    "\t\t\tlatex_quote($$item{content});\n"
    "\t\t}\n"
    "\t}\n"
    "}\n"
    "\n"
    "sub generate($$) {\n"
2674 2675
    "\tmy ($item, $node) = @_;\n"
    "\tmy ($type, $name) = @$node[0, 1];\n"
2676 2677 2678 2679 2680 2681 2682 2683 2684 2685
    "\tif ($type eq \"string\") {\n"
    "\t\tprint \"\\\\\" . $name . \"{\";\n"
    "\t\tlatex_quote($item);\n"
    "\t\tprint \"}\";\n"
    "\t} elsif ($type eq \"doc\") {\n"
    "\t\tif (@$item) {\n"
    "\t\t\tprint \"\\\\\" . $name . \"{\";\n"
    "\t\t\tgenerate_doc($item);\n"
    "\t\t\tprint \"}%\\n\";\n"
    "\t\t} else {\n"
2686
    "#\t\t\tprint \"\\\\\" . $name . \"Empty%\\n\";\n"
2687 2688 2689
    "\t\t}\n"
    "\t} elsif ($type eq \"hash\") {\n"
    "\t\tmy ($key, $value);\n"
2690 2691 2692
    "\t\twhile (($key, $subnode) = each %{$$node[2]}) {\n"
    "\t\t\tmy $subname = $$subnode[1];\n"
    "\t\t\tprint \"\\\\Defcs{field\" . $subname . \"}{\";\n"
2693
    "\t\t\tif ($$item{$key}) {\n"
2694
    "\t\t\t\tgenerate($$item{$key}, $subnode);\n"
2695
    "\t\t\t} else {\n"
2696
    "#\t\t\t\t\tprint \"\\\\\" . $subname . \"Empty%\\n\";\n"
2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708
    "\t\t\t}\n"
    "\t\t\tprint \"}%\\n\";\n"
    "\t\t}\n"
    "\t\tprint \"\\\\\" . $name . \"%\\n\";\n"
    "\t} elsif ($type eq \"list\") {\n"
    "\t\tmy $index = 0;\n"
    "\t\tif (@$item) {\n"
    "\t\t\tprint \"\\\\\" . $name . \"{%\\n\";\n"
    "\t\t\tfor my $subitem (@$item) {\n"
    "\t\t\t\tif ($index) {\n"
    "\t\t\t\t\tprint \"\\\\\" . $name . \"Sep%\\n\";\n"
    "\t\t\t\t}\n"
2709
    "\t\t\t\tgenerate($subitem, $$node[2]);\n"
2710 2711 2712 2713
    "\t\t\t\t$index++;\n"
    "\t\t\t}\n"
    "\t\t\tprint \"}%\\n\";\n"
    "\t\t} else {\n"
2714
    "#\t\t\tprint \"\\\\\" . $name . \"Empty%\\n\";\n"
2715 2716 2717 2718
    "\t\t}\n"
    "\t}\n"
    "}\n"
    "\n"
2719
    "generate($doxydocs, $doxystructure);\n";
2720 2721 2722 2723 2724 2725 2726 2727 2728 2729

  return true;
}

bool PerlModGenerator::generateDoxyFormatTex()
{
  QFile doxyFormatTex;
  if (!createOutputFile(doxyFormatTex, pathDoxyFormatTex))
    return false;

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2730
  FTextStream doxyFormatTexStream(&doxyFormatTex);
2731
  doxyFormatTexStream << 
2732 2733 2734 2735 2736 2737 2738 2739 2740 2741
    "\\def\\Defcs#1{\\long\\expandafter\\def\\csname#1\\endcsname}\n"
    "\\Defcs{Empty}{}\n"
    "\\def\\IfEmpty#1{\\expandafter\\ifx\\csname#1\\endcsname\\Empty}\n"
    "\n"
    "\\def\\StringNode#1{\\Defcs{#1}##1{##1}}\n"
    "\\def\\DocNode#1{\\Defcs{#1}##1{##1}}\n"
    "\\def\\ListNode#1{\\Defcs{#1}##1{##1}\\Defcs{#1Sep}{}}\n"
    "\\def\\HashNode#1{\\Defcs{#1}{}}\n"
    "\n"
    "\\input{" << pathDoxyStructureTex << "}\n"
2742 2743 2744 2745 2746 2747
    "\n"
    "\\newbox\\BoxA\n"
    "\\dimendef\\DimenA=151\\relax\n"
    "\\dimendef\\DimenB=152\\relax\n"
    "\\countdef\\ZoneDepth=151\\relax\n"
    "\n"
2748 2749 2750 2751
    "\\def\\Cs#1{\\csname#1\\endcsname}\n"
    "\\def\\Letcs#1{\\expandafter\\let\\csname#1\\endcsname}\n"
    "\\def\\Heading#1{\\vskip 4mm\\relax\\textbf{#1}}\n"
    "\\def\\See#1{\\begin{flushleft}\\Heading{See also: }#1\\end{flushleft}}\n"
2752
    "\n"
2753 2754
    "\\def\\Frame#1{\\vskip 3mm\\relax\\fbox{ \\vbox{\\hsize0.95\\hsize\\vskip 1mm\\relax\n"
    "\\raggedright#1\\vskip 0.5mm\\relax} }}\n"
2755 2756
    "\n"
    "\\def\\Zone#1#2#3{%\n"
2757 2758 2759 2760 2761 2762 2763
    "\\Defcs{Test#1}{#2}%\n"
    "\\Defcs{Emit#1}{#3}%\n"
    "\\Defcs{#1}{%\n"
    "\\advance\\ZoneDepth1\\relax\n"
    "\\Letcs{Mode\\number\\ZoneDepth}0\\relax\n"
    "\\Letcs{Present\\number\\ZoneDepth}0\\relax\n"
    "\\Cs{Test#1}\n"
2764
    "\\expandafter\\if\\Cs{Present\\number\\ZoneDepth}1%\n"
2765 2766
    "\\advance\\ZoneDepth-1\\relax\n"
    "\\Letcs{Present\\number\\ZoneDepth}1\\relax\n"
2767
    "\\expandafter\\if\\Cs{Mode\\number\\ZoneDepth}1%\n"
2768 2769 2770 2771 2772 2773
    "\\advance\\ZoneDepth1\\relax\n"
    "\\Letcs{Mode\\number\\ZoneDepth}1\\relax\n"
    "\\Cs{Emit#1}\n"
    "\\advance\\ZoneDepth-1\\relax\\fi\n"
    "\\advance\\ZoneDepth1\\relax\\fi\n"
    "\\advance\\ZoneDepth-1\\relax}}\n"
2774 2775
    "\n"
    "\\def\\Member#1#2{%\n"
2776 2777 2778 2779 2780 2781
    "\\Defcs{Test#1}{\\Cs{field#1Detailed}\n"
    "\\IfEmpty{field#1DetailedDoc}\\else\\Letcs{Present#1}1\\fi}\n"
    "\\Defcs{#1}{\\Letcs{Present#1}0\\relax\n"
    "\\Cs{Test#1}\\if1\\Cs{Present#1}\\Letcs{Present\\number\\ZoneDepth}1\\relax\n"
    "\\if1\\Cs{Mode\\number\\ZoneDepth}#2\\fi\\fi}}\n"
    "\n"
2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806
    "\\def\\TypedefMemberList#1#2{%\n"
    "\\Defcs{#1DetailedDoc}##1{\\vskip 5.5mm\\relax##1}%\n"
    "\\Defcs{#1Name}##1{\\textbf{##1}}%\n"
    "\\Defcs{#1See}##1{\\See{##1}}%\n"
    "%\n"
    "\\Zone{#1s}{\\Cs{field#1List}}{\\subsubsection{#2}\\Cs{field#1List}}%\n"
    "\\Member{#1}{\\Frame{typedef \\Cs{field#1Type} \\Cs{field#1Name}}%\n"
    "\\Cs{field#1DetailedDoc}\\Cs{field#1See}\\vskip 5mm\\relax}}%\n"
    "\n"
    "\\def\\VariableMemberList#1#2{%\n"
    "\\Defcs{#1DetailedDoc}##1{\\vskip 5.5mm\\relax##1}%\n"
    "\\Defcs{#1Name}##1{\\textbf{##1}}%\n"
    "\\Defcs{#1See}##1{\\See{##1}}%\n"
    "%\n"
    "\\Zone{#1s}{\\Cs{field#1List}}{\\subsubsection{#2}\\Cs{field#1List}}%\n"
    "\\Member{#1}{\\Frame{\\Cs{field#1Type}{} \\Cs{field#1Name}}%\n"
    "\\Cs{field#1DetailedDoc}\\Cs{field#1See}\\vskip 5mm\\relax}}%\n"
    "\n"
    "\\def\\FunctionMemberList#1#2{%\n"
    "\\Defcs{#1PDParamName}##1{\\textit{##1}}%\n"
    "\\Defcs{#1PDParam}{\\Cs{field#1PDParamName}}%\n"
    "\\Defcs{#1PDParamsSep}{, }%\n"
    "\\Defcs{#1PDBlocksSep}{\\vskip 2mm\\relax}%\n"
    "%\n"
    "\\Defcs{#1PDBlocks}##1{%\n"
2807 2808
    "\\Heading{Parameters:}\\vskip 1.5mm\\relax\n"
    "\\DimenA0pt\\relax\n"
2809 2810 2811 2812
    "\\Defcs{#1PDBlock}{\\setbox\\BoxA\\hbox{\\Cs{field#1PDParams}}%\n"
    "\\ifdim\\DimenA<\\wd\\BoxA\\DimenA\\wd\\BoxA\\fi}%\n"
    "##1%\n"
    "\\advance\\DimenA3mm\\relax\n"
2813 2814 2815
    "\\DimenB\\hsize\\advance\\DimenB-\\DimenA\\relax\n"
    "\\Defcs{#1PDBlock}{\\hbox to\\hsize{\\vtop{\\hsize\\DimenA\\relax\n"
    "\\Cs{field#1PDParams}}\\hfill\n"
2816
    "\\vtop{\\hsize\\DimenB\\relax\\Cs{field#1PDDoc}}}}%\n"
2817 2818 2819 2820 2821 2822 2823 2824 2825
    "##1}\n"
    "\n"
    "\\Defcs{#1ParamName}##1{\\textit{##1}}\n"
    "\\Defcs{#1Param}{\\Cs{field#1ParamType}{} \\Cs{field#1ParamName}}\n"
    "\\Defcs{#1ParamsSep}{, }\n"
    "\n"
    "\\Defcs{#1Name}##1{\\textbf{##1}}\n"
    "\\Defcs{#1See}##1{\\See{##1}}\n"
    "\\Defcs{#1Return}##1{\\Heading{Returns: }##1}\n"
2826 2827 2828
    "\\Defcs{field#1Title}{\\Frame{\\Cs{field#1Type}{} \\Cs{field#1Name}(\\Cs{field#1Params})}}%\n"
    "%\n"
    "\\Zone{#1s}{\\Cs{field#1List}}{\\subsubsection{#2}\\Cs{field#1List}}%\n"
2829 2830
    "\\Member{#1}{%\n"
    "\\Cs{field#1Title}\\vskip 6mm\\relax\\Cs{field#1DetailedDoc}\n"
2831 2832
    "\\Cs{field#1Return}\\Cs{field#1PDBlocks}\\Cs{field#1See}\\vskip 5mm\\relax}}\n"
    "\n"
2833 2834 2835 2836
    "\\def\\FileDetailed{\\fieldFileDetailedDoc\\par}\n"
    "\\def\\ClassDetailed{\\fieldClassDetailedDoc\\par}\n"
    "\n"
    "\\def\\FileSubzones{\\fieldFileTypedefs\\fieldFileVariables\\fieldFileFunctions}\n"
2837
    "\n"
2838 2839 2840 2841
    "\\def\\ClassSubzones{%\n"
    "\\fieldClassPublicTypedefs\\fieldClassPublicMembers\\fieldClassPublicMethods\n"
    "\\fieldClassProtectedTypedefs\\fieldClassProtectedMembers\\fieldClassProtectedMethods\n"
    "\\fieldClassPrivateTypedefs\\fieldClassPrivateMembers\\fieldClassPrivateMethods}\n"
2842
    "\n"
2843 2844 2845 2846 2847 2848
    "\\Member{Page}{\\subsection{\\fieldPageName}\\fieldPageDetailedDoc}\n"
    "\n"
    "\\TypedefMemberList{FileTypedef}{Typedefs}\n"
    "\\VariableMemberList{FileVariable}{Variables}\n"
    "\\FunctionMemberList{FileFunction}{Functions}\n"
    "\\Zone{File}{\\FileSubzones}{\\subsection{\\fieldFileName}\\fieldFileDetailed\\FileSubzones}\n"
2849 2850 2851 2852 2853 2854 2855 2856 2857 2858
    "\n"
    "\\TypedefMemberList{ClassPublicTypedef}{Public Typedefs}\n"
    "\\TypedefMemberList{ClassProtectedTypedef}{Protected Typedefs}\n"
    "\\TypedefMemberList{ClassPrivateTypedef}{Private Typedefs}\n"
    "\\VariableMemberList{ClassPublicMember}{Public Members}\n"
    "\\VariableMemberList{ClassProtectedMember}{Protected Members}\n"
    "\\VariableMemberList{ClassPrivateMember}{Private Members}\n"
    "\\FunctionMemberList{ClassPublicMethod}{Public Methods}\n"
    "\\FunctionMemberList{ClassProtectedMethod}{Protected Methods}\n"
    "\\FunctionMemberList{ClassPrivateMethod}{Private Methods}\n"
2859
    "\\Zone{Class}{\\ClassSubzones}{\\subsection{\\fieldClassName}\\fieldClassDetailed\\ClassSubzones}\n"
2860
    "\n"
2861 2862 2863
    "\\Zone{AllPages}{\\fieldPages}{\\section{Pages}\\fieldPages}\n"
    "\\Zone{AllFiles}{\\fieldFiles}{\\section{Files}\\fieldFiles}\n"
    "\\Zone{AllClasses}{\\fieldClasses}{\\section{Classes}\\fieldClasses}\n"
2864
    "\n"
2865 2866 2867
    "\\newlength{\\oldparskip}\n"
    "\\newlength{\\oldparindent}\n"
    "\\newlength{\\oldfboxrule}\n"
2868
    "\n"
2869 2870
    "\\ZoneDepth0\\relax\n"
    "\\Letcs{Mode0}1\\relax\n"
2871 2872
    "\n"
    "\\def\\EmitDoxyDocs{%\n"
2873 2874 2875 2876 2877 2878 2879 2880 2881
    "\\setlength{\\oldparskip}{\\parskip}\n"
    "\\setlength{\\oldparindent}{\\parindent}\n"
    "\\setlength{\\oldfboxrule}{\\fboxrule}\n"
    "\\setlength{\\parskip}{0cm}\n"
    "\\setlength{\\parindent}{0cm}\n"
    "\\setlength{\\fboxrule}{1pt}\n"
    "\\AllPages\\AllFiles\\AllClasses\n"
    "\\setlength{\\parskip}{\\oldparskip}\n"
    "\\setlength{\\parindent}{\\oldparindent}\n"
2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892
    "\\setlength{\\fboxrule}{\\oldfboxrule}}\n";

  return true;
}

bool PerlModGenerator::generateDoxyLatexTex()
{
  QFile doxyLatexTex;
  if (!createOutputFile(doxyLatexTex, pathDoxyLatexTex))
    return false;

Dimitri van Heesch's avatar
Dimitri van Heesch committed
2893
  FTextStream doxyLatexTexStream(&doxyLatexTex);
2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905
  doxyLatexTexStream <<
    "\\documentclass[a4paper,12pt]{article}\n"
    "\\usepackage[latin1]{inputenc}\n"
    "\\usepackage[none]{hyphenat}\n"
    "\\usepackage[T1]{fontenc}\n"
    "\\usepackage{hyperref}\n"
    "\\usepackage{times}\n"
    "\n"
    "\\input{doxyformat}\n"
    "\n"
    "\\begin{document}\n"
    "\\input{" << pathDoxyDocsTex << "}\n"
2906
    "\\sloppy\n"
2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921
    "\\EmitDoxyDocs\n"
    "\\end{document}\n";

  return true;
}

void PerlModGenerator::generate()
{
  // + classes
  // + namespaces
  // + files
  // - packages
  // + groups
  // + related pages
  // - examples
2922

2923 2924 2925 2926 2927 2928
  QDir perlModDir;
  if (!createOutputDir(perlModDir))
    return;

  bool perlmodLatex = Config_getBool("PERLMOD_LATEX");

2929 2930 2931 2932 2933
  QCString perlModAbsPath = perlModDir.absPath().utf8();
  pathDoxyDocsPM = perlModAbsPath + "/DoxyDocs.pm";
  pathDoxyStructurePM = perlModAbsPath + "/DoxyStructure.pm";
  pathMakefile = perlModAbsPath + "/Makefile";
  pathDoxyRules = perlModAbsPath + "/doxyrules.make";
2934 2935

  if (perlmodLatex) {
2936 2937 2938 2939 2940 2941 2942 2943
    pathDoxyStructureTex = perlModAbsPath + "/doxystructure.tex";
    pathDoxyFormatTex = perlModAbsPath + "/doxyformat.tex";
    pathDoxyLatexTex = perlModAbsPath + "/doxylatex.tex";
    pathDoxyLatexDVI = perlModAbsPath + "/doxylatex.dvi";
    pathDoxyLatexPDF = perlModAbsPath + "/doxylatex.pdf";
    pathDoxyDocsTex = perlModAbsPath + "/doxydocs.tex";
    pathDoxyLatexPL = perlModAbsPath + "/doxylatex.pl";
    pathDoxyLatexStructurePL = perlModAbsPath + "/doxylatex-structure.pl";
2944 2945
  }

2946
  if (!(generatePerlModOutput()
2947
	&& generateDoxyStructurePM()
2948 2949 2950
	&& generateMakefile()
	&& generateDoxyRules()))
    return;
2951

2952
  if (perlmodLatex) {
2953
    if (!(generateDoxyLatexStructurePL()
2954 2955 2956 2957 2958 2959
	  && generateDoxyLatexPL()
	  && generateDoxyLatexTex()
	  && generateDoxyFormatTex()))
      return;
  }
}
2960

2961 2962
void generatePerlMod()
{
2963
  PerlModGenerator pmg(Config_getBool("PERLMOD_PRETTY"));
2964
  pmg.generate();
2965 2966 2967 2968 2969
}

// Local Variables:
// c-basic-offset: 2
// End:
2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987

/* This elisp function for XEmacs makes Control-Z transform
   the text in the region into a valid C string.

  (global-set-key '(control z) (lambda () (interactive)
   (save-excursion
    (if (< (mark) (point)) (exchange-point-and-mark))
    (let ((start (point)) (replacers 
     '(("\\\\" "\\\\\\\\")
       ("\"" "\\\\\"")
       ("\t" "\\\\t")
       ("^.*$" "\"\\&\\\\n\""))))
     (while replacers   
      (while (re-search-forward (caar replacers) (mark) t)
       (replace-match (cadar replacers) t))
      (goto-char start)
      (setq replacers (cdr replacers)))))))
*/