Exemple #1
0
void DocbookDocVisitor::visit(DocVerbatim *s)
{
  if (m_hide) return;
  SrcLangExt langExt = getLanguageFromFileName(m_langExt);
  switch(s->type())
  {
    case DocVerbatim::Code: // fall though
      m_t << "<literallayout><computeroutput>";
      Doxygen::parserManager->getParser(m_langExt)
        ->parseCode(m_ci,s->context(),s->text(),langExt,
            s->isExample(),s->exampleFile());
      m_t << "</computeroutput></literallayout>";
      break;
    case DocVerbatim::Verbatim:
      m_t << "<literallayout>";
      filter(s->text());
      m_t << "</literallayout>";
      break;
    case DocVerbatim::HtmlOnly:    
      break;
    case DocVerbatim::RtfOnly:     
      break;
    case DocVerbatim::ManOnly:     
      break;
    case DocVerbatim::LatexOnly:   
      break;
    case DocVerbatim::XmlOnly:     
      break;
    case DocVerbatim::DocbookOnly: 
      break;
      m_t << s->text();
      break;
    case DocVerbatim::Dot:
      {
        static int dotindex = 1;
        QCString baseName(4096);
        QCString name;
        QCString stext = s->text();
        m_t << "<para>" << endl;
        name.sprintf("%s%d", "dot_inline_dotgraph_", dotindex);
        baseName.sprintf("%s%d",
            (Config_getString(DOCBOOK_OUTPUT)+"/inline_dotgraph_").data(),
            dotindex++
            );
        QFile file(baseName+".dot");
        if (!file.open(IO_WriteOnly))
        {
          err("Could not open file %s.msc for writing\n",baseName.data());
        }
        file.writeBlock( stext, stext.length() );
        file.close();
        writeDotFile(baseName, s);
        m_t << "</para>" << endl;
      }
      break;
    case DocVerbatim::Msc:
      {
        static int mscindex = 1;
        QCString baseName(4096);
        QCString name;
        QCString stext = s->text();
        m_t << "<para>" << endl;
        name.sprintf("%s%d", "msc_inline_mscgraph_", mscindex);
        baseName.sprintf("%s%d",
            (Config_getString(DOCBOOK_OUTPUT)+"/inline_mscgraph_").data(),
            mscindex++
            );
        QFile file(baseName+".msc");
        if (!file.open(IO_WriteOnly))
        {
          err("Could not open file %s.msc for writing\n",baseName.data());
        }
        QCString text = "msc {";
        text+=stext;
        text+="}";
        file.writeBlock( text, text.length() );
        file.close();
        writeMscFile(baseName,s);
        m_t << "</para>" << endl;
      }
      break;
    case DocVerbatim::PlantUML:
      {
        static QCString docbookOutput = Config_getString(DOCBOOK_OUTPUT);
        QCString baseName = writePlantUMLSource(docbookOutput,s->exampleFile(),s->text());
        QCString shortName = baseName;
        int i;
        if ((i=shortName.findRev('/'))!=-1)
        {
          shortName=shortName.right(shortName.length()-i-1);
        }
        m_t << "<para>" << endl;
        writePlantUMLFile(baseName,s);
        m_t << "</para>" << endl;
      }
      break;
  }
}
void LatexDocVisitor::visit(DocVerbatim *s)
{
    if (m_hide) return;
    QCString lang = m_langExt;
    if (!s->language().isEmpty()) // explicit language setting
    {
        lang = s->language();
    }
    SrcLangExt langExt = getLanguageFromFileName(lang);
    switch(s->type())
    {
    case DocVerbatim::Code:
    {
        m_t << "\n\\begin{DoxyCode}\n";
        Doxygen::parserManager->getParser(lang)
        ->parseCode(m_ci,s->context(),s->text(),langExt,
                    s->isExample(),s->exampleFile());
        m_t << "\\end{DoxyCode}\n";
    }
    break;
    case DocVerbatim::Verbatim:
        m_t << "\\begin{DoxyVerb}";
        m_t << s->text();
        m_t << "\\end{DoxyVerb}\n";
        break;
    case DocVerbatim::HtmlOnly:
    case DocVerbatim::XmlOnly:
    case DocVerbatim::ManOnly:
    case DocVerbatim::RtfOnly:
    case DocVerbatim::DocbookOnly:
        /* nothing */
        break;
    case DocVerbatim::LatexOnly:
        m_t << s->text();
        break;
    case DocVerbatim::Dot:
    {
        static int dotindex = 1;
        QCString fileName(4096);

        fileName.sprintf("%s%d%s",
                         (Config_getString("LATEX_OUTPUT")+"/inline_dotgraph_").data(),
                         dotindex++,
                         ".dot"
                        );
        QFile file(fileName);
        if (!file.open(IO_WriteOnly))
        {
            err("Could not open file %s for writing\n",fileName.data());
        }
        else
        {
            file.writeBlock( s->text(), s->text().length() );
            file.close();

            startDotFile(fileName,s->width(),s->height(),s->hasCaption());
            visitCaption(this, s->children());
            endDotFile(s->hasCaption());

            if (Config_getBool("DOT_CLEANUP")) file.remove();
        }
    }
    break;
    case DocVerbatim::Msc:
    {
        static int mscindex = 1;
        QCString baseName(4096);

        baseName.sprintf("%s%d",
                         (Config_getString("LATEX_OUTPUT")+"/inline_mscgraph_").data(),
                         mscindex++
                        );
        QFile file(baseName+".msc");
        if (!file.open(IO_WriteOnly))
        {
            err("Could not open file %s.msc for writing\n",baseName.data());
        }
        else
        {
            QCString text = "msc {";
            text+=s->text();
            text+="}";
            file.writeBlock( text, text.length() );
            file.close();

            writeMscFile(baseName, s);

            if (Config_getBool("DOT_CLEANUP")) file.remove();
        }
    }
    break;
    case DocVerbatim::PlantUML:
    {
        QCString latexOutput = Config_getString("LATEX_OUTPUT");
        QCString baseName = writePlantUMLSource(latexOutput,s->exampleFile(),s->text());

        writePlantUMLFile(baseName, s);
    }
    break;
    }
}
Exemple #3
0
void RTFDocVisitor::visit(DocVerbatim *s)
{
  if (m_hide) return;
  DBG_RTF("{\\comment RTFDocVisitor::visit(DocVerbatim)}\n");
  QCString lang = m_langExt;
  if (!s->language().isEmpty()) // explicit language setting
  {
    lang = s->language();
  }
  SrcLangExt langExt = getLanguageFromFileName(lang);
  switch(s->type())
  {
    case DocVerbatim::Code: // fall though
      m_t << "{" << endl;
      m_t << "\\par" << endl;
      m_t << rtf_Style_Reset << getStyle("CodeExample");
      Doxygen::parserManager->getParser(lang)
                            ->parseCode(m_ci,s->context(),s->text(),langExt,
                                        s->isExample(),s->exampleFile());
      //m_t << "\\par" << endl; 
      m_t << "}" << endl;
      break;
    case DocVerbatim::Verbatim: 
      m_t << "{" << endl;
      m_t << "\\par" << endl;
      m_t << rtf_Style_Reset << getStyle("CodeExample");
      filter(s->text(),TRUE);
      //m_t << "\\par" << endl; 
      m_t << "}" << endl;
      break;
    case DocVerbatim::RtfOnly: 
      m_t << s->text(); 
      break;
    case DocVerbatim::HtmlOnly: 
    case DocVerbatim::LatexOnly: 
    case DocVerbatim::XmlOnly: 
    case DocVerbatim::ManOnly:
    case DocVerbatim::DocbookOnly:
      /* nothing */
      break;
    case DocVerbatim::Dot: 
      {
        static int dotindex = 1;
        QCString fileName(4096);

        fileName.sprintf("%s%d%s", 
            (Config_getString(RTF_OUTPUT)+"/inline_dotgraph_").data(), 
            dotindex++,
            ".dot"
           );
        QFile file(fileName);
        if (!file.open(IO_WriteOnly))
        {
          err("Could not open file %s for writing\n",fileName.data());
        }
        file.writeBlock( s->text(), s->text().length() );
        file.close();

        writeDotFile(fileName, s->hasCaption());
        visitCaption(this, s->children());
        includePicturePostRTF(true, s->hasCaption());

        if (Config_getBool(DOT_CLEANUP)) file.remove();
      }
      break;
    case DocVerbatim::Msc: 
      {
        static int mscindex = 1;
        QCString baseName(4096);

        baseName.sprintf("%s%d%s",
            (Config_getString(RTF_OUTPUT)+"/inline_mscgraph_").data(), 
            mscindex++,
            ".msc"
           );
        QFile file(baseName);
        if (!file.open(IO_WriteOnly))
        {
          err("Could not open file %s for writing\n",baseName.data());
        }
        QCString text = "msc {";
        text+=s->text();
        text+="}";
        file.writeBlock( text, text.length() );
        file.close();

        writeMscFile(baseName, s->hasCaption());
        visitCaption(this, s->children());
        includePicturePostRTF(true, s->hasCaption());

        if (Config_getBool(DOT_CLEANUP)) file.remove();
      }
      break;
    case DocVerbatim::PlantUML:
      {
        static QCString rtfOutput = Config_getString(RTF_OUTPUT);
        QCString baseName = writePlantUMLSource(rtfOutput,s->exampleFile(),s->text());

        writePlantUMLFile(baseName, s->hasCaption());
        visitCaption(this, s->children());
        includePicturePostRTF(true, s->hasCaption());
      }
      break;
  }
  m_lastIsPara=FALSE;
}
void LatexDocVisitor::visit(DocVerbatim *s)
{
   if (m_hide) {
      return;
   }

   QString lang = m_langExt;
   if (! s->language().isEmpty()) { 
      // explicit language setting
      lang = s->language();
   }

   SrcLangExt langExt = getLanguageFromFileName(lang);

   switch (s->type()) {
      case DocVerbatim::Code: {
         m_t << "\n\\begin{DoxyCode}\n";
         Doxy_Globals::parserManager->getParser(lang)
         ->parseCode(m_ci, s->context(), s->text(), langExt,
                     s->isExample(), s->exampleFile());
         m_t << "\\end{DoxyCode}\n";
      }
      break;

      case DocVerbatim::Verbatim:
         m_t << "\\begin{DoxyVerb}";
         m_t << s->text();
         m_t << "\\end{DoxyVerb}\n";
         break;

      case DocVerbatim::HtmlOnly:
      case DocVerbatim::XmlOnly:
      case DocVerbatim::ManOnly:
      case DocVerbatim::RtfOnly:
      case DocVerbatim::DocbookOnly:
         /* nothing */
         break;

      case DocVerbatim::LatexOnly:
         m_t << s->text();
         break;

      case DocVerbatim::Dot: {
         static int dotindex = 1;

         QString latexOutput = Config::getString("latex-output") + "/inline_dotgraph_";        
         QString fileName = QString("%1%2.dot").arg(latexOutput).arg(dotindex++);

         QFile file(fileName);

         if (! file.open(QIODevice::WriteOnly)) {
            err("Unable to open file %s for writing, error: %d\n", csPrintable(fileName), file.error()); 
 
         } else {

            file.write( s->text().toUtf8() );
            file.close();
       
            startDotFile(fileName, s->width(), s->height(), s->hasCaption());
            visitCaption(this, s->children());
            endDotFile(s->hasCaption());

            if (Config::getBool("dot-cleanup")) {
               file.remove();
            }
         } 
      }
      break;

      case DocVerbatim::Msc: {
         static int mscindex = 1;

         QString latexOutput = Config::getString("latex-output") + "/inline_mscgraph_";
         QString baseName = QString("%1%2").arg(latexOutput).arg(mscindex++);

         QFile file(baseName + ".msc");

         if (! file.open(QIODevice::WriteOnly)) {
            err("Unable to open file %s.msc for writing, error: %d\n", qPrintable(baseName), file.error()); 

         } else {

            QString text = "msc {";
            text += s->text();
            text += "}";
   
            file.write( text.toUtf8() );
            file.close();
   
            writeMscFile(baseName, s);
   
            if (Config::getBool("dot-cleanup")) {
               file.remove();
            }
         }
      }
      break;

      case DocVerbatim::PlantUML: {
         QString latexOutput = Config::getString("latex-output");
         QString baseName    = writePlantUMLSource(latexOutput, s->exampleFile(), s->text());

         writePlantUMLFile(baseName, s);
      }
      break;
   }
}