1 /******************************************************************************
6 * Copyright (C) 1997-2014 by Dimitri van Heesch.
7 * Authors: Dimitri van Heesch, Miguel Lobo.
9 * Permission to use, copy, modify, and distribute this software and its
10 * documentation under the terms of the GNU General Public License is hereby
11 * granted. No representations are made about the suitability of this software
12 * for any purpose. It is provided "as is" without express or implied warranty.
13 * See the GNU General Public License for more details.
15 * Documents produced by Doxygen are derivative works derived from the
16 * input used in their production; they are not affected by this license.
27 #include "perlmodgen.h"
28 #include "docparser.h"
32 #include "memberlist.h"
33 #include "ftextstream.h"
34 #include "arguments.h"
38 #include "classlist.h"
40 #include "membername.h"
41 #include "namespacedef.h"
42 #include "membergroup.h"
45 #include "htmlentity.h"
47 #define PERLOUTPUT_MAX_INDENTATION 40
49 class PerlModOutputStream
56 PerlModOutputStream(FTextStream *t = 0) : m_t(t) { }
59 void add(const char *s);
60 void add(QCString &s);
62 void add(unsigned int n);
65 void PerlModOutputStream::add(char c)
73 void PerlModOutputStream::add(const char *s)
81 void PerlModOutputStream::add(QCString &s)
89 void PerlModOutputStream::add(int n)
97 void PerlModOutputStream::add(unsigned int n)
111 inline PerlModOutput(bool pretty)
112 : m_pretty(pretty), m_stream(0), m_indentation(false), m_blockstart(true)
117 virtual ~PerlModOutput() { }
119 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; }
124 inline PerlModOutput &continueBlock()
127 m_blockstart = false;
134 inline PerlModOutput &add(char c) { m_stream->add(c); return *this; }
135 inline PerlModOutput &add(const char *s) { m_stream->add(s); return *this; }
136 inline PerlModOutput &add(QCString &s) { m_stream->add(s); return *this; }
137 inline PerlModOutput &add(int n) { m_stream->add(n); return *this; }
138 inline PerlModOutput &add(unsigned int n) { m_stream->add(n); return *this; }
140 PerlModOutput &addQuoted(const char *s) { iaddQuoted(s); return *this; }
142 inline PerlModOutput &indent()
146 m_stream->add(m_spaces);
151 inline PerlModOutput &open(char c, const char *s = 0) { iopen(c, s); return *this; }
152 inline PerlModOutput &close(char c = 0) { iclose(c); return *this; }
154 inline PerlModOutput &addField(const char *s) { iaddField(s); return *this; }
155 inline PerlModOutput &addFieldQuotedChar(const char *field, char content)
157 iaddFieldQuotedChar(field, content); return *this;
159 inline PerlModOutput &addFieldQuotedString(const char *field, const char *content)
161 iaddFieldQuotedString(field, content); return *this;
163 inline PerlModOutput &addFieldBoolean(const char *field, bool content)
165 return addFieldQuotedString(field, content ? "yes" : "no");
167 inline PerlModOutput &openList(const char *s = 0) { open('[', s); return *this; }
168 inline PerlModOutput &closeList() { close(']'); return *this; }
169 inline PerlModOutput &openHash(const char *s = 0 ) { open('{', s); return *this; }
170 inline PerlModOutput &closeHash() { close('}'); return *this; }
175 void icloseSave(QCString &);
180 void iaddQuoted(const char *);
181 void iaddFieldQuotedChar(const char *, char);
182 void iaddFieldQuotedString(const char *, const char *);
183 void iaddField(const char *);
185 void iopen(char, const char *);
190 PerlModOutputStream *m_stream;
194 QStack<PerlModOutputStream> m_saved;
195 char m_spaces[PERLOUTPUT_MAX_INDENTATION * 2 + 2];
198 void PerlModOutput::iopenSave()
200 m_saved.push(m_stream);
201 m_stream = new PerlModOutputStream();
204 void PerlModOutput::icloseSave(QCString &s)
208 m_stream = m_saved.pop();
211 void PerlModOutput::incIndent()
213 if (m_indentation < PERLOUTPUT_MAX_INDENTATION)
215 char *s = &m_spaces[m_indentation * 2];
216 *s++ = ' '; *s++ = ' '; *s = 0;
221 void PerlModOutput::decIndent()
224 if (m_indentation < PERLOUTPUT_MAX_INDENTATION)
225 m_spaces[m_indentation * 2] = 0;
228 void PerlModOutput::iaddQuoted(const char *s)
231 while ((c = *s++) != 0) {
232 if ((c == '\'') || (c == '\\'))
238 void PerlModOutput::iaddField(const char *s)
242 m_stream->add(m_pretty ? " => " : "=>");
245 void PerlModOutput::iaddFieldQuotedChar(const char *field, char content)
249 if ((content == '\'') || (content == '\\'))
251 m_stream->add(content);
255 void PerlModOutput::iaddFieldQuotedString(const char *field, const char *content)
265 void PerlModOutput::iopen(char c, const char *s)
276 void PerlModOutput::iclose(char c)
282 m_blockstart = false;
285 /*! @brief Concrete visitor implementation for PerlMod output. */
286 class PerlModDocVisitor : public DocVisitor
289 PerlModDocVisitor(PerlModOutput &);
290 virtual ~PerlModDocVisitor() { }
294 //--------------------------------------
295 // visitor functions for leaf nodes
296 //--------------------------------------
298 void visit(DocWord *);
299 void visit(DocLinkedWord *);
300 void visit(DocWhiteSpace *);
301 void visit(DocSymbol *);
302 void visit(DocURL *);
303 void visit(DocLineBreak *);
304 void visit(DocHorRuler *);
305 void visit(DocStyleChange *);
306 void visit(DocVerbatim *);
307 void visit(DocAnchor *);
308 void visit(DocInclude *);
309 void visit(DocIncOperator *);
310 void visit(DocFormula *);
311 void visit(DocIndexEntry *);
312 void visit(DocSimpleSectSep *);
313 void visit(DocCite *);
315 //--------------------------------------
316 // visitor functions for compound nodes
317 //--------------------------------------
319 void visitPre(DocAutoList *);
320 void visitPost(DocAutoList *);
321 void visitPre(DocAutoListItem *);
322 void visitPost(DocAutoListItem *);
323 void visitPre(DocPara *) ;
324 void visitPost(DocPara *);
325 void visitPre(DocRoot *);
326 void visitPost(DocRoot *);
327 void visitPre(DocSimpleSect *);
328 void visitPost(DocSimpleSect *);
329 void visitPre(DocTitle *);
330 void visitPost(DocTitle *);
331 void visitPre(DocSimpleList *);
332 void visitPost(DocSimpleList *);
333 void visitPre(DocSimpleListItem *);
334 void visitPost(DocSimpleListItem *);
335 void visitPre(DocSection *);
336 void visitPost(DocSection *);
337 void visitPre(DocHtmlList *);
338 void visitPost(DocHtmlList *) ;
339 void visitPre(DocHtmlListItem *);
340 void visitPost(DocHtmlListItem *);
341 //void visitPre(DocHtmlPre *);
342 //void visitPost(DocHtmlPre *);
343 void visitPre(DocHtmlDescList *);
344 void visitPost(DocHtmlDescList *);
345 void visitPre(DocHtmlDescTitle *);
346 void visitPost(DocHtmlDescTitle *);
347 void visitPre(DocHtmlDescData *);
348 void visitPost(DocHtmlDescData *);
349 void visitPre(DocHtmlTable *);
350 void visitPost(DocHtmlTable *);
351 void visitPre(DocHtmlRow *);
352 void visitPost(DocHtmlRow *) ;
353 void visitPre(DocHtmlCell *);
354 void visitPost(DocHtmlCell *);
355 void visitPre(DocHtmlCaption *);
356 void visitPost(DocHtmlCaption *);
357 void visitPre(DocInternal *);
358 void visitPost(DocInternal *);
359 void visitPre(DocHRef *);
360 void visitPost(DocHRef *);
361 void visitPre(DocHtmlHeader *);
362 void visitPost(DocHtmlHeader *);
363 void visitPre(DocImage *);
364 void visitPost(DocImage *);
365 void visitPre(DocDotFile *);
366 void visitPost(DocDotFile *);
367 void visitPre(DocMscFile *);
368 void visitPost(DocMscFile *);
369 void visitPre(DocDiaFile *);
370 void visitPost(DocDiaFile *);
371 void visitPre(DocLink *);
372 void visitPost(DocLink *);
373 void visitPre(DocRef *);
374 void visitPost(DocRef *);
375 void visitPre(DocSecRefItem *);
376 void visitPost(DocSecRefItem *);
377 void visitPre(DocSecRefList *);
378 void visitPost(DocSecRefList *);
379 //void visitPre(DocLanguage *);
380 //void visitPost(DocLanguage *);
381 void visitPre(DocParamSect *);
382 void visitPost(DocParamSect *);
383 void visitPre(DocParamList *);
384 void visitPost(DocParamList *);
385 void visitPre(DocXRefItem *);
386 void visitPost(DocXRefItem *);
387 void visitPre(DocInternalRef *);
388 void visitPost(DocInternalRef *);
389 void visitPre(DocCopy *);
390 void visitPost(DocCopy *);
391 void visitPre(DocText *);
392 void visitPost(DocText *);
393 void visitPre(DocHtmlBlockQuote *);
394 void visitPost(DocHtmlBlockQuote *);
395 void visitPre(DocVhdlFlow *);
396 void visitPost(DocVhdlFlow *);
397 void visitPre(DocParBlock *);
398 void visitPost(DocParBlock *);
402 //--------------------------------------
404 //--------------------------------------
406 void addLink(const QCString &ref, const QCString &file,
407 const QCString &anchor);
412 void openItem(const char *);
414 void singleItem(const char *);
415 void openSubBlock(const char * = 0);
416 void closeSubBlock();
420 //--------------------------------------
422 //--------------------------------------
424 PerlModOutput &m_output;
426 bool m_textblockstart;
430 PerlModDocVisitor::PerlModDocVisitor(PerlModOutput &output)
431 : DocVisitor(DocVisitor_Other), m_output(output), m_textmode(false)
433 m_output.openList("doc");
436 void PerlModDocVisitor::finish()
443 void PerlModDocVisitor::addLink(const QCString &,const QCString &file,const QCString &anchor)
445 QCString link = file;
446 if (!anchor.isEmpty())
447 (link += "_1") += anchor;
448 m_output.addFieldQuotedString("link", link);
451 void PerlModDocVisitor::openItem(const char *name)
454 m_output.openHash().addFieldQuotedString("type", name);
457 void PerlModDocVisitor::closeItem()
460 m_output.closeHash();
463 void PerlModDocVisitor::enterText()
468 m_output.addField("content").add('\'');
472 void PerlModDocVisitor::leaveText()
482 void PerlModDocVisitor::singleItem(const char *name)
488 void PerlModDocVisitor::openSubBlock(const char *s)
491 m_output.openList(s);
492 m_textblockstart = true;
495 void PerlModDocVisitor::closeSubBlock()
498 m_output.closeList();
501 void PerlModDocVisitor::openOther()
503 // Using a secondary text stream will corrupt the perl file. Instead of
504 // printing doc => [ data => [] ], it will print doc => [] data => [].
511 void PerlModDocVisitor::closeOther()
513 // Using a secondary text stream will corrupt the perl file. Instead of
514 // printing doc => [ data => [] ], it will print doc => [] data => [].
518 m_output.closeSave(other);
523 void PerlModDocVisitor::visit(DocWord *w)
526 m_output.addQuoted(w->word());
529 void PerlModDocVisitor::visit(DocLinkedWord *w)
532 addLink(w->ref(), w->file(), w->anchor());
533 m_output.addFieldQuotedString("content", w->word());
537 void PerlModDocVisitor::visit(DocWhiteSpace *)
543 void PerlModDocVisitor::visit(DocSymbol *sy)
545 const DocSymbol::PerlSymb *res = HtmlEntityMapper::instance()->perl(sy->symbol());
546 const char *accent=0;
551 case DocSymbol::Perl_string:
553 m_output.add(res->symb);
555 case DocSymbol::Perl_char:
557 m_output.add(res->symb[0]);
559 case DocSymbol::Perl_symbol:
562 m_output.addFieldQuotedString("symbol", res->symb);
568 case DocSymbol::Perl_umlaut:
571 case DocSymbol::Perl_acute:
574 case DocSymbol::Perl_grave:
577 case DocSymbol::Perl_circ:
580 case DocSymbol::Perl_slash:
583 case DocSymbol::Perl_tilde:
586 case DocSymbol::Perl_cedilla:
589 case DocSymbol::Perl_ring:
600 .addFieldQuotedString("accent", accent)
601 .addFieldQuotedChar("letter", res->symb[0]);
609 err("perl: non supported HTML-entity found: %s\n",HtmlEntityMapper::instance()->html(sy->symbol(),TRUE));
613 void PerlModDocVisitor::visit(DocURL *u)
616 m_output.addFieldQuotedString("content", u->url());
620 void PerlModDocVisitor::visit(DocLineBreak *) { singleItem("linebreak"); }
621 void PerlModDocVisitor::visit(DocHorRuler *) { singleItem("hruler"); }
623 void PerlModDocVisitor::visit(DocStyleChange *s)
625 const char *style = 0;
628 case DocStyleChange::Bold: style = "bold"; break;
629 case DocStyleChange::Italic: style = "italic"; break;
630 case DocStyleChange::Code: style = "code"; break;
631 case DocStyleChange::Subscript: style = "subscript"; break;
632 case DocStyleChange::Superscript: style = "superscript"; break;
633 case DocStyleChange::Center: style = "center"; break;
634 case DocStyleChange::Small: style = "small"; break;
635 case DocStyleChange::Preformatted: style = "preformatted"; break;
636 case DocStyleChange::Div: style = "div"; break;
637 case DocStyleChange::Span: style = "span"; break;
641 m_output.addFieldQuotedString("style", style)
642 .addFieldBoolean("enable", s->enable());
646 void PerlModDocVisitor::visit(DocVerbatim *s)
648 const char *type = 0;
651 case DocVerbatim::Code:
653 m_output.add("<programlisting>");
654 parseCode(m_ci,s->context(),s->text(),FALSE,0);
655 m_output.add("</programlisting>");
658 case DocVerbatim::Verbatim: type = "preformatted"; break;
659 case DocVerbatim::HtmlOnly: type = "htmlonly"; break;
660 case DocVerbatim::RtfOnly: type = "rtfonly"; break;
661 case DocVerbatim::ManOnly: type = "manonly"; break;
662 case DocVerbatim::LatexOnly: type = "latexonly"; break;
663 case DocVerbatim::XmlOnly: type = "xmlonly"; break;
664 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;
670 m_output.addFieldQuotedString("content", s->text());
674 void PerlModDocVisitor::visit(DocAnchor *anc)
676 QCString anchor = anc->file() + "_1" + anc->anchor();
678 m_output.addFieldQuotedString("id", anchor);
682 void PerlModDocVisitor::visit(DocInclude *inc)
684 const char *type = 0;
687 case DocInclude::IncWithLines:
690 m_t << "<div class=\"fragment\"><pre>";
691 QFileInfo cfi( inc->file() );
692 FileDef fd( cfi.dirPath(), cfi.fileName() );
693 parseCode(m_ci,inc->context(),inc->text().latin1(),inc->isExample(),inc->exampleFile(), &fd);
694 m_t << "</pre></div>";
699 case DocInclude::Include:
701 m_output.add("<programlisting>");
702 parseCode(m_ci,inc->context(),inc->text(),FALSE,0);
703 m_output.add("</programlisting>");
706 case DocInclude::DontInclude: return;
707 case DocInclude::HtmlInclude: type = "htmlonly"; break;
708 case DocInclude::LatexInclude: type = "latexonly"; break;
709 case DocInclude::VerbInclude: type = "preformatted"; break;
710 case DocInclude::Snippet: return;
713 m_output.addFieldQuotedString("content", inc->text());
717 void PerlModDocVisitor::visit(DocIncOperator *)
720 //printf("DocIncOperator: type=%d first=%d, last=%d text=`%s'\n",
721 // op->type(),op->isFirst(),op->isLast(),op->text().data());
724 m_output.add("<programlisting>");
726 if (op->type()!=DocIncOperator::Skip)
728 parseCode(m_ci,op->context(),op->text(),FALSE,0);
732 m_output.add("</programlisting>");
741 void PerlModDocVisitor::visit(DocFormula *f)
746 m_output.addFieldQuotedString("id", id).addFieldQuotedString("content", f->text());
750 void PerlModDocVisitor::visit(DocIndexEntry *)
753 m_output.add("<indexentry>"
755 m_output.addQuoted(ie->entry());
756 m_output.add("</primaryie>"
757 "<secondaryie></secondaryie>"
762 void PerlModDocVisitor::visit(DocSimpleSectSep *)
766 void PerlModDocVisitor::visit(DocCite *cite)
769 m_output.addFieldQuotedString("text", cite->text());
774 //--------------------------------------
775 // visitor functions for compound nodes
776 //--------------------------------------
778 void PerlModDocVisitor::visitPre(DocAutoList *l)
781 m_output.addFieldQuotedString("style", l->isEnumList() ? "ordered" : "itemized");
782 openSubBlock("content");
785 void PerlModDocVisitor::visitPost(DocAutoList *)
791 void PerlModDocVisitor::visitPre(DocAutoListItem *)
796 void PerlModDocVisitor::visitPost(DocAutoListItem *)
801 void PerlModDocVisitor::visitPre(DocPara *)
803 if (m_textblockstart)
804 m_textblockstart = false;
806 singleItem("parbreak");
809 openSubBlock("content");
813 void PerlModDocVisitor::visitPost(DocPara *)
821 void PerlModDocVisitor::visitPre(DocRoot *)
825 void PerlModDocVisitor::visitPost(DocRoot *)
829 void PerlModDocVisitor::visitPre(DocSimpleSect *s)
831 const char *type = 0;
834 case DocSimpleSect::See: type = "see"; break;
835 case DocSimpleSect::Return: type = "return"; break;
836 case DocSimpleSect::Author: type = "author"; break;
837 case DocSimpleSect::Authors: type = "authors"; break;
838 case DocSimpleSect::Version: type = "version"; break;
839 case DocSimpleSect::Since: type = "since"; break;
840 case DocSimpleSect::Date: type = "date"; break;
841 case DocSimpleSect::Note: type = "note"; break;
842 case DocSimpleSect::Warning: type = "warning"; break;
843 case DocSimpleSect::Pre: type = "pre"; break;
844 case DocSimpleSect::Post: type = "post"; break;
845 case DocSimpleSect::Copyright: type = "copyright"; break;
846 case DocSimpleSect::Invar: type = "invariant"; break;
847 case DocSimpleSect::Remark: type = "remark"; break;
848 case DocSimpleSect::Attention: type = "attention"; break;
849 case DocSimpleSect::User: type = "par"; break;
850 case DocSimpleSect::Rcs: type = "rcs"; break;
851 case DocSimpleSect::Unknown:
852 err("unknown simple section found\n");
861 void PerlModDocVisitor::visitPost(DocSimpleSect *)
865 m_output.closeHash();
868 void PerlModDocVisitor::visitPre(DocTitle *)
871 openSubBlock("content");
874 void PerlModDocVisitor::visitPost(DocTitle *)
880 void PerlModDocVisitor::visitPre(DocSimpleList *)
883 m_output.addFieldQuotedString("style", "itemized");
884 openSubBlock("content");
887 void PerlModDocVisitor::visitPost(DocSimpleList *)
893 void PerlModDocVisitor::visitPre(DocSimpleListItem *) { openSubBlock(); }
894 void PerlModDocVisitor::visitPost(DocSimpleListItem *) { closeSubBlock(); }
896 void PerlModDocVisitor::visitPre(DocSection *s)
898 QCString sect = QCString().sprintf("sect%d",s->level());
900 openSubBlock("content");
903 void PerlModDocVisitor::visitPost(DocSection *)
909 void PerlModDocVisitor::visitPre(DocHtmlList *l)
912 m_output.addFieldQuotedString("style", (l->type() == DocHtmlList::Ordered) ? "ordered" : "itemized");
913 openSubBlock("content");
916 void PerlModDocVisitor::visitPost(DocHtmlList *)
922 void PerlModDocVisitor::visitPre(DocHtmlListItem *) { openSubBlock(); }
923 void PerlModDocVisitor::visitPost(DocHtmlListItem *) { closeSubBlock(); }
925 //void PerlModDocVisitor::visitPre(DocHtmlPre *)
927 // openItem("preformatted");
928 // openSubBlock("content");
929 // //m_insidePre=TRUE;
932 //void PerlModDocVisitor::visitPost(DocHtmlPre *)
934 // //m_insidePre=FALSE;
939 void PerlModDocVisitor::visitPre(DocHtmlDescList *)
942 m_output.add("<variablelist>\n");
946 void PerlModDocVisitor::visitPost(DocHtmlDescList *)
949 m_output.add("</variablelist>\n");
953 void PerlModDocVisitor::visitPre(DocHtmlDescTitle *)
956 m_output.add("<varlistentry><term>");
960 void PerlModDocVisitor::visitPost(DocHtmlDescTitle *)
963 m_output.add("</term></varlistentry>\n");
967 void PerlModDocVisitor::visitPre(DocHtmlDescData *)
970 m_output.add("<listitem>");
974 void PerlModDocVisitor::visitPost(DocHtmlDescData *)
977 m_output.add("</listitem>\n");
981 void PerlModDocVisitor::visitPre(DocHtmlTable *)
984 m_output.add("<table rows=\""); m_output.add(t->numRows());
985 m_output.add("\" cols=\""); m_output.add(t->numCols()); m_output.add("\">");
989 void PerlModDocVisitor::visitPost(DocHtmlTable *)
992 m_output.add("</table>\n");
996 void PerlModDocVisitor::visitPre(DocHtmlRow *)
999 m_output.add("<row>\n");
1003 void PerlModDocVisitor::visitPost(DocHtmlRow *)
1006 m_output.add("</row>\n");
1010 void PerlModDocVisitor::visitPre(DocHtmlCell *)
1013 if (c->isHeading()) m_output.add("<entry thead=\"yes\">"); else m_output.add("<entry thead=\"no\">");
1017 void PerlModDocVisitor::visitPost(DocHtmlCell *)
1020 m_output.add("</entry>");
1024 void PerlModDocVisitor::visitPre(DocHtmlCaption *)
1027 m_output.add("<caption>");
1031 void PerlModDocVisitor::visitPost(DocHtmlCaption *)
1034 m_output.add("</caption>\n");
1038 void PerlModDocVisitor::visitPre(DocInternal *)
1041 m_output.add("<internal>");
1045 void PerlModDocVisitor::visitPost(DocInternal *)
1048 m_output.add("</internal>");
1052 void PerlModDocVisitor::visitPre(DocHRef *)
1055 m_output.add("<ulink url=\""); m_output.add(href->url()); m_output.add("\">");
1059 void PerlModDocVisitor::visitPost(DocHRef *)
1062 m_output.add("</ulink>");
1066 void PerlModDocVisitor::visitPre(DocHtmlHeader *)
1069 m_output.add("<sect"); m_output.add(header->level()); m_output.add(">");
1073 void PerlModDocVisitor::visitPost(DocHtmlHeader *)
1076 m_output.add("</sect"); m_output.add(header->level()); m_output.add(">\n");
1080 void PerlModDocVisitor::visitPre(DocImage *)
1083 m_output.add("<image type=\"");
1086 case DocImage::Html: m_output.add("html"); break;
1087 case DocImage::Latex: m_output.add("latex"); break;
1088 case DocImage::Rtf: m_output.add("rtf"); break;
1092 QCString baseName=img->name();
1094 if ((i=baseName.findRev('/'))!=-1 || (i=baseName.findRev('\\'))!=-1)
1096 baseName=baseName.right(baseName.length()-i-1);
1098 m_output.add(" name=\""); m_output.add(baseName); m_output.add("\"");
1099 if (!img->width().isEmpty())
1101 m_output.add(" width=\"");
1102 m_output.addQuoted(img->width());
1105 else if (!img->height().isEmpty())
1107 m_output.add(" height=\"");
1108 m_output.addQuoted(img->height());
1115 void PerlModDocVisitor::visitPost(DocImage *)
1118 m_output.add("</image>");
1122 void PerlModDocVisitor::visitPre(DocDotFile *)
1125 m_output.add("<dotfile name=\""); m_output.add(df->file()); m_output.add("\">");
1129 void PerlModDocVisitor::visitPost(DocDotFile *)
1132 m_output.add("</dotfile>");
1135 void PerlModDocVisitor::visitPre(DocMscFile *)
1138 m_output.add("<mscfile name=\""); m_output.add(df->file()); m_output.add("\">");
1142 void PerlModDocVisitor::visitPost(DocMscFile *)
1145 m_output.add("<mscfile>");
1149 void PerlModDocVisitor::visitPre(DocDiaFile *)
1152 m_output.add("<diafile name=\""); m_output.add(df->file()); m_output.add("\">");
1156 void PerlModDocVisitor::visitPost(DocDiaFile *)
1159 m_output.add("</diafile>");
1164 void PerlModDocVisitor::visitPre(DocLink *lnk)
1167 addLink(lnk->ref(), lnk->file(), lnk->anchor());
1170 void PerlModDocVisitor::visitPost(DocLink *)
1175 void PerlModDocVisitor::visitPre(DocRef *ref)
1178 if (!ref->hasLinkText())
1179 m_output.addFieldQuotedString("text", ref->targetTitle());
1180 openSubBlock("content");
1183 void PerlModDocVisitor::visitPost(DocRef *)
1189 void PerlModDocVisitor::visitPre(DocSecRefItem *)
1192 m_output.add("<tocitem id=\""); m_output.add(ref->file()); m_output.add("_1"); m_output.add(ref->anchor()); m_output.add("\">");
1196 void PerlModDocVisitor::visitPost(DocSecRefItem *)
1199 m_output.add("</tocitem>");
1203 void PerlModDocVisitor::visitPre(DocSecRefList *)
1206 m_output.add("<toclist>");
1210 void PerlModDocVisitor::visitPost(DocSecRefList *)
1213 m_output.add("</toclist>");
1217 //void PerlModDocVisitor::visitPre(DocLanguage *l)
1219 // openItem("language");
1220 // m_output.addFieldQuotedString("id", l->id());
1223 //void PerlModDocVisitor::visitPost(DocLanguage *)
1228 void PerlModDocVisitor::visitPre(DocParamSect *s)
1231 const char *type = 0;
1234 case DocParamSect::Param: type = "params"; break;
1235 case DocParamSect::RetVal: type = "retvals"; break;
1236 case DocParamSect::Exception: type = "exceptions"; break;
1237 case DocParamSect::TemplateParam: type = "templateparam"; break;
1238 case DocParamSect::Unknown:
1239 err("unknown parameter section found\n");
1246 void PerlModDocVisitor::visitPost(DocParamSect *)
1252 void PerlModDocVisitor::visitPre(DocParamList *pl)
1256 .openList("parameters");
1257 //QStrListIterator li(pl->parameters());
1259 QListIterator<DocNode> li(pl->parameters());
1261 for (li.toFirst();(param=li.current());++li)
1264 if (param->kind()==DocNode::Kind_Word)
1266 s = ((DocWord*)param)->word();
1268 else if (param->kind()==DocNode::Kind_LinkedWord)
1270 s = ((DocLinkedWord*)param)->word();
1273 .addFieldQuotedString("name", s)
1276 m_output.closeList()
1280 void PerlModDocVisitor::visitPost(DocParamList *)
1283 m_output.closeList()
1287 void PerlModDocVisitor::visitPre(DocXRefItem *x)
1290 m_output.add("<xrefsect id=\"");
1291 m_output.add(x->file()); m_output.add("_1"); m_output.add(x->anchor());
1292 m_output.add("\">");
1293 m_output.add("<xreftitle>");
1294 m_output.addQuoted(x->title());
1295 m_output.add("</xreftitle>");
1296 m_output.add("<xrefdescription>");
1298 if (x->title().isEmpty()) return;
1299 openItem("xrefitem");
1300 openSubBlock("content");
1303 void PerlModDocVisitor::visitPost(DocXRefItem *x)
1305 if (x->title().isEmpty()) return;
1309 m_output.add("</xrefdescription>");
1310 m_output.add("</xrefsect>");
1314 void PerlModDocVisitor::visitPre(DocInternalRef *ref)
1317 addLink(0,ref->file(),ref->anchor());
1318 openSubBlock("content");
1321 void PerlModDocVisitor::visitPost(DocInternalRef *)
1327 void PerlModDocVisitor::visitPre(DocCopy *)
1331 void PerlModDocVisitor::visitPost(DocCopy *)
1335 void PerlModDocVisitor::visitPre(DocText *)
1339 void PerlModDocVisitor::visitPost(DocText *)
1343 void PerlModDocVisitor::visitPre(DocHtmlBlockQuote *)
1345 openItem("blockquote");
1346 openSubBlock("content");
1349 void PerlModDocVisitor::visitPost(DocHtmlBlockQuote *)
1355 void PerlModDocVisitor::visitPre(DocVhdlFlow *)
1359 void PerlModDocVisitor::visitPost(DocVhdlFlow *)
1363 void PerlModDocVisitor::visitPre(DocParBlock *)
1367 void PerlModDocVisitor::visitPost(DocParBlock *)
1372 static void addTemplateArgumentList(ArgumentList *al,PerlModOutput &output,const char *)
1377 output.openList("template_parameters");
1378 ArgumentListIterator ali(*al);
1380 for (ali.toFirst();(a=ali.current());++ali)
1383 if (!a->type.isEmpty())
1384 output.addFieldQuotedString("type", a->type);
1385 if (!a->name.isEmpty())
1386 output.addFieldQuotedString("declaration_name", a->name)
1387 .addFieldQuotedString("definition_name", a->name);
1388 if (!a->defval.isEmpty())
1389 output.addFieldQuotedString("default", a->defval);
1396 static void addMemberTemplateLists(MemberDef *md,PerlModOutput &output)
1398 ClassDef *cd = md->getClassDef();
1399 const char *cname = cd ? cd->name().data() : 0;
1400 if (md->templateArguments()) // function template prefix
1401 addTemplateArgumentList(md->templateArguments(),output,cname);
1405 static void addTemplateList(ClassDef *cd,PerlModOutput &output)
1407 addTemplateArgumentList(cd->templateArguments(),output,cd->name());
1410 static void addPerlModDocBlock(PerlModOutput &output,
1412 const QCString &fileName,
1416 const QCString &text)
1418 QCString stext = text.stripWhiteSpace();
1419 if (stext.isEmpty())
1420 output.addField(name).add("{}");
1422 DocNode *root = validatingParseDoc(fileName,lineNr,scope,md,stext,FALSE,0);
1423 output.openHash(name);
1424 PerlModDocVisitor *visitor = new PerlModDocVisitor(output);
1425 root->accept(visitor);
1433 static const char *getProtectionName(Protection prot)
1437 case Public: return "public";
1438 case Protected: return "protected";
1439 case Private: return "private";
1440 case Package: return "package";
1445 static const char *getVirtualnessName(Specifier virt)
1449 case Normal: return "non_virtual";
1450 case Virtual: return "virtual";
1451 case Pure: return "pure_virtual";
1456 static QCString pathDoxyfile;
1457 static QCString pathDoxyExec;
1459 void setPerlModDoxyfile(const QCString &qs)
1462 pathDoxyExec = QDir::currentDirPath().utf8();
1465 class PerlModGenerator
1469 PerlModOutput m_output;
1471 QCString pathDoxyStructurePM;
1472 QCString pathDoxyDocsTex;
1473 QCString pathDoxyFormatTex;
1474 QCString pathDoxyLatexTex;
1475 QCString pathDoxyLatexDVI;
1476 QCString pathDoxyLatexPDF;
1477 QCString pathDoxyStructureTex;
1478 QCString pathDoxyDocsPM;
1479 QCString pathDoxyLatexPL;
1480 QCString pathDoxyLatexStructurePL;
1481 QCString pathDoxyRules;
1482 QCString pathMakefile;
1484 inline PerlModGenerator(bool pretty) : m_output(pretty) { }
1486 void generatePerlModForMember(MemberDef *md, Definition *);
1487 void generatePerlModSection(Definition *d, MemberList *ml,
1488 const char *name, const char *header=0);
1489 void addListOfAllMembers(ClassDef *cd);
1490 void generatePerlModForClass(ClassDef *cd);
1491 void generatePerlModForNamespace(NamespaceDef *nd);
1492 void generatePerlModForFile(FileDef *fd);
1493 void generatePerlModForGroup(GroupDef *gd);
1494 void generatePerlModForPage(PageDef *pi);
1496 bool createOutputFile(QFile &f, const char *s);
1497 bool createOutputDir(QDir &perlModDir);
1498 bool generateDoxyLatexTex();
1499 bool generateDoxyFormatTex();
1500 bool generateDoxyStructurePM();
1501 bool generateDoxyLatexPL();
1502 bool generateDoxyLatexStructurePL();
1503 bool generateDoxyRules();
1504 bool generateMakefile();
1505 bool generatePerlModOutput();
1510 void PerlModGenerator::generatePerlModForMember(MemberDef *md,Definition *)
1512 // + declaration/definition arg lists
1514 // + reimplementedBy
1516 // + const/volatile specifiers
1518 // - source definition
1519 // - source references
1520 // - source referenced by
1522 // - template arguments
1523 // (templateArguments(), definitionTemplateParameterLists())
1527 switch (md->memberType())
1529 case MemberType_Define: memType="define"; break;
1530 case MemberType_EnumValue: memType="enumvalue"; break;
1531 case MemberType_Property: memType="property"; break;
1532 case MemberType_Variable: memType="variable"; break;
1533 case MemberType_Typedef: memType="typedef"; break;
1534 case MemberType_Enumeration: memType="enum"; break;
1535 case MemberType_Function: memType="function"; isFunc=TRUE; break;
1536 case MemberType_Signal: memType="signal"; isFunc=TRUE; break;
1537 //case MemberType_Prototype: memType="prototype"; isFunc=TRUE; break;
1538 case MemberType_Friend: memType="friend"; isFunc=TRUE; break;
1539 case MemberType_DCOP: memType="dcop"; isFunc=TRUE; break;
1540 case MemberType_Slot: memType="slot"; isFunc=TRUE; break;
1541 case MemberType_Event: memType="event"; break;
1542 case MemberType_Interface: memType="interface"; break;
1543 case MemberType_Service: memType="service"; break;
1547 .addFieldQuotedString("kind", memType)
1548 .addFieldQuotedString("name", md->name())
1549 .addFieldQuotedString("virtualness", getVirtualnessName(md->virtualness()))
1550 .addFieldQuotedString("protection", getProtectionName(md->protection()))
1551 .addFieldBoolean("static", md->isStatic());
1553 addPerlModDocBlock(m_output,"brief",md->getDefFileName(),md->getDefLine(),md->getOuterScope(),md,md->briefDescription());
1554 addPerlModDocBlock(m_output,"detailed",md->getDefFileName(),md->getDefLine(),md->getOuterScope(),md,md->documentation());
1555 if (md->memberType()!=MemberType_Define &&
1556 md->memberType()!=MemberType_Enumeration)
1557 m_output.addFieldQuotedString("type", md->typeString());
1559 ArgumentList *al = md->argumentList();
1560 if (isFunc) //function
1562 m_output.addFieldBoolean("const", al!=0 && al->constSpecifier)
1563 .addFieldBoolean("volatile", al!=0 && al->volatileSpecifier);
1565 m_output.openList("parameters");
1566 ArgumentList *declAl = md->declArgumentList();
1567 ArgumentList *defAl = md->argumentList();
1568 if (declAl && declAl->count()>0)
1570 ArgumentListIterator declAli(*declAl);
1571 ArgumentListIterator defAli(*defAl);
1573 for (declAli.toFirst();(a=declAli.current());++declAli)
1575 Argument *defArg = defAli.current();
1576 m_output.openHash();
1578 if (!a->name.isEmpty())
1579 m_output.addFieldQuotedString("declaration_name", a->name);
1581 if (defArg && !defArg->name.isEmpty() && defArg->name!=a->name)
1582 m_output.addFieldQuotedString("definition_name", defArg->name);
1584 if (!a->type.isEmpty())
1585 m_output.addFieldQuotedString("type", a->type);
1587 if (!a->array.isEmpty())
1588 m_output.addFieldQuotedString("array", a->array);
1590 if (!a->defval.isEmpty())
1591 m_output.addFieldQuotedString("default_value", a->defval);
1593 if (!a->attrib.isEmpty())
1594 m_output.addFieldQuotedString("attributes", a->attrib);
1596 m_output.closeHash();
1597 if (defArg) ++defAli;
1600 m_output.closeList();
1602 else if (md->memberType()==MemberType_Define &&
1603 md->argsString()!=0) // define
1605 m_output.openList("parameters");
1606 ArgumentListIterator ali(*al);
1608 for (ali.toFirst();(a=ali.current());++ali)
1611 .addFieldQuotedString("name", a->type)
1614 m_output.closeList();
1616 else if (md->argsString()!=0)
1618 m_output.addFieldQuotedString("arguments", md->argsString());
1621 if (!md->initializer().isEmpty())
1622 m_output.addFieldQuotedString("initializer", md->initializer());
1624 if (md->excpString())
1625 m_output.addFieldQuotedString("exceptions", md->excpString());
1627 if (md->memberType()==MemberType_Enumeration) // enum
1629 MemberList *enumFields = md->enumFieldList();
1632 m_output.openList("values");
1633 MemberListIterator emli(*enumFields);
1635 for (emli.toFirst();(emd=emli.current());++emli)
1638 .addFieldQuotedString("name", emd->name());
1640 if (!emd->initializer().isEmpty())
1641 m_output.addFieldQuotedString("initializer", emd->initializer());
1643 addPerlModDocBlock(m_output,"brief",emd->getDefFileName(),emd->getDefLine(),emd->getOuterScope(),emd,emd->briefDescription());
1645 addPerlModDocBlock(m_output,"detailed",emd->getDefFileName(),emd->getDefLine(),emd->getOuterScope(),emd,emd->documentation());
1647 m_output.closeHash();
1649 m_output.closeList();
1653 MemberDef *rmd = md->reimplements();
1655 m_output.openHash("reimplements")
1656 .addFieldQuotedString("name", rmd->name())
1659 MemberList *rbml = md->reimplementedBy();
1662 MemberListIterator mli(*rbml);
1663 m_output.openList("reimplemented_by");
1664 for (mli.toFirst();(rmd=mli.current());++mli)
1666 .addFieldQuotedString("name", rmd->name())
1668 m_output.closeList();
1671 m_output.closeHash();
1674 void PerlModGenerator::generatePerlModSection(Definition *d,
1675 MemberList *ml,const char *name,const char *header)
1677 if (ml==0) return; // empty list
1679 m_output.openHash(name);
1682 m_output.addFieldQuotedString("header", header);
1684 m_output.openList("members");
1685 MemberListIterator mli(*ml);
1687 for (mli.toFirst();(md=mli.current());++mli)
1689 generatePerlModForMember(md,d);
1691 m_output.closeList()
1695 void PerlModGenerator::addListOfAllMembers(ClassDef *cd)
1697 m_output.openList("all_members");
1698 if (cd->memberNameInfoSDict())
1700 MemberNameInfoSDict::Iterator mnii(*cd->memberNameInfoSDict());
1701 MemberNameInfo *mni;
1702 for (mnii.toFirst();(mni=mnii.current());++mnii)
1704 MemberNameInfoIterator mii(*mni);
1706 for (mii.toFirst();(mi=mii.current());++mii)
1708 MemberDef *md=mi->memberDef;
1709 ClassDef *cd=md->getClassDef();
1710 Definition *d=md->getGroupDef();
1714 .addFieldQuotedString("name", md->name())
1715 .addFieldQuotedString("virtualness", getVirtualnessName(md->virtualness()))
1716 .addFieldQuotedString("protection", getProtectionName(mi->prot));
1718 if (!mi->ambiguityResolutionScope.isEmpty())
1719 m_output.addFieldQuotedString("ambiguity_scope", mi->ambiguityResolutionScope);
1721 m_output.addFieldQuotedString("scope", cd->name())
1726 m_output.closeList();
1729 void PerlModGenerator::generatePerlModForClass(ClassDef *cd)
1731 // + brief description
1732 // + detailed description
1733 // + template argument list(s)
1736 // + inheritance diagram
1737 // + list of direct super classes
1738 // + list of direct sub classes
1739 // + list of inner classes
1740 // + collaboration diagram
1741 // + list of all members
1742 // + user defined member sections
1743 // + standard member sections
1744 // + detailed member documentation
1745 // - examples using the class
1747 if (cd->isReference()) return; // skip external references.
1748 if (cd->name().find('@')!=-1) return; // skip anonymous compounds.
1749 if (cd->templateMaster()!=0) return; // skip generated template instances.
1752 .addFieldQuotedString("name", cd->name());
1754 if (cd->baseClasses())
1756 m_output.openList("base");
1757 BaseClassListIterator bcli(*cd->baseClasses());
1759 for (bcli.toFirst();(bcd=bcli.current());++bcli)
1761 .addFieldQuotedString("name", bcd->classDef->displayName())
1762 .addFieldQuotedString("virtualness", getVirtualnessName(bcd->virt))
1763 .addFieldQuotedString("protection", getProtectionName(bcd->prot))
1765 m_output.closeList();
1768 if (cd->subClasses())
1770 m_output.openList("derived");
1771 BaseClassListIterator bcli(*cd->subClasses());
1773 for (bcli.toFirst();(bcd=bcli.current());++bcli)
1775 .addFieldQuotedString("name", bcd->classDef->displayName())
1776 .addFieldQuotedString("virtualness", getVirtualnessName(bcd->virt))
1777 .addFieldQuotedString("protection", getProtectionName(bcd->prot))
1779 m_output.closeList();
1782 ClassSDict *cl = cd->getClassSDict();
1785 m_output.openList("inner");
1786 ClassSDict::Iterator cli(*cl);
1788 for (cli.toFirst();(cd=cli.current());++cli)
1790 .addFieldQuotedString("name", cd->name())
1792 m_output.closeList();
1795 IncludeInfo *ii=cd->includeInfo();
1798 QCString nm = ii->includeName;
1799 if (nm.isEmpty() && ii->fileDef) nm = ii->fileDef->docName();
1802 m_output.openHash("includes");
1804 if (ii->fileDef && !ii->fileDef->isReference()) // TODO: support external references
1805 t << " id=\"" << ii->fileDef->getOutputFileBase() << "\"";
1807 m_output.addFieldBoolean("local", ii->local)
1808 .addFieldQuotedString("name", nm)
1813 addTemplateList(cd,m_output);
1814 addListOfAllMembers(cd);
1815 if (cd->getMemberGroupSDict())
1817 MemberGroupSDict::Iterator mgli(*cd->getMemberGroupSDict());
1819 for (;(mg=mgli.current());++mgli)
1820 generatePerlModSection(cd,mg->members(),"user_defined",mg->header());
1823 generatePerlModSection(cd,cd->getMemberList(MemberListType_pubTypes),"public_typedefs");
1824 generatePerlModSection(cd,cd->getMemberList(MemberListType_pubMethods),"public_methods");
1825 generatePerlModSection(cd,cd->getMemberList(MemberListType_pubAttribs),"public_members");
1826 generatePerlModSection(cd,cd->getMemberList(MemberListType_pubSlots),"public_slots");
1827 generatePerlModSection(cd,cd->getMemberList(MemberListType_signals),"signals");
1828 generatePerlModSection(cd,cd->getMemberList(MemberListType_dcopMethods),"dcop_methods");
1829 generatePerlModSection(cd,cd->getMemberList(MemberListType_properties),"properties");
1830 generatePerlModSection(cd,cd->getMemberList(MemberListType_pubStaticMethods),"public_static_methods");
1831 generatePerlModSection(cd,cd->getMemberList(MemberListType_pubStaticAttribs),"public_static_members");
1832 generatePerlModSection(cd,cd->getMemberList(MemberListType_proTypes),"protected_typedefs");
1833 generatePerlModSection(cd,cd->getMemberList(MemberListType_proMethods),"protected_methods");
1834 generatePerlModSection(cd,cd->getMemberList(MemberListType_proAttribs),"protected_members");
1835 generatePerlModSection(cd,cd->getMemberList(MemberListType_proSlots),"protected_slots");
1836 generatePerlModSection(cd,cd->getMemberList(MemberListType_proStaticMethods),"protected_static_methods");
1837 generatePerlModSection(cd,cd->getMemberList(MemberListType_proStaticAttribs),"protected_static_members");
1838 generatePerlModSection(cd,cd->getMemberList(MemberListType_priTypes),"private_typedefs");
1839 generatePerlModSection(cd,cd->getMemberList(MemberListType_priMethods),"private_methods");
1840 generatePerlModSection(cd,cd->getMemberList(MemberListType_priAttribs),"private_members");
1841 generatePerlModSection(cd,cd->getMemberList(MemberListType_priSlots),"private_slots");
1842 generatePerlModSection(cd,cd->getMemberList(MemberListType_priStaticMethods),"private_static_methods");
1843 generatePerlModSection(cd,cd->getMemberList(MemberListType_priStaticAttribs),"private_static_members");
1844 generatePerlModSection(cd,cd->getMemberList(MemberListType_friends),"friend_methods");
1845 generatePerlModSection(cd,cd->getMemberList(MemberListType_related),"related_methods");
1847 addPerlModDocBlock(m_output,"brief",cd->getDefFileName(),cd->getDefLine(),cd,0,cd->briefDescription());
1848 addPerlModDocBlock(m_output,"detailed",cd->getDefFileName(),cd->getDefLine(),cd,0,cd->documentation());
1851 DotClassGraph inheritanceGraph(cd,DotClassGraph::Inheritance);
1852 if (!inheritanceGraph.isTrivial())
1854 t << " <inheritancegraph>" << endl;
1855 inheritanceGraph.writePerlMod(t);
1856 t << " </inheritancegraph>" << endl;
1858 DotClassGraph collaborationGraph(cd,DotClassGraph::Implementation);
1859 if (!collaborationGraph.isTrivial())
1861 t << " <collaborationgraph>" << endl;
1862 collaborationGraph.writePerlMod(t);
1863 t << " </collaborationgraph>" << endl;
1865 t << " <location file=\""
1866 << cd->getDefFileName() << "\" line=\""
1867 << cd->getDefLine() << "\"";
1868 if (cd->getStartBodyLine()!=-1)
1870 t << " bodystart=\"" << cd->getStartBodyLine() << "\" bodyend=\""
1871 << cd->getEndBodyLine() << "\"";
1876 m_output.closeHash();
1879 void PerlModGenerator::generatePerlModForNamespace(NamespaceDef *nd)
1881 // + contained class definitions
1882 // + contained namespace definitions
1888 // - files containing (parts of) the namespace definition
1890 if (nd->isReference()) return; // skip external references
1893 .addFieldQuotedString("name", nd->name());
1895 ClassSDict *cl = nd->getClassSDict();
1898 m_output.openList("classes");
1899 ClassSDict::Iterator cli(*cl);
1901 for (cli.toFirst();(cd=cli.current());++cli)
1903 .addFieldQuotedString("name", cd->name())
1905 m_output.closeList();
1908 NamespaceSDict *nl = nd->getNamespaceSDict();
1911 m_output.openList("namespaces");
1912 NamespaceSDict::Iterator nli(*nl);
1914 for (nli.toFirst();(nd=nli.current());++nli)
1916 .addFieldQuotedString("name", nd->name())
1918 m_output.closeList();
1921 if (nd->getMemberGroupSDict())
1923 MemberGroupSDict::Iterator mgli(*nd->getMemberGroupSDict());
1925 for (;(mg=mgli.current());++mgli)
1926 generatePerlModSection(nd,mg->members(),"user-defined",mg->header());
1929 generatePerlModSection(nd,nd->getMemberList(MemberListType_decDefineMembers),"defines");
1930 generatePerlModSection(nd,nd->getMemberList(MemberListType_decProtoMembers),"prototypes");
1931 generatePerlModSection(nd,nd->getMemberList(MemberListType_decTypedefMembers),"typedefs");
1932 generatePerlModSection(nd,nd->getMemberList(MemberListType_decEnumMembers),"enums");
1933 generatePerlModSection(nd,nd->getMemberList(MemberListType_decFuncMembers),"functions");
1934 generatePerlModSection(nd,nd->getMemberList(MemberListType_decVarMembers),"variables");
1936 addPerlModDocBlock(m_output,"brief",nd->getDefFileName(),nd->getDefLine(),0,0,nd->briefDescription());
1937 addPerlModDocBlock(m_output,"detailed",nd->getDefFileName(),nd->getDefLine(),0,0,nd->documentation());
1939 m_output.closeHash();
1942 void PerlModGenerator::generatePerlModForFile(FileDef *fd)
1945 // + includedby files
1947 // - included by graph
1948 // - contained class definitions
1949 // - contained namespace definitions
1956 // - number of lines
1958 if (fd->isReference()) return;
1961 .addFieldQuotedString("name", fd->name());
1964 m_output.openList("includes");
1965 if (fd->includeFileList())
1967 QListIterator<IncludeInfo> ili1(*fd->includeFileList());
1968 for (ili1.toFirst();(inc=ili1.current());++ili1)
1971 .addFieldQuotedString("name", inc->includeName);
1972 if (inc->fileDef && !inc->fileDef->isReference())
1974 m_output.addFieldQuotedString("ref", inc->fileDef->getOutputFileBase());
1976 m_output.closeHash();
1979 m_output.closeList();
1981 m_output.openList("included_by");
1982 if (fd->includedByFileList())
1984 QListIterator<IncludeInfo> ili2(*fd->includedByFileList());
1985 for (ili2.toFirst();(inc=ili2.current());++ili2)
1988 .addFieldQuotedString("name", inc->includeName);
1989 if (inc->fileDef && !inc->fileDef->isReference())
1991 m_output.addFieldQuotedString("ref", inc->fileDef->getOutputFileBase());
1993 m_output.closeHash();
1996 m_output.closeList();
1998 generatePerlModSection(fd,fd->getMemberList(MemberListType_decDefineMembers),"defines");
1999 generatePerlModSection(fd,fd->getMemberList(MemberListType_decProtoMembers),"prototypes");
2000 generatePerlModSection(fd,fd->getMemberList(MemberListType_decTypedefMembers),"typedefs");
2001 generatePerlModSection(fd,fd->getMemberList(MemberListType_decEnumMembers),"enums");
2002 generatePerlModSection(fd,fd->getMemberList(MemberListType_decFuncMembers),"functions");
2003 generatePerlModSection(fd,fd->getMemberList(MemberListType_decVarMembers),"variables");
2005 addPerlModDocBlock(m_output,"brief",fd->getDefFileName(),fd->getDefLine(),0,0,fd->briefDescription());
2006 addPerlModDocBlock(m_output,"detailed",fd->getDefFileName(),fd->getDefLine(),0,0,fd->documentation());
2008 m_output.closeHash();
2011 void PerlModGenerator::generatePerlModForGroup(GroupDef *gd)
2022 // + brief description
2023 // + detailed description
2025 if (gd->isReference()) return; // skip external references
2028 .addFieldQuotedString("name", gd->name())
2029 .addFieldQuotedString("title", gd->groupTitle());
2031 FileList *fl = gd->getFiles();
2034 m_output.openList("files");
2035 QListIterator<FileDef> fli(*fl);
2037 for (fli.toFirst();(fd=fli.current());++fli)
2039 .addFieldQuotedString("name", fd->name())
2041 m_output.closeList();
2044 ClassSDict *cl = gd->getClasses();
2047 m_output.openList("classes");
2048 ClassSDict::Iterator cli(*cl);
2050 for (cli.toFirst();(cd=cli.current());++cli)
2052 .addFieldQuotedString("name", cd->name())
2054 m_output.closeList();
2057 NamespaceSDict *nl = gd->getNamespaces();
2060 m_output.openList("namespaces");
2061 NamespaceSDict::Iterator nli(*nl);
2063 for (nli.toFirst();(nd=nli.current());++nli)
2065 .addFieldQuotedString("name", nd->name())
2067 m_output.closeList();
2070 PageSDict *pl = gd->getPages();
2073 m_output.openList("pages");
2074 PageSDict::Iterator pli(*pl);
2076 for (pli.toFirst();(pd=pli.current());++pli)
2078 .addFieldQuotedString("title", pd->title())
2080 m_output.closeList();
2083 GroupList *gl = gd->getSubGroups();
2086 m_output.openList("groups");
2087 GroupListIterator gli(*gl);
2089 for (gli.toFirst();(sgd=gli.current());++gli)
2091 .addFieldQuotedString("title", sgd->groupTitle())
2093 m_output.closeList();
2096 if (gd->getMemberGroupSDict())
2098 MemberGroupSDict::Iterator mgli(*gd->getMemberGroupSDict());
2100 for (;(mg=mgli.current());++mgli)
2101 generatePerlModSection(gd,mg->members(),"user-defined",mg->header());
2104 generatePerlModSection(gd,gd->getMemberList(MemberListType_decDefineMembers),"defines");
2105 generatePerlModSection(gd,gd->getMemberList(MemberListType_decProtoMembers),"prototypes");
2106 generatePerlModSection(gd,gd->getMemberList(MemberListType_decTypedefMembers),"typedefs");
2107 generatePerlModSection(gd,gd->getMemberList(MemberListType_decEnumMembers),"enums");
2108 generatePerlModSection(gd,gd->getMemberList(MemberListType_decFuncMembers),"functions");
2109 generatePerlModSection(gd,gd->getMemberList(MemberListType_decVarMembers),"variables");
2111 addPerlModDocBlock(m_output,"brief",gd->getDefFileName(),gd->getDefLine(),0,0,gd->briefDescription());
2112 addPerlModDocBlock(m_output,"detailed",gd->getDefFileName(),gd->getDefLine(),0,0,gd->documentation());
2114 m_output.closeHash();
2117 void PerlModGenerator::generatePerlModForPage(PageDef *pd)
2123 if (pd->isReference()) return;
2126 .addFieldQuotedString("name", pd->name());
2128 SectionInfo *si = Doxygen::sectionDict->find(pd->name());
2130 m_output.addFieldQuotedString("title4", filterTitle(si->title));
2132 addPerlModDocBlock(m_output,"detailed",pd->docFile(),pd->docLine(),0,0,pd->documentation());
2133 m_output.closeHash();
2136 bool PerlModGenerator::generatePerlModOutput()
2139 if (!createOutputFile(outputFile, pathDoxyDocsPM))
2142 FTextStream outputTextStream(&outputFile);
2143 PerlModOutputStream outputStream(&outputTextStream);
2144 m_output.setPerlModOutputStream(&outputStream);
2145 m_output.add("$doxydocs=").openHash();
2147 m_output.openList("classes");
2148 ClassSDict::Iterator cli(*Doxygen::classSDict);
2150 for (cli.toFirst();(cd=cli.current());++cli)
2151 generatePerlModForClass(cd);
2152 m_output.closeList();
2154 m_output.openList("namespaces");
2155 NamespaceSDict::Iterator nli(*Doxygen::namespaceSDict);
2157 for (nli.toFirst();(nd=nli.current());++nli)
2158 generatePerlModForNamespace(nd);
2159 m_output.closeList();
2161 m_output.openList("files");
2162 FileNameListIterator fnli(*Doxygen::inputNameList);
2164 for (;(fn=fnli.current());++fnli)
2166 FileNameIterator fni(*fn);
2168 for (;(fd=fni.current());++fni)
2169 generatePerlModForFile(fd);
2171 m_output.closeList();
2173 m_output.openList("groups");
2174 GroupSDict::Iterator gli(*Doxygen::groupSDict);
2176 for (;(gd=gli.current());++gli)
2178 generatePerlModForGroup(gd);
2180 m_output.closeList();
2182 m_output.openList("pages");
2183 PageSDict::Iterator pdi(*Doxygen::pageSDict);
2185 for (pdi.toFirst();(pd=pdi.current());++pdi)
2187 generatePerlModForPage(pd);
2189 if (Doxygen::mainPage)
2191 generatePerlModForPage(Doxygen::mainPage);
2193 m_output.closeList();
2195 m_output.closeHash().add(";\n1;\n");
2199 bool PerlModGenerator::createOutputFile(QFile &f, const char *s)
2202 if (!f.open(IO_WriteOnly))
2204 err("Cannot open file %s for writing!\n", s);
2210 bool PerlModGenerator::createOutputDir(QDir &perlModDir)
2212 QCString outputDirectory = Config_getString("OUTPUT_DIRECTORY");
2213 if (outputDirectory.isEmpty())
2215 outputDirectory=QDir::currentDirPath().utf8();
2219 QDir dir(outputDirectory);
2222 dir.setPath(QDir::currentDirPath());
2223 if (!dir.mkdir(outputDirectory))
2225 err("tag OUTPUT_DIRECTORY: Output directory `%s' does not "
2226 "exist and cannot be created\n",outputDirectory.data());
2231 msg("Notice: Output directory `%s' does not exist. "
2232 "I have created it for you.\n", outputDirectory.data());
2234 dir.cd(outputDirectory);
2236 outputDirectory=dir.absPath().utf8();
2239 QDir dir(outputDirectory);
2242 dir.setPath(QDir::currentDirPath());
2243 if (!dir.mkdir(outputDirectory))
2245 err("Cannot create directory %s\n",outputDirectory.data());
2250 perlModDir.setPath(outputDirectory+"/perlmod");
2251 if (!perlModDir.exists() && !perlModDir.mkdir(outputDirectory+"/perlmod"))
2253 err("Could not create perlmod directory in %s\n",outputDirectory.data());
2259 bool PerlModGenerator::generateDoxyStructurePM()
2262 if (!createOutputFile(doxyModelPM, pathDoxyStructurePM))
2265 FTextStream doxyModelPMStream(&doxyModelPM);
2266 doxyModelPMStream <<
2267 "sub memberlist($) {\n"
2268 " my $prefix = $_[0];\n"
2270 "\t[ \"hash\", $prefix . \"s\",\n"
2273 "\t [ \"list\", $prefix . \"List\",\n"
2274 "\t\t[ \"hash\", $prefix,\n"
2276 "\t\t kind => [ \"string\", $prefix . \"Kind\" ],\n"
2277 "\t\t name => [ \"string\", $prefix . \"Name\" ],\n"
2278 "\t\t static => [ \"string\", $prefix . \"Static\" ],\n"
2279 "\t\t virtualness => [ \"string\", $prefix . \"Virtualness\" ],\n"
2280 "\t\t protection => [ \"string\", $prefix . \"Protection\" ],\n"
2281 "\t\t type => [ \"string\", $prefix . \"Type\" ],\n"
2282 "\t\t parameters =>\n"
2283 "\t\t [ \"list\", $prefix . \"Params\",\n"
2284 "\t\t\t[ \"hash\", $prefix . \"Param\",\n"
2286 "\t\t\t declaration_name => [ \"string\", $prefix . \"ParamName\" ],\n"
2287 "\t\t\t type => [ \"string\", $prefix . \"ParamType\" ],\n"
2291 "\t\t detailed =>\n"
2292 "\t\t [ \"hash\", $prefix . \"Detailed\",\n"
2294 "\t\t\t doc => [ \"doc\", $prefix . \"DetailedDoc\" ],\n"
2295 "\t\t\t return => [ \"doc\", $prefix . \"Return\" ],\n"
2296 "\t\t\t see => [ \"doc\", $prefix . \"See\" ],\n"
2297 "\t\t\t params =>\n"
2298 "\t\t\t [ \"list\", $prefix . \"PDBlocks\",\n"
2299 "\t\t\t [ \"hash\", $prefix . \"PDBlock\",\n"
2301 "\t\t\t\t parameters =>\n"
2302 "\t\t\t\t [ \"list\", $prefix . \"PDParams\",\n"
2303 "\t\t\t\t [ \"hash\", $prefix . \"PDParam\",\n"
2305 "\t\t\t\t\t name => [ \"string\", $prefix . \"PDParamName\" ],\n"
2309 "\t\t\t\t doc => [ \"doc\", $prefix . \"PDDoc\" ],\n"
2322 "$doxystructure =\n"
2323 " [ \"hash\", \"Root\",\n"
2326 "\t [ \"list\", \"Files\",\n"
2327 "\t [ \"hash\", \"File\",\n"
2329 "\t\tname => [ \"string\", \"FileName\" ],\n"
2330 "\t\ttypedefs => memberlist(\"FileTypedef\"),\n"
2331 "\t\tvariables => memberlist(\"FileVariable\"),\n"
2332 "\t\tfunctions => memberlist(\"FileFunction\"),\n"
2334 "\t\t [ \"hash\", \"FileDetailed\",\n"
2336 "\t\t doc => [ \"doc\", \"FileDetailedDoc\" ],\n"
2343 "\t [ \"list\", \"Pages\",\n"
2344 "\t [ \"hash\", \"Page\",\n"
2346 "\t\tname => [ \"string\", \"PageName\" ],\n"
2348 "\t\t [ \"hash\", \"PageDetailed\",\n"
2350 "\t\t doc => [ \"doc\", \"PageDetailedDoc\" ],\n"
2357 "\t [ \"list\", \"Classes\",\n"
2358 "\t [ \"hash\", \"Class\",\n"
2360 "\t\tname => [ \"string\", \"ClassName\" ],\n"
2361 "\t\tpublic_typedefs => memberlist(\"ClassPublicTypedef\"),\n"
2362 "\t\tpublic_methods => memberlist(\"ClassPublicMethod\"),\n"
2363 "\t\tpublic_members => memberlist(\"ClassPublicMember\"),\n"
2364 "\t\tprotected_typedefs => memberlist(\"ClassProtectedTypedef\"),\n"
2365 "\t\tprotected_methods => memberlist(\"ClassProtectedMethod\"),\n"
2366 "\t\tprotected_members => memberlist(\"ClassProtectedMember\"),\n"
2367 "\t\tprivate_typedefs => memberlist(\"ClassPrivateTypedef\"),\n"
2368 "\t\tprivate_methods => memberlist(\"ClassPrivateMethod\"),\n"
2369 "\t\tprivate_members => memberlist(\"ClassPrivateMember\"),\n"
2371 "\t\t [ \"hash\", \"ClassDetailed\",\n"
2373 "\t\t doc => [ \"doc\", \"ClassDetailedDoc\" ],\n"
2380 "\t [ \"list\", \"Groups\",\n"
2381 "\t [ \"hash\", \"Group\",\n"
2383 "\t\tname => [ \"string\", \"GroupName\" ],\n"
2384 "\t\ttitle => [ \"string\", \"GroupTitle\" ],\n"
2386 "\t\t [ \"list\", \"Files\",\n"
2387 "\t\t [ \"hash\", \"File\",\n"
2389 "\t\t name => [ \"string\", \"Filename\" ]\n"
2394 "\t\t [ \"list\", \"Classes\",\n"
2395 "\t\t [ \"hash\", \"Class\",\n"
2397 "\t\t name => [ \"string\", \"Classname\" ]\n"
2401 "\t\tnamespaces =>\n"
2402 "\t\t [ \"list\", \"Namespaces\",\n"
2403 "\t\t [ \"hash\", \"Namespace\",\n"
2405 "\t\t name => [ \"string\", \"NamespaceName\" ]\n"
2410 "\t\t [ \"list\", \"Pages\",\n"
2411 "\t\t [ \"hash\", \"Page\","
2413 "\t\t title => [ \"string\", \"PageName\" ]\n"
2418 "\t\t [ \"list\", \"Groups\",\n"
2419 "\t\t [ \"hash\", \"Group\",\n"
2421 "\t\t title => [ \"string\", \"GroupName\" ]\n"
2425 "\t\tfunctions => memberlist(\"GroupFunction\"),\n"
2427 "\t\t [ \"hash\", \"GroupDetailed\",\n"
2429 "\t\t doc => [ \"doc\", \"GroupDetailedDoc\" ],\n"
2443 bool PerlModGenerator::generateDoxyRules()
2446 if (!createOutputFile(doxyRules, pathDoxyRules))
2449 bool perlmodLatex = Config_getBool("PERLMOD_LATEX");
2450 QCString prefix = Config_getString("PERLMOD_MAKEVAR_PREFIX");
2452 FTextStream doxyRulesStream(&doxyRules);
2454 prefix << "DOXY_EXEC_PATH = " << pathDoxyExec << "\n" <<
2455 prefix << "DOXYFILE = " << pathDoxyfile << "\n" <<
2456 prefix << "DOXYDOCS_PM = " << pathDoxyDocsPM << "\n" <<
2457 prefix << "DOXYSTRUCTURE_PM = " << pathDoxyStructurePM << "\n" <<
2458 prefix << "DOXYRULES = " << pathDoxyRules << "\n";
2461 prefix << "DOXYLATEX_PL = " << pathDoxyLatexPL << "\n" <<
2462 prefix << "DOXYLATEXSTRUCTURE_PL = " << pathDoxyLatexStructurePL << "\n" <<
2463 prefix << "DOXYSTRUCTURE_TEX = " << pathDoxyStructureTex << "\n" <<
2464 prefix << "DOXYDOCS_TEX = " << pathDoxyDocsTex << "\n" <<
2465 prefix << "DOXYFORMAT_TEX = " << pathDoxyFormatTex << "\n" <<
2466 prefix << "DOXYLATEX_TEX = " << pathDoxyLatexTex << "\n" <<
2467 prefix << "DOXYLATEX_DVI = " << pathDoxyLatexDVI << "\n" <<
2468 prefix << "DOXYLATEX_PDF = " << pathDoxyLatexPDF << "\n";
2472 ".PHONY: clean-perlmod\n"
2474 "\trm -f $(" << prefix << "DOXYSTRUCTURE_PM) \\\n"
2475 "\t$(" << prefix << "DOXYDOCS_PM)";
2479 "\t$(" << prefix << "DOXYLATEX_PL) \\\n"
2480 "\t$(" << prefix << "DOXYLATEXSTRUCTURE_PL) \\\n"
2481 "\t$(" << prefix << "DOXYDOCS_TEX) \\\n"
2482 "\t$(" << prefix << "DOXYSTRUCTURE_TEX) \\\n"
2483 "\t$(" << prefix << "DOXYFORMAT_TEX) \\\n"
2484 "\t$(" << prefix << "DOXYLATEX_TEX) \\\n"
2485 "\t$(" << prefix << "DOXYLATEX_PDF) \\\n"
2486 "\t$(" << prefix << "DOXYLATEX_DVI) \\\n"
2487 "\t$(addprefix $(" << prefix << "DOXYLATEX_TEX:tex=),out aux log)";
2488 doxyRulesStream << "\n\n";
2491 "$(" << prefix << "DOXYRULES) \\\n"
2492 "$(" << prefix << "DOXYMAKEFILE) \\\n"
2493 "$(" << prefix << "DOXYSTRUCTURE_PM) \\\n"
2494 "$(" << prefix << "DOXYDOCS_PM)";
2498 "$(" << prefix << "DOXYLATEX_PL) \\\n"
2499 "$(" << prefix << "DOXYLATEXSTRUCTURE_PL) \\\n"
2500 "$(" << prefix << "DOXYFORMAT_TEX) \\\n"
2501 "$(" << prefix << "DOXYLATEX_TEX)";
2505 "\t$(" << prefix << "DOXYFILE)\n"
2506 "\tcd $(" << prefix << "DOXY_EXEC_PATH) ; doxygen \"$<\"\n";
2511 "$(" << prefix << "DOXYDOCS_TEX): \\\n"
2512 "$(" << prefix << "DOXYLATEX_PL) \\\n"
2513 "$(" << prefix << "DOXYDOCS_PM)\n"
2514 "\tperl -I\"$(<D)\" \"$<\" >\"$@\"\n"
2516 "$(" << prefix << "DOXYSTRUCTURE_TEX): \\\n"
2517 "$(" << prefix << "DOXYLATEXSTRUCTURE_PL) \\\n"
2518 "$(" << prefix << "DOXYSTRUCTURE_PM)\n"
2519 "\tperl -I\"$(<D)\" \"$<\" >\"$@\"\n"
2521 "$(" << prefix << "DOXYLATEX_PDF) \\\n"
2522 "$(" << prefix << "DOXYLATEX_DVI): \\\n"
2523 "$(" << prefix << "DOXYLATEX_TEX) \\\n"
2524 "$(" << prefix << "DOXYFORMAT_TEX) \\\n"
2525 "$(" << prefix << "DOXYSTRUCTURE_TEX) \\\n"
2526 "$(" << prefix << "DOXYDOCS_TEX)\n"
2528 "$(" << prefix << "DOXYLATEX_PDF): \\\n"
2529 "$(" << prefix << "DOXYLATEX_TEX)\n"
2530 "\tpdflatex -interaction=nonstopmode \"$<\"\n"
2532 "$(" << prefix << "DOXYLATEX_DVI): \\\n"
2533 "$(" << prefix << "DOXYLATEX_TEX)\n"
2534 "\tlatex -interaction=nonstopmode \"$<\"\n";
2540 bool PerlModGenerator::generateMakefile()
2543 if (!createOutputFile(makefile, pathMakefile))
2546 bool perlmodLatex = Config_getBool("PERLMOD_LATEX");
2547 QCString prefix = Config_getString("PERLMOD_MAKEVAR_PREFIX");
2549 FTextStream makefileStream(&makefile);
2551 ".PHONY: default clean" << (perlmodLatex ? " pdf" : "") << "\n"
2552 "default: " << (perlmodLatex ? "pdf" : "clean") << "\n"
2554 "include " << pathDoxyRules << "\n"
2556 "clean: clean-perlmod\n";
2560 "pdf: $(" << prefix << "DOXYLATEX_PDF)\n"
2561 "dvi: $(" << prefix << "DOXYLATEX_DVI)\n";
2567 bool PerlModGenerator::generateDoxyLatexStructurePL()
2569 QFile doxyLatexStructurePL;
2570 if (!createOutputFile(doxyLatexStructurePL, pathDoxyLatexStructurePL))
2573 FTextStream doxyLatexStructurePLStream(&doxyLatexStructurePL);
2574 doxyLatexStructurePLStream <<
2575 "use DoxyStructure;\n"
2577 "sub process($) {\n"
2578 "\tmy $node = $_[0];\n"
2579 "\tmy ($type, $name) = @$node[0, 1];\n"
2581 "\tif ($type eq \"string\") { $command = \"String\" }\n"
2582 "\telsif ($type eq \"doc\") { $command = \"Doc\" }\n"
2583 "\telsif ($type eq \"hash\") {\n"
2584 "\t\t$command = \"Hash\";\n"
2585 "\t\tfor my $subnode (values %{$$node[2]}) {\n"
2586 "\t\t\tprocess($subnode);\n"
2589 "\telsif ($type eq \"list\") {\n"
2590 "\t\t$command = \"List\";\n"
2591 "\t\tprocess($$node[2]);\n"
2593 "\tprint \"\\\\\" . $command . \"Node{\" . $name . \"}%\\n\";\n"
2596 "process($doxystructure);\n";
2601 bool PerlModGenerator::generateDoxyLatexPL()
2604 if (!createOutputFile(doxyLatexPL, pathDoxyLatexPL))
2607 FTextStream doxyLatexPLStream(&doxyLatexPL);
2608 doxyLatexPLStream <<
2609 "use DoxyStructure;\n"
2612 "sub latex_quote($) {\n"
2613 "\tmy $text = $_[0];\n"
2614 "\t$text =~ s/\\\\/\\\\textbackslash /g;\n"
2615 "\t$text =~ s/\\|/\\\\textbar /g;\n"
2616 "\t$text =~ s/</\\\\textless /g;\n"
2617 "\t$text =~ s/>/\\\\textgreater /g;\n"
2618 "\t$text =~ s/~/\\\\textasciitilde /g;\n"
2619 "\t$text =~ s/\\^/\\\\textasciicircum /g;\n"
2620 "\t$text =~ s/[\\$&%#_{}]/\\\\$&/g;\n"
2624 "sub generate_doc($) {\n"
2625 "\tmy $doc = $_[0];\n"
2626 "\tfor my $item (@$doc) {\n"
2627 "\t\tmy $type = $$item{type};\n"
2628 "\t\tif ($type eq \"text\") {\n"
2629 "\t\t\tlatex_quote($$item{content});\n"
2630 "\t\t} elsif ($type eq \"parbreak\") {\n"
2631 "\t\t\tprint \"\\n\\n\";\n"
2632 "\t\t} elsif ($type eq \"style\") {\n"
2633 "\t\t\tmy $style = $$item{style};\n"
2634 "\t\t\tif ($$item{enable} eq \"yes\") {\n"
2635 "\t\t\t\tif ($style eq \"bold\") { print '\\bfseries'; }\n"
2636 "\t\t\t\tif ($style eq \"italic\") { print '\\itshape'; }\n"
2637 "\t\t\t\tif ($style eq \"code\") { print '\\ttfamily'; }\n"
2639 "\t\t\t\tif ($style eq \"bold\") { print '\\mdseries'; }\n"
2640 "\t\t\t\tif ($style eq \"italic\") { print '\\upshape'; }\n"
2641 "\t\t\t\tif ($style eq \"code\") { print '\\rmfamily'; }\n"
2643 "\t\t\tprint '{}';\n"
2644 "\t\t} elsif ($type eq \"symbol\") {\n"
2645 "\t\t\tmy $symbol = $$item{symbol};\n"
2646 "\t\t\tif ($symbol eq \"copyright\") { print '\\copyright'; }\n"
2647 "\t\t\telsif ($symbol eq \"szlig\") { print '\\ss'; }\n"
2648 "\t\t\tprint '{}';\n"
2649 "\t\t} elsif ($type eq \"accent\") {\n"
2650 "\t\t\tmy ($accent) = $$item{accent};\n"
2651 "\t\t\tif ($accent eq \"umlaut\") { print '\\\"'; }\n"
2652 "\t\t\telsif ($accent eq \"acute\") { print '\\\\\\''; }\n"
2653 "\t\t\telsif ($accent eq \"grave\") { print '\\`'; }\n"
2654 "\t\t\telsif ($accent eq \"circ\") { print '\\^'; }\n"
2655 "\t\t\telsif ($accent eq \"tilde\") { print '\\~'; }\n"
2656 "\t\t\telsif ($accent eq \"cedilla\") { print '\\c'; }\n"
2657 "\t\t\telsif ($accent eq \"ring\") { print '\\r'; }\n"
2658 "\t\t\tprint \"{\" . $$item{letter} . \"}\"; \n"
2659 "\t\t} elsif ($type eq \"list\") {\n"
2660 "\t\t\tmy $env = ($$item{style} eq \"ordered\") ? \"enumerate\" : \"itemize\";\n"
2661 "\t\t\tprint \"\\n\\\\begin{\" . $env .\"}\";\n"
2662 "\t\t \tfor my $subitem (@{$$item{content}}) {\n"
2663 "\t\t\t\tprint \"\\n\\\\item \";\n"
2664 "\t\t\t\tgenerate_doc($subitem);\n"
2666 "\t\t\tprint \"\\n\\\\end{\" . $env .\"}\";\n"
2667 "\t\t} elsif ($type eq \"url\") {\n"
2668 "\t\t\tlatex_quote($$item{content});\n"
2673 "sub generate($$) {\n"
2674 "\tmy ($item, $node) = @_;\n"
2675 "\tmy ($type, $name) = @$node[0, 1];\n"
2676 "\tif ($type eq \"string\") {\n"
2677 "\t\tprint \"\\\\\" . $name . \"{\";\n"
2678 "\t\tlatex_quote($item);\n"
2679 "\t\tprint \"}\";\n"
2680 "\t} elsif ($type eq \"doc\") {\n"
2681 "\t\tif (@$item) {\n"
2682 "\t\t\tprint \"\\\\\" . $name . \"{\";\n"
2683 "\t\t\tgenerate_doc($item);\n"
2684 "\t\t\tprint \"}%\\n\";\n"
2686 "#\t\t\tprint \"\\\\\" . $name . \"Empty%\\n\";\n"
2688 "\t} elsif ($type eq \"hash\") {\n"
2689 "\t\tmy ($key, $value);\n"
2690 "\t\twhile (($key, $subnode) = each %{$$node[2]}) {\n"
2691 "\t\t\tmy $subname = $$subnode[1];\n"
2692 "\t\t\tprint \"\\\\Defcs{field\" . $subname . \"}{\";\n"
2693 "\t\t\tif ($$item{$key}) {\n"
2694 "\t\t\t\tgenerate($$item{$key}, $subnode);\n"
2696 "#\t\t\t\t\tprint \"\\\\\" . $subname . \"Empty%\\n\";\n"
2698 "\t\t\tprint \"}%\\n\";\n"
2700 "\t\tprint \"\\\\\" . $name . \"%\\n\";\n"
2701 "\t} elsif ($type eq \"list\") {\n"
2702 "\t\tmy $index = 0;\n"
2703 "\t\tif (@$item) {\n"
2704 "\t\t\tprint \"\\\\\" . $name . \"{%\\n\";\n"
2705 "\t\t\tfor my $subitem (@$item) {\n"
2706 "\t\t\t\tif ($index) {\n"
2707 "\t\t\t\t\tprint \"\\\\\" . $name . \"Sep%\\n\";\n"
2709 "\t\t\t\tgenerate($subitem, $$node[2]);\n"
2710 "\t\t\t\t$index++;\n"
2712 "\t\t\tprint \"}%\\n\";\n"
2714 "#\t\t\tprint \"\\\\\" . $name . \"Empty%\\n\";\n"
2719 "generate($doxydocs, $doxystructure);\n";
2724 bool PerlModGenerator::generateDoxyFormatTex()
2726 QFile doxyFormatTex;
2727 if (!createOutputFile(doxyFormatTex, pathDoxyFormatTex))
2730 FTextStream doxyFormatTexStream(&doxyFormatTex);
2731 doxyFormatTexStream <<
2732 "\\def\\Defcs#1{\\long\\expandafter\\def\\csname#1\\endcsname}\n"
2733 "\\Defcs{Empty}{}\n"
2734 "\\def\\IfEmpty#1{\\expandafter\\ifx\\csname#1\\endcsname\\Empty}\n"
2736 "\\def\\StringNode#1{\\Defcs{#1}##1{##1}}\n"
2737 "\\def\\DocNode#1{\\Defcs{#1}##1{##1}}\n"
2738 "\\def\\ListNode#1{\\Defcs{#1}##1{##1}\\Defcs{#1Sep}{}}\n"
2739 "\\def\\HashNode#1{\\Defcs{#1}{}}\n"
2741 "\\input{" << pathDoxyStructureTex << "}\n"
2744 "\\dimendef\\DimenA=151\\relax\n"
2745 "\\dimendef\\DimenB=152\\relax\n"
2746 "\\countdef\\ZoneDepth=151\\relax\n"
2748 "\\def\\Cs#1{\\csname#1\\endcsname}\n"
2749 "\\def\\Letcs#1{\\expandafter\\let\\csname#1\\endcsname}\n"
2750 "\\def\\Heading#1{\\vskip 4mm\\relax\\textbf{#1}}\n"
2751 "\\def\\See#1{\\begin{flushleft}\\Heading{See also: }#1\\end{flushleft}}\n"
2753 "\\def\\Frame#1{\\vskip 3mm\\relax\\fbox{ \\vbox{\\hsize0.95\\hsize\\vskip 1mm\\relax\n"
2754 "\\raggedright#1\\vskip 0.5mm\\relax} }}\n"
2756 "\\def\\Zone#1#2#3{%\n"
2757 "\\Defcs{Test#1}{#2}%\n"
2758 "\\Defcs{Emit#1}{#3}%\n"
2760 "\\advance\\ZoneDepth1\\relax\n"
2761 "\\Letcs{Mode\\number\\ZoneDepth}0\\relax\n"
2762 "\\Letcs{Present\\number\\ZoneDepth}0\\relax\n"
2764 "\\expandafter\\if\\Cs{Present\\number\\ZoneDepth}1%\n"
2765 "\\advance\\ZoneDepth-1\\relax\n"
2766 "\\Letcs{Present\\number\\ZoneDepth}1\\relax\n"
2767 "\\expandafter\\if\\Cs{Mode\\number\\ZoneDepth}1%\n"
2768 "\\advance\\ZoneDepth1\\relax\n"
2769 "\\Letcs{Mode\\number\\ZoneDepth}1\\relax\n"
2771 "\\advance\\ZoneDepth-1\\relax\\fi\n"
2772 "\\advance\\ZoneDepth1\\relax\\fi\n"
2773 "\\advance\\ZoneDepth-1\\relax}}\n"
2775 "\\def\\Member#1#2{%\n"
2776 "\\Defcs{Test#1}{\\Cs{field#1Detailed}\n"
2777 "\\IfEmpty{field#1DetailedDoc}\\else\\Letcs{Present#1}1\\fi}\n"
2778 "\\Defcs{#1}{\\Letcs{Present#1}0\\relax\n"
2779 "\\Cs{Test#1}\\if1\\Cs{Present#1}\\Letcs{Present\\number\\ZoneDepth}1\\relax\n"
2780 "\\if1\\Cs{Mode\\number\\ZoneDepth}#2\\fi\\fi}}\n"
2782 "\\def\\TypedefMemberList#1#2{%\n"
2783 "\\Defcs{#1DetailedDoc}##1{\\vskip 5.5mm\\relax##1}%\n"
2784 "\\Defcs{#1Name}##1{\\textbf{##1}}%\n"
2785 "\\Defcs{#1See}##1{\\See{##1}}%\n"
2787 "\\Zone{#1s}{\\Cs{field#1List}}{\\subsubsection{#2}\\Cs{field#1List}}%\n"
2788 "\\Member{#1}{\\Frame{typedef \\Cs{field#1Type} \\Cs{field#1Name}}%\n"
2789 "\\Cs{field#1DetailedDoc}\\Cs{field#1See}\\vskip 5mm\\relax}}%\n"
2791 "\\def\\VariableMemberList#1#2{%\n"
2792 "\\Defcs{#1DetailedDoc}##1{\\vskip 5.5mm\\relax##1}%\n"
2793 "\\Defcs{#1Name}##1{\\textbf{##1}}%\n"
2794 "\\Defcs{#1See}##1{\\See{##1}}%\n"
2796 "\\Zone{#1s}{\\Cs{field#1List}}{\\subsubsection{#2}\\Cs{field#1List}}%\n"
2797 "\\Member{#1}{\\Frame{\\Cs{field#1Type}{} \\Cs{field#1Name}}%\n"
2798 "\\Cs{field#1DetailedDoc}\\Cs{field#1See}\\vskip 5mm\\relax}}%\n"
2800 "\\def\\FunctionMemberList#1#2{%\n"
2801 "\\Defcs{#1PDParamName}##1{\\textit{##1}}%\n"
2802 "\\Defcs{#1PDParam}{\\Cs{field#1PDParamName}}%\n"
2803 "\\Defcs{#1PDParamsSep}{, }%\n"
2804 "\\Defcs{#1PDBlocksSep}{\\vskip 2mm\\relax}%\n"
2806 "\\Defcs{#1PDBlocks}##1{%\n"
2807 "\\Heading{Parameters:}\\vskip 1.5mm\\relax\n"
2808 "\\DimenA0pt\\relax\n"
2809 "\\Defcs{#1PDBlock}{\\setbox\\BoxA\\hbox{\\Cs{field#1PDParams}}%\n"
2810 "\\ifdim\\DimenA<\\wd\\BoxA\\DimenA\\wd\\BoxA\\fi}%\n"
2812 "\\advance\\DimenA3mm\\relax\n"
2813 "\\DimenB\\hsize\\advance\\DimenB-\\DimenA\\relax\n"
2814 "\\Defcs{#1PDBlock}{\\hbox to\\hsize{\\vtop{\\hsize\\DimenA\\relax\n"
2815 "\\Cs{field#1PDParams}}\\hfill\n"
2816 "\\vtop{\\hsize\\DimenB\\relax\\Cs{field#1PDDoc}}}}%\n"
2819 "\\Defcs{#1ParamName}##1{\\textit{##1}}\n"
2820 "\\Defcs{#1Param}{\\Cs{field#1ParamType}{} \\Cs{field#1ParamName}}\n"
2821 "\\Defcs{#1ParamsSep}{, }\n"
2823 "\\Defcs{#1Name}##1{\\textbf{##1}}\n"
2824 "\\Defcs{#1See}##1{\\See{##1}}\n"
2825 "\\Defcs{#1Return}##1{\\Heading{Returns: }##1}\n"
2826 "\\Defcs{field#1Title}{\\Frame{\\Cs{field#1Type}{} \\Cs{field#1Name}(\\Cs{field#1Params})}}%\n"
2828 "\\Zone{#1s}{\\Cs{field#1List}}{\\subsubsection{#2}\\Cs{field#1List}}%\n"
2830 "\\Cs{field#1Title}\\vskip 6mm\\relax\\Cs{field#1DetailedDoc}\n"
2831 "\\Cs{field#1Return}\\Cs{field#1PDBlocks}\\Cs{field#1See}\\vskip 5mm\\relax}}\n"
2833 "\\def\\FileDetailed{\\fieldFileDetailedDoc\\par}\n"
2834 "\\def\\ClassDetailed{\\fieldClassDetailedDoc\\par}\n"
2836 "\\def\\FileSubzones{\\fieldFileTypedefs\\fieldFileVariables\\fieldFileFunctions}\n"
2838 "\\def\\ClassSubzones{%\n"
2839 "\\fieldClassPublicTypedefs\\fieldClassPublicMembers\\fieldClassPublicMethods\n"
2840 "\\fieldClassProtectedTypedefs\\fieldClassProtectedMembers\\fieldClassProtectedMethods\n"
2841 "\\fieldClassPrivateTypedefs\\fieldClassPrivateMembers\\fieldClassPrivateMethods}\n"
2843 "\\Member{Page}{\\subsection{\\fieldPageName}\\fieldPageDetailedDoc}\n"
2845 "\\TypedefMemberList{FileTypedef}{Typedefs}\n"
2846 "\\VariableMemberList{FileVariable}{Variables}\n"
2847 "\\FunctionMemberList{FileFunction}{Functions}\n"
2848 "\\Zone{File}{\\FileSubzones}{\\subsection{\\fieldFileName}\\fieldFileDetailed\\FileSubzones}\n"
2850 "\\TypedefMemberList{ClassPublicTypedef}{Public Typedefs}\n"
2851 "\\TypedefMemberList{ClassProtectedTypedef}{Protected Typedefs}\n"
2852 "\\TypedefMemberList{ClassPrivateTypedef}{Private Typedefs}\n"
2853 "\\VariableMemberList{ClassPublicMember}{Public Members}\n"
2854 "\\VariableMemberList{ClassProtectedMember}{Protected Members}\n"
2855 "\\VariableMemberList{ClassPrivateMember}{Private Members}\n"
2856 "\\FunctionMemberList{ClassPublicMethod}{Public Methods}\n"
2857 "\\FunctionMemberList{ClassProtectedMethod}{Protected Methods}\n"
2858 "\\FunctionMemberList{ClassPrivateMethod}{Private Methods}\n"
2859 "\\Zone{Class}{\\ClassSubzones}{\\subsection{\\fieldClassName}\\fieldClassDetailed\\ClassSubzones}\n"
2861 "\\Zone{AllPages}{\\fieldPages}{\\section{Pages}\\fieldPages}\n"
2862 "\\Zone{AllFiles}{\\fieldFiles}{\\section{Files}\\fieldFiles}\n"
2863 "\\Zone{AllClasses}{\\fieldClasses}{\\section{Classes}\\fieldClasses}\n"
2865 "\\newlength{\\oldparskip}\n"
2866 "\\newlength{\\oldparindent}\n"
2867 "\\newlength{\\oldfboxrule}\n"
2869 "\\ZoneDepth0\\relax\n"
2870 "\\Letcs{Mode0}1\\relax\n"
2872 "\\def\\EmitDoxyDocs{%\n"
2873 "\\setlength{\\oldparskip}{\\parskip}\n"
2874 "\\setlength{\\oldparindent}{\\parindent}\n"
2875 "\\setlength{\\oldfboxrule}{\\fboxrule}\n"
2876 "\\setlength{\\parskip}{0cm}\n"
2877 "\\setlength{\\parindent}{0cm}\n"
2878 "\\setlength{\\fboxrule}{1pt}\n"
2879 "\\AllPages\\AllFiles\\AllClasses\n"
2880 "\\setlength{\\parskip}{\\oldparskip}\n"
2881 "\\setlength{\\parindent}{\\oldparindent}\n"
2882 "\\setlength{\\fboxrule}{\\oldfboxrule}}\n";
2887 bool PerlModGenerator::generateDoxyLatexTex()
2890 if (!createOutputFile(doxyLatexTex, pathDoxyLatexTex))
2893 FTextStream doxyLatexTexStream(&doxyLatexTex);
2894 doxyLatexTexStream <<
2895 "\\documentclass[a4paper,12pt]{article}\n"
2896 "\\usepackage[latin1]{inputenc}\n"
2897 "\\usepackage[none]{hyphenat}\n"
2898 "\\usepackage[T1]{fontenc}\n"
2899 "\\usepackage{hyperref}\n"
2900 "\\usepackage{times}\n"
2902 "\\input{doxyformat}\n"
2904 "\\begin{document}\n"
2905 "\\input{" << pathDoxyDocsTex << "}\n"
2908 "\\end{document}\n";
2913 void PerlModGenerator::generate()
2924 if (!createOutputDir(perlModDir))
2927 bool perlmodLatex = Config_getBool("PERLMOD_LATEX");
2929 QCString perlModAbsPath = perlModDir.absPath().utf8();
2930 pathDoxyDocsPM = perlModAbsPath + "/DoxyDocs.pm";
2931 pathDoxyStructurePM = perlModAbsPath + "/DoxyStructure.pm";
2932 pathMakefile = perlModAbsPath + "/Makefile";
2933 pathDoxyRules = perlModAbsPath + "/doxyrules.make";
2936 pathDoxyStructureTex = perlModAbsPath + "/doxystructure.tex";
2937 pathDoxyFormatTex = perlModAbsPath + "/doxyformat.tex";
2938 pathDoxyLatexTex = perlModAbsPath + "/doxylatex.tex";
2939 pathDoxyLatexDVI = perlModAbsPath + "/doxylatex.dvi";
2940 pathDoxyLatexPDF = perlModAbsPath + "/doxylatex.pdf";
2941 pathDoxyDocsTex = perlModAbsPath + "/doxydocs.tex";
2942 pathDoxyLatexPL = perlModAbsPath + "/doxylatex.pl";
2943 pathDoxyLatexStructurePL = perlModAbsPath + "/doxylatex-structure.pl";
2946 if (!(generatePerlModOutput()
2947 && generateDoxyStructurePM()
2948 && generateMakefile()
2949 && generateDoxyRules()))
2953 if (!(generateDoxyLatexStructurePL()
2954 && generateDoxyLatexPL()
2955 && generateDoxyLatexTex()
2956 && generateDoxyFormatTex()))
2961 void generatePerlMod()
2963 PerlModGenerator pmg(Config_getBool("PERLMOD_PRETTY"));
2968 // c-basic-offset: 2
2971 /* This elisp function for XEmacs makes Control-Z transform
2972 the text in the region into a valid C string.
2974 (global-set-key '(control z) (lambda () (interactive)
2976 (if (< (mark) (point)) (exchange-point-and-mark))
2977 (let ((start (point)) (replacers
2978 '(("\\\\" "\\\\\\\\")
2981 ("^.*$" "\"\\&\\\\n\""))))
2983 (while (re-search-forward (caar replacers) (mark) t)
2984 (replace-match (cadar replacers) t))
2986 (setq replacers (cdr replacers)))))))