My Project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Enumerations | Functions | Variables
context.cpp File Reference
#include <assert.h>
#include <qdir.h>
#include "context.h"
#include "config.h"
#include "index.h"
#include "classlist.h"
#include "doxygen.h"
#include "namespacedef.h"
#include "filedef.h"
#include "pagedef.h"
#include "groupdef.h"
#include "util.h"
#include "version.h"
#include "language.h"
#include "message.h"
#include "vhdldocgen.h"
#include "filename.h"
#include "dirdef.h"
#include "docparser.h"
#include "htmlgen.h"
#include "htmldocvisitor.h"
#include "htmlhelp.h"
#include "latexgen.h"
#include "latexdocvisitor.h"
#include "dot.h"
#include "diagram.h"
#include "example.h"
#include "membername.h"
#include "parserintf.h"
#include "portable.h"
#include "arguments.h"
#include "searchindex.h"
#include "resourcemgr.h"

Go to the source code of this file.

Classes

struct  ContextGlobals
 
class  ScopedPtr< T >
 Scoped smart pointer. More...
 
class  SharedPtr< T >
 Reference counting smart pointer. More...
 
class  GenericConstIterator
 Template List iterator support. More...
 
class  GenericNodeListContext
 standard template list implementation More...
 
class  PropertyMapper< T >
 Helper class to map a property name to a handler member function. More...
 
struct  PropertyMapper< T >::PropertyFuncIntf
 
struct  PropertyMapper< T >::PropertyFunc
 
class  ConfigContext::Private
 
class  DoxygenContext::Private
 
struct  DoxygenContext::Private::Cachable
 
class  TranslateContext::Private
 
class  DefinitionContext< T >
 
struct  DefinitionContext< T >::Cachable
 
class  IncludeInfoContext::Private
 
class  IncludeInfoListContext::Private
 
class  ClassContext::Private
 
struct  ClassContext::Private::Cachable
 
class  NamespaceContext::Private
 
struct  NamespaceContext::Private::Cachable
 
class  FileContext::Private
 
struct  FileContext::Private::Cachable
 
class  DirContext::Private
 
struct  DirContext::Private::Cachable
 
class  PageContext::Private
 
struct  PageContext::Private::Cachable
 
class  TextGeneratorHtml
 
class  TextGeneratorLatex
 
class  TextGeneratorFactory
 
class  MemberContext::Private
 
struct  MemberContext::Private::Cachable
 
class  ModuleContext::Private
 
struct  ModuleContext::Private::Cachable
 
class  ClassListContext::Private
 
class  ClassIndexContext::Private
 
struct  ClassIndexContext::Private::Cachable
 
class  ClassHierarchyContext::Private
 
struct  ClassHierarchyContext::Private::Cachable
 
class  NestingNodeContext::Private
 
struct  NestingNodeContext::Private::Cachable
 
class  NestingContext::Private
 
class  ClassTreeContext::Private
 
struct  ClassTreeContext::Private::Cachable
 
class  NamespaceListContext::Private
 
class  NamespaceTreeContext::Private
 
struct  NamespaceTreeContext::Private::Cachable
 
class  FileListContext::Private
 
class  DirListContext::Private
 
class  UsedFilesContext::Private
 
class  FileTreeContext::Private
 
struct  FileTreeContext::Private::Cachable
 
class  PageTreeContext::Private
 
struct  PageTreeContext::Private::Cachable
 
class  PageListContext::Private
 
class  ExampleListContext::Private
 
class  ModuleListContext::Private
 
class  ModuleTreeContext::Private
 
struct  ModuleTreeContext::Private::Cachable
 
class  NavPathElemContext::Private
 
class  ExampleTreeContext::Private
 
struct  ExampleTreeContext::Private::Cachable
 
class  GlobalsIndexContext::Private
 
struct  GlobalsIndexContext::Private::Cachable
 
class  ClassMembersIndexContext::Private
 
struct  ClassMembersIndexContext::Private::Cachable
 
class  NamespaceMembersIndexContext::Private
 
struct  NamespaceMembersIndexContext::Private::Cachable
 
class  InheritanceGraphContext::Private
 
class  InheritanceNodeContext::Private
 
class  InheritanceListContext::Private
 
class  MemberListContext::Private
 
class  MemberInfoContext::Private
 
class  AllMembersListContext::Private
 
class  MemberGroupInfoContext::Private
 
struct  MemberGroupInfoContext::Private::Cachable
 
class  MemberGroupListContext::Private
 
class  MemberListInfoContext::Private
 
struct  MemberListInfoContext::Private::Cachable
 
class  InheritedMemberInfoContext::Private
 
class  InheritedMemberInfoListContext::Private
 
class  ArgumentContext::Private
 
struct  ArgumentContext::Private::Cachable
 
class  ArgumentListContext::Private
 
class  SymbolContext::Private
 
class  SymbolListContext::Private
 
class  SymbolGroupContext::Private
 
struct  SymbolGroupContext::Private::Cachable
 
class  SymbolGroupListContext::Private
 
class  SymbolIndexContext::Private
 
struct  SymbolIndexContext::Private::Cachable
 
class  SymbolIndicesContext::Private
 
class  SearchIndexContext::Private
 
struct  SearchIndexContext::Private::Cachable
 
class  SearchIndicesContext::Private
 
class  HtmlEscaper
 
class  LatexSpaceless
 
class  HtmlSpaceless
 
class  LatexEscaper
 

Enumerations

enum  ContextOutputFormat {
  ContextOutputFormat_Unspecified =0, ContextOutputFormat_Html, ContextOutputFormat_Latex, ContextOutputFormat_Rtf,
  ContextOutputFormat_ManPage, ContextOutputFormat_DocBook, ContextOutputFormat_Xml, ContextOutputFormat_TagFile
}
 

Functions

static TemplateVariant parseDoc (Definition *def, const QCString &file, int line, const QCString &relPath, const QCString &docStr, bool isBrief)
 
static TemplateVariant parseCode (MemberDef *md, const QCString &scopeName, const QCString &relPath, const QCString &code, int startLine=-1, int endLine=-1, bool showLineNumbers=FALSE)
 
static TemplateVariant parseCode (FileDef *fd, const QCString &relPath)
 
TemplateVariant createLinkedText (Definition *def, const QCString &relPath, const QCString &text)
 
static int computeMaxDepth (const TemplateListIntf *list)
 
static int computeNumNodesAtLevel (const TemplateStructIntf *s, int level, int maxLevel)
 
static int computePreferredDepth (const TemplateListIntf *list, int maxDepth)
 
void generateOutputViaTemplate ()
 
void generateTemplateFiles (const char *templateDir)
 

Variables

struct ContextGlobals g_globals
 

Enumeration Type Documentation

Enumerator
ContextOutputFormat_Unspecified 
ContextOutputFormat_Html 
ContextOutputFormat_Latex 
ContextOutputFormat_Rtf 
ContextOutputFormat_ManPage 
ContextOutputFormat_DocBook 
ContextOutputFormat_Xml 
ContextOutputFormat_TagFile 

Definition at line 55 of file context.cpp.

Function Documentation

static int computeMaxDepth ( const TemplateListIntf list)
static
static int computeNumNodesAtLevel ( const TemplateStructIntf s,
int  level,
int  maxLevel 
)
static

Definition at line 5874 of file context.cpp.

References TemplateListIntf::createIterator(), TemplateListIntf::ConstIterator::current(), TemplateStructIntf::get(), TemplateListIntf::ConstIterator::toFirst(), TemplateVariant::toList(), TemplateListIntf::ConstIterator::toNext(), and TemplateVariant::toStruct().

Referenced by computePreferredDepth().

{
int num=0;
if (level<maxLevel)
{
num++;
TemplateVariant child = s->get("children");
if (child.toList())
{
for (it->toFirst();it->current(v);it->toNext())
{
num+=computeNumNodesAtLevel(v.toStruct(),level+1,maxLevel);
}
delete it;
}
}
return num;
}
static int computePreferredDepth ( const TemplateListIntf list,
int  maxDepth 
)
static
TemplateVariant createLinkedText ( Definition def,
const QCString &  relPath,
const QCString &  text 
)
void generateOutputViaTemplate ( )

Definition at line 10083 of file context.cpp.

References ConfigContext::alloc(), DoxygenContext::alloc(), TranslateContext::alloc(), PageContext::alloc(), ClassListContext::alloc(), ClassIndexContext::alloc(), ClassHierarchyContext::alloc(), ClassTreeContext::alloc(), NamespaceListContext::alloc(), NamespaceTreeContext::alloc(), DirListContext::alloc(), FileListContext::alloc(), FileTreeContext::alloc(), PageListContext::alloc(), PageTreeContext::alloc(), ModuleListContext::alloc(), ModuleTreeContext::alloc(), ExampleListContext::alloc(), ExampleTreeContext::alloc(), GlobalsIndexContext::alloc(), ClassMembersIndexContext::alloc(), NamespaceMembersIndexContext::alloc(), SearchIndicesContext::alloc(), Config_getString, ContextOutputFormat_Html, ContextOutputFormat_Latex, TemplateEngine::createContext(), createSubDirs(), DefinitionIntf::definitionType(), TemplateEngine::destroyContext(), ContextGlobals::dynSectionId, g_globals, SharedPtr< T >::get(), TemplateEngine::loadByName(), Doxygen::mainPage, msg(), ContextGlobals::outputDir, ContextGlobals::outputFormat, Doxygen::pageSDict, Template::render(), TemplateContext::set(), Definition::setCookie(), TemplateContext::setEscapeIntf(), PageDef::setFileName(), TemplateContext::setOutputDirectory(), TemplateContext::setSpacelessIntf(), TemplateEngine::setTemplateDir(), Doxygen::symbolMap, theTranslator, Translator::trMainPage(), DefinitionIntf::TypeSymbolList, and TemplateEngine::unload().

Referenced by generateOutput().

{
msg("Generating output via template engine...\n");
{
if (ctx)
{
//%% Doxygen doxygen:
ctx->set("doxygen",doxygen.get());
//%% Translator tr:
ctx->set("tr",tr.get());
//%% Config config:
ctx->set("config",config.get());
//%% ClassList classList:
ctx->set("classList",classList.get()); // not used for standard HTML
//%% ClassTree classTree:
ctx->set("classTree",classTree.get());
//%% ClassIndex classIndex:
ctx->set("classIndex",classIndex.get());
//%% ClassHierarchy classHierarchy:
ctx->set("classHierarchy",classHierarchy.get());
//%% NamespaceList namespaceList:
ctx->set("namespaceList",namespaceList.get());
//%% NamespaceTree namespaceTree:
ctx->set("namespaceTree",namespaceTree.get());
//%% FileList fileList:
ctx->set("fileList",fileList.get());
//%% FileTree fileTree:
ctx->set("fileTree",fileTree.get());
//%% PageList pageList
ctx->set("pageList",pageList.get());
//%% PageTree pageTree
ctx->set("pageTree",pageTree.get());
//%% ExampleTree exampleTree
ctx->set("exampleTree",exampleTree.get());
//%% ExampleList exampleList
ctx->set("exampleList",exampleList.get());
//%% ModuleTree moduleTree
ctx->set("moduleTree",moduleTree.get());
//%% ModuleList moduleList
ctx->set("moduleList",moduleList.get());
//%% DirList dirList
ctx->set("dirList",dirList.get());
//%% Page mainPage
{
ctx->set("mainPage",mainPage.get());
}
else
{
// TODO: for LaTeX output index should be main... => solve in template
Doxygen::mainPage = new PageDef("[generated]",1,"index","",theTranslator->trMainPage());
ctx->set("mainPage",mainPage.get());
}
//%% GlobalsIndex globalsIndex:
ctx->set("globalsIndex",globalsIndex.get());
//%% ClassMembersIndex classMembersIndex:
ctx->set("classMembersIndex",classMembersIndex.get());
//%% NamespaceMembersIndex namespaceMembersIndex:
ctx->set("namespaceMembersIndex",namespaceMembersIndex.get());
//%% SearchIndicaes searchindicaes
ctx->set("searchIndices",searchIndices.get());
//%% string space
ctx->set("space"," ");
//if (Config_getBool(GENERATE_HTML))
{ // render HTML output
e.setTemplateDir("templates/html"); // TODO: make template part user configurable
Template *tpl = e.loadByName("htmllayout.tpl",1);
if (tpl)
{
QDir dir(g_globals.outputDir);
HtmlEscaper htmlEsc;
ctx->setEscapeIntf(Config_getString(HTML_FILE_EXTENSION),&htmlEsc);
ctx->setSpacelessIntf(&spl);
tpl->render(ts,ctx);
e.unload(tpl);
}
}
// TODO: clean index before each run...
//if (Config_getBool(GENERATE_LATEX))
if (0)
{ // render LaTeX output
e.setTemplateDir("templates/latex"); // TODO: make template part user configurable
Template *tpl = e.loadByName("latexlayout.tpl",1);
if (tpl)
{
QDir dir(g_globals.outputDir);
LatexEscaper latexEsc;
ctx->setEscapeIntf(".tex",&latexEsc);
ctx->setSpacelessIntf(&spl);
tpl->render(ts,ctx);
e.unload(tpl);
}
}
// clear all cached data in Definition objects.
QDictIterator<DefinitionIntf> di(*Doxygen::symbolMap);
for (;(intf=di.current());++di)
{
if (intf->definitionType()==DefinitionIntf::TypeSymbolList) // list of symbols
{
// for each symbol
for (dli.toFirst();(d=dli.current());++dli)
{
d->setCookie(0);
}
}
else // single symbol
{
Definition *d = (Definition *)intf;
d->setCookie(0);
}
}
}
}
#if DEBUG_REF // should be 0, i.e. all objects are deleted
printf("==== total ref count %d\n",RefCountedContext::s_totalCount);
#endif
}
void generateTemplateFiles ( const char *  templateDir)

Definition at line 10252 of file context.cpp.

References err(), ResourceMgr::instance(), and ResourceMgr::writeCategory().

Referenced by readConfiguration().

{
if (!templateDir) return;
QDir thisDir;
if (!thisDir.exists(templateDir) && !thisDir.mkdir(templateDir))
{
err("Failed to create output directory '%s'\n",templateDir);
return;
}
QCString outDir = QCString(templateDir)+"/html";
if (!thisDir.exists(outDir) && !thisDir.mkdir(outDir))
{
err("Failed to create output directory '%s'\n",templateDir);
return;
}
}
static TemplateVariant parseCode ( MemberDef md,
const QCString &  scopeName,
const QCString &  relPath,
const QCString &  code,
int  startLine = -1,
int  endLine = -1,
bool  showLineNumbers = FALSE 
)
static

Definition at line 1281 of file context.cpp.

References ContextOutputFormat_Html, ContextOutputFormat_Latex, Definition::docFile(), err(), g_globals, Definition::getBodyDef(), Definition::getDefFileExtension(), Definition::getLanguage(), ParserManager::getParser(), ContextGlobals::outputFormat, ParserInterface::parseCode(), Doxygen::parserManager, and ParserInterface::resetCodeParserState().

Referenced by MemberContext::Private::initializerAsCode(), MemberContext::Private::sourceCode(), FileContext::Private::sources(), DocbookDocVisitor::visit(), RTFDocVisitor::visit(), ManDocVisitor::visit(), XmlDocVisitor::visit(), HtmlDocVisitor::visit(), LatexDocVisitor::visit(), and PerlModDocVisitor::visit().

{
QGString s;
FTextStream t(&s);
{
{
HtmlCodeGenerator codeGen(t,relPath);
pIntf->parseCode(codeGen,scopeName,code,md->getLanguage(),FALSE,0,md->getBodyDef(),
startLine,endLine,TRUE,md,showLineNumbers,md);
}
break;
{
LatexCodeGenerator codeGen(t,relPath,md->docFile());
pIntf->parseCode(codeGen,scopeName,code,md->getLanguage(),FALSE,0,md->getBodyDef(),
startLine,endLine,TRUE,md,showLineNumbers,md);
}
break;
// TODO: support other generators
default:
err("context.cpp: output format not yet supported");
break;
}
return TemplateVariant(s.data(),TRUE);
}
static TemplateVariant parseCode ( FileDef fd,
const QCString &  relPath 
)
static

Definition at line 1312 of file context.cpp.

References FileDef::absFilePath(), Config_getBool, ContextOutputFormat_Html, ContextOutputFormat_Latex, Definition::docFile(), err(), fileToString(), g_globals, Definition::getDefFileExtension(), Definition::getLanguage(), ParserManager::getParser(), ContextGlobals::outputFormat, ParserInterface::parseCode(), Doxygen::parserManager, and ParserInterface::resetCodeParserState().

{
static bool filterSourceFiles = Config_getBool(FILTER_SOURCE_FILES);
QGString s;
FTextStream t(&s);
{
{
HtmlCodeGenerator codeGen(t,relPath);
pIntf->parseCode(codeGen,0,
fileToString(fd->absFilePath(),filterSourceFiles,TRUE), // the sources
fd->getLanguage(), // lang
FALSE, // isExampleBlock
0, // exampleName
fd, // fileDef
-1, // startLine
-1, // endLine
FALSE, // inlineFragment
0, // memberDef
TRUE, // showLineNumbers
0, // searchCtx
TRUE // collectXRefs, TODO: should become FALSE
);
}
break;
{
LatexCodeGenerator codeGen(t,relPath,fd->docFile());
pIntf->parseCode(codeGen,0,
fileToString(fd->absFilePath(),filterSourceFiles,TRUE), // the sources
fd->getLanguage(), // lang
FALSE, // isExampleBlock
0, // exampleName
fd, // fileDef
-1, // startLine
-1, // endLine
FALSE, // inlineFragment
0, // memberDef
TRUE, // showLineNumbers
0, // searchCtx
TRUE // collectXRefs, TODO: should become FALSE
);
}
break;
// TODO: support other generators
default:
err("context.cpp: output format not yet supported");
break;
}
return TemplateVariant(s.data(),TRUE);
}
static TemplateVariant parseDoc ( Definition def,
const QCString &  file,
int  line,
const QCString &  relPath,
const QCString &  docStr,
bool  isBrief 
)
static

Definition at line 1242 of file context.cpp.

References DocRoot::accept(), ContextOutputFormat_Html, ContextOutputFormat_Latex, err(), g_globals, Definition::getDefFileExtension(), DocRoot::isEmpty(), ContextGlobals::outputFormat, and validatingParseDoc().

Referenced by DefinitionContext< FileContext::Private >::brief(), NestingNodeContext::Private::brief(), DefinitionContext< FileContext::Private >::details(), MemberGroupInfoContext::Private::docs(), ArgumentContext::Private::docs(), PageContext::Private::example(), DefinitionContext< FileContext::Private >::inbodyDocs(), and MemberContext::Private::paramDocs().

{
DocRoot *root = validatingParseDoc(file,line,def,0,docStr,TRUE,FALSE,0,isBrief,FALSE);
QGString docs;
{
FTextStream ts(&docs);
{
{
HtmlCodeGenerator codeGen(ts,relPath);
HtmlDocVisitor visitor(ts,codeGen,def);
root->accept(&visitor);
}
break;
{
LatexCodeGenerator codeGen(ts,relPath,file);
LatexDocVisitor visitor(ts,codeGen,def->getDefFileExtension(),FALSE);
root->accept(&visitor);
}
break;
// TODO: support other generators
default:
err("context.cpp: output format not yet supported");
break;
}
}
bool isEmpty = root->isEmpty();
if (isEmpty)
result = "";
else
result = TemplateVariant(docs,TRUE);
delete root;
return result;
}

Variable Documentation

struct ContextGlobals g_globals