Commit 9282aab5 authored by Dimitri van Heesch's avatar Dimitri van Heesch

Template context support for CREATE_SUBDIRS

parent 7e3e890f
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
* *
*/ */
#include <qdir.h>
#include "context.h" #include "context.h"
#include "config.h" #include "config.h"
#include "index.h" #include "index.h"
...@@ -286,7 +288,7 @@ class ConfigContext::Private ...@@ -286,7 +288,7 @@ class ConfigContext::Private
{ {
public: public:
Private() { m_cachedLists.setAutoDelete(TRUE); } Private() { m_cachedLists.setAutoDelete(TRUE); }
~Private() { } virtual ~Private() { }
TemplateVariant fetchList(const QCString &name,const QStrList *list) TemplateVariant fetchList(const QCString &name,const QStrList *list)
{ {
TemplateVariant *v = m_cachedLists.find(name); TemplateVariant *v = m_cachedLists.find(name);
...@@ -663,6 +665,19 @@ class TranslateContext::Private : public PropertyMapper ...@@ -663,6 +665,19 @@ class TranslateContext::Private : public PropertyMapper
static bool extractAll = Config_getBool("EXTRACT_ALL"); static bool extractAll = Config_getBool("EXTRACT_ALL");
return theTranslator->trNamespaceMemberDescription(extractAll); return theTranslator->trNamespaceMemberDescription(extractAll);
} }
TemplateVariant classMembersDescription() const
{
static bool extractAll = Config_getBool("EXTRACT_ALL");
static bool fortranOpt = Config_getBool("OPTIMIZE_FOR_FORTRAN");
if (fortranOpt)
{
return theTranslator->trCompoundMembersDescriptionFortran(extractAll);
}
else
{
return theTranslator->trCompoundMembersDescription(extractAll);
}
}
TemplateVariant relatedPagesDesc() const TemplateVariant relatedPagesDesc() const
{ {
return theTranslator->trRelatedPagesDescription(); return theTranslator->trRelatedPagesDescription();
...@@ -805,6 +820,11 @@ class TranslateContext::Private : public PropertyMapper ...@@ -805,6 +820,11 @@ class TranslateContext::Private : public PropertyMapper
bool extractAll = Config_getBool("EXTRACT_ALL"); bool extractAll = Config_getBool("EXTRACT_ALL");
return theTranslator->trModulesListDescription(extractAll); return theTranslator->trModulesListDescription(extractAll);
} }
TemplateVariant namespaceListDescription() const
{
bool extractAll = Config_getBool("EXTRACT_ALL");
return theTranslator->trNamespaceListDescription(extractAll);
}
TemplateVariant directories() const TemplateVariant directories() const
{ {
return theTranslator->trDirectories(); return theTranslator->trDirectories();
...@@ -871,6 +891,8 @@ class TranslateContext::Private : public PropertyMapper ...@@ -871,6 +891,8 @@ class TranslateContext::Private : public PropertyMapper
addProperty("classHierarchy", this,&Private::classHierarchy); addProperty("classHierarchy", this,&Private::classHierarchy);
//%% string classMembers //%% string classMembers
addProperty("classMembers", this,&Private::classMembers); addProperty("classMembers", this,&Private::classMembers);
//%% string classMembersDescription
addProperty("classMembersDescription",this,&Private::classMembersDescription);
//%% string modules //%% string modules
addProperty("modules", this,&Private::modules); addProperty("modules", this,&Private::modules);
//%% string namespaces //%% string namespaces
...@@ -961,6 +983,8 @@ class TranslateContext::Private : public PropertyMapper ...@@ -961,6 +983,8 @@ class TranslateContext::Private : public PropertyMapper
addProperty("detailLevel", this,&Private::detailLevel); addProperty("detailLevel", this,&Private::detailLevel);
//%% string fileListDescription //%% string fileListDescription
addProperty("fileListDescription",this,&Private::fileListDescription); addProperty("fileListDescription",this,&Private::fileListDescription);
//%% string namespaceListDescription
addProperty("namespaceListDescription",this,&Private::namespaceListDescription);
//%% string directories //%% string directories
addProperty("directories", this,&Private::directories); addProperty("directories", this,&Private::directories);
//%% string moduleDescript //%% string moduleDescript
...@@ -1177,7 +1201,7 @@ class DefinitionContext : public PropertyMapper ...@@ -1177,7 +1201,7 @@ class DefinitionContext : public PropertyMapper
static bool createSubdirs = Config_getBool("CREATE_SUBDIRS"); static bool createSubdirs = Config_getBool("CREATE_SUBDIRS");
return createSubdirs ? QCString("../../") : QCString(""); return createSubdirs ? QCString("../../") : QCString("");
} }
TemplateVariant relPath() const virtual TemplateVariant relPath() const
{ {
return relPathAsString(); return relPathAsString();
} }
...@@ -1499,6 +1523,7 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private> ...@@ -1499,6 +1523,7 @@ class ClassContext::Private : public DefinitionContext<ClassContext::Private>
addProperty("memberGroups", this,&Private::memberGroups); addProperty("memberGroups", this,&Private::memberGroups);
addProperty("additionalInheritedMembers",this,&Private::additionalInheritedMembers); addProperty("additionalInheritedMembers",this,&Private::additionalInheritedMembers);
} }
virtual ~Private() {}
TemplateVariant title() const TemplateVariant title() const
{ {
return TemplateVariant(m_classDef->title()); return TemplateVariant(m_classDef->title());
...@@ -2175,6 +2200,7 @@ class NamespaceContext::Private : public DefinitionContext<NamespaceContext::Pri ...@@ -2175,6 +2200,7 @@ class NamespaceContext::Private : public DefinitionContext<NamespaceContext::Pri
addProperty("detailedVariables", this,&Private::detailedVariables); addProperty("detailedVariables", this,&Private::detailedVariables);
addProperty("inlineClasses", this,&Private::inlineClasses); addProperty("inlineClasses", this,&Private::inlineClasses);
} }
virtual ~Private() {}
TemplateVariant title() const TemplateVariant title() const
{ {
return TemplateVariant(m_namespaceDef->title()); return TemplateVariant(m_namespaceDef->title());
...@@ -2433,6 +2459,7 @@ class FileContext::Private : public DefinitionContext<FileContext::Private> ...@@ -2433,6 +2459,7 @@ class FileContext::Private : public DefinitionContext<FileContext::Private>
addProperty("inlineClasses", this,&Private::inlineClasses); addProperty("inlineClasses", this,&Private::inlineClasses);
addProperty("compoundType", this,&Private::compoundType); addProperty("compoundType", this,&Private::compoundType);
} }
virtual ~Private() {}
TemplateVariant title() const TemplateVariant title() const
{ {
return m_fileDef->title(); return m_fileDef->title();
...@@ -2789,6 +2816,7 @@ class DirContext::Private : public DefinitionContext<DirContext::Private> ...@@ -2789,6 +2816,7 @@ class DirContext::Private : public DefinitionContext<DirContext::Private>
addProperty("hasDetails", this,&Private::hasDetails); addProperty("hasDetails", this,&Private::hasDetails);
addProperty("compoundType", this,&Private::compoundType); addProperty("compoundType", this,&Private::compoundType);
} }
virtual ~Private() {}
TemplateVariant title() const TemplateVariant title() const
{ {
return TemplateVariant(m_dirDef->shortTitle()); return TemplateVariant(m_dirDef->shortTitle());
...@@ -2849,6 +2877,10 @@ class DirContext::Private : public DefinitionContext<DirContext::Private> ...@@ -2849,6 +2877,10 @@ class DirContext::Private : public DefinitionContext<DirContext::Private>
{ {
return theTranslator->trDir(FALSE,TRUE); return theTranslator->trDir(FALSE,TRUE);
} }
TemplateVariant relPath() const
{
return "";
}
private: private:
DirDef *m_dirDef; DirDef *m_dirDef;
...@@ -2891,6 +2923,7 @@ class PageContext::Private : public DefinitionContext<PageContext::Private> ...@@ -2891,6 +2923,7 @@ class PageContext::Private : public DefinitionContext<PageContext::Private>
addProperty("highlight",this,&Private::highlight); addProperty("highlight",this,&Private::highlight);
addProperty("subhighlight",this,&Private::subHighlight); addProperty("subhighlight",this,&Private::subHighlight);
} }
virtual ~Private() {}
TemplateVariant title() const TemplateVariant title() const
{ {
if (m_isMainPage) if (m_isMainPage)
...@@ -2909,10 +2942,28 @@ class PageContext::Private : public DefinitionContext<PageContext::Private> ...@@ -2909,10 +2942,28 @@ class PageContext::Private : public DefinitionContext<PageContext::Private>
return m_pageDef->title(); return m_pageDef->title();
} }
} }
TemplateVariant relPath() const
{
if (m_pageDef==Doxygen::mainPage)
{
return "";
}
else
{
return DefinitionContext<PageContext::Private>::relPath();
}
}
TemplateVariant highlight() const TemplateVariant highlight() const
{
if (m_pageDef==Doxygen::mainPage)
{
return "main";
}
else
{ {
return "pages"; return "pages";
} }
}
TemplateVariant subHighlight() const TemplateVariant subHighlight() const
{ {
return ""; return "";
...@@ -3186,6 +3237,7 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private> ...@@ -3186,6 +3237,7 @@ class MemberContext::Private : public DefinitionContext<MemberContext::Private>
if (md->isRaisable()) m_cache.eventAttrs->append("raise"); if (md->isRaisable()) m_cache.eventAttrs->append("raise");
} }
} }
virtual ~Private() {}
TemplateVariant fieldType() const TemplateVariant fieldType() const
{ {
return createLinkedText(m_memberDef,relPathAsString(),m_memberDef->fieldType()); return createLinkedText(m_memberDef,relPathAsString(),m_memberDef->fieldType());
...@@ -4161,6 +4213,7 @@ class ModuleContext::Private : public DefinitionContext<ModuleContext::Private> ...@@ -4161,6 +4213,7 @@ class ModuleContext::Private : public DefinitionContext<ModuleContext::Private>
addProperty("inlineClasses", this,&Private::inlineClasses); addProperty("inlineClasses", this,&Private::inlineClasses);
addProperty("compoundType", this,&Private::compoundType); addProperty("compoundType", this,&Private::compoundType);
} }
virtual ~Private() {}
TemplateVariant title() const TemplateVariant title() const
{ {
return TemplateVariant(m_groupDef->groupTitle()); return TemplateVariant(m_groupDef->groupTitle());
...@@ -5784,6 +5837,23 @@ TemplateListIntf::ConstIterator *NamespaceListContext::createIterator() const ...@@ -5784,6 +5837,23 @@ TemplateListIntf::ConstIterator *NamespaceListContext::createIterator() const
class NamespaceTreeContext::Private : public PropertyMapper class NamespaceTreeContext::Private : public PropertyMapper
{ {
public: public:
Private()
{
m_namespaceTree.reset(NestingContext::alloc(0,0));
if (Doxygen::namespaceSDict)
{
m_namespaceTree->addNamespaces(*Doxygen::namespaceSDict,TRUE,FALSE);
}
//%% Nesting tree
addProperty("tree",this,&Private::tree);
addProperty("fileName",this,&Private::fileName);
addProperty("relPath",this,&Private::relPath);
addProperty("highlight",this,&Private::highlight);
addProperty("subhighlight",this,&Private::subhighlight);
addProperty("title",this,&Private::title);
addProperty("preferredDepth",this,&Private::preferredDepth);
addProperty("maxDepth",this,&Private::maxDepth);
}
TemplateVariant tree() const TemplateVariant tree() const
{ {
return m_namespaceTree.get(); return m_namespaceTree.get();
...@@ -5822,23 +5892,35 @@ class NamespaceTreeContext::Private : public PropertyMapper ...@@ -5822,23 +5892,35 @@ class NamespaceTreeContext::Private : public PropertyMapper
return theTranslator->trNamespaceList(); return theTranslator->trNamespaceList();
} }
} }
Private() TemplateVariant maxDepth() const
{ {
m_namespaceTree.reset(NestingContext::alloc(0,0)); if (!m_cache.maxDepthComputed)
if (Doxygen::namespaceSDict)
{ {
m_namespaceTree->addNamespaces(*Doxygen::namespaceSDict,TRUE,FALSE); m_cache.maxDepth = computeMaxDepth(m_namespaceTree.get());
m_cache.maxDepthComputed=TRUE;
} }
//%% Nesting tree return m_cache.maxDepth;
addProperty("tree",this,&Private::tree); }
addProperty("fileName",this,&Private::fileName); TemplateVariant preferredDepth() const
addProperty("relPath",this,&Private::relPath); {
addProperty("highlight",this,&Private::highlight); if (!m_cache.preferredDepthComputed)
addProperty("subhighlight",this,&Private::subhighlight); {
addProperty("title",this,&Private::title); m_cache.preferredDepth = computePreferredDepth(m_namespaceTree.get(),maxDepth().toInt());
m_cache.preferredDepthComputed=TRUE;
}
return m_cache.preferredDepth;
} }
private: private:
SharedPtr<NestingContext> m_namespaceTree; SharedPtr<NestingContext> m_namespaceTree;
struct Cachable
{
Cachable() : maxDepthComputed(FALSE), preferredDepthComputed(FALSE) {}
int maxDepth;
bool maxDepthComputed;
int preferredDepth;
bool preferredDepthComputed;
};
mutable Cachable m_cache;
}; };
//%% } //%% }
...@@ -7581,7 +7663,7 @@ class InheritedMemberInfoContext::Private : public PropertyMapper ...@@ -7581,7 +7663,7 @@ class InheritedMemberInfoContext::Private : public PropertyMapper
addProperty("id", this,&Private::id); addProperty("id", this,&Private::id);
addProperty("inheritedFrom", this,&Private::inheritedFrom); addProperty("inheritedFrom", this,&Private::inheritedFrom);
} }
~Private() virtual ~Private()
{ {
delete m_memberList; delete m_memberList;
} }
...@@ -8120,6 +8202,8 @@ void generateOutputViaTemplate() ...@@ -8120,6 +8202,8 @@ void generateOutputViaTemplate()
g_globals.outputFormat = ContextGlobals::Html; g_globals.outputFormat = ContextGlobals::Html;
g_globals.dynSectionId = 0; g_globals.dynSectionId = 0;
g_globals.outputDir = Config_getString("HTML_OUTPUT"); g_globals.outputDir = Config_getString("HTML_OUTPUT");
QDir dir(g_globals.outputDir);
createSubDirs(dir);
HtmlEscaper htmlEsc; HtmlEscaper htmlEsc;
ctx->setEscapeIntf(Config_getString("HTML_FILE_EXTENSION"),&htmlEsc); ctx->setEscapeIntf(Config_getString("HTML_FILE_EXTENSION"),&htmlEsc);
HtmlSpaceless spl; HtmlSpaceless spl;
......
...@@ -66,7 +66,7 @@ class RefCountedContext ...@@ -66,7 +66,7 @@ class RefCountedContext
m_className=className; m_className=className;
m_insideRelease = FALSE; m_insideRelease = FALSE;
} }
virtual ~RefCountedContext() ~RefCountedContext()
{ {
if (!m_insideRelease) abort(); if (!m_insideRelease) abort();
} }
......
...@@ -1360,7 +1360,7 @@ QCString Definition::qualifiedName() const ...@@ -1360,7 +1360,7 @@ QCString Definition::qualifiedName() const
//printf("end %s::qualifiedName()=%s\n",name().data(),m_impl->qualifiedName.data()); //printf("end %s::qualifiedName()=%s\n",name().data(),m_impl->qualifiedName.data());
//count--; //count--;
return m_impl->qualifiedName; return m_impl->qualifiedName;
}; }
void Definition::setOuterScope(Definition *d) void Definition::setOuterScope(Definition *d)
{ {
......
...@@ -5102,6 +5102,6 @@ bool MemberDef::isFunctionOrSignalSlot() const ...@@ -5102,6 +5102,6 @@ bool MemberDef::isFunctionOrSignalSlot() const
bool MemberDef::isRelatedOrFriend() const bool MemberDef::isRelatedOrFriend() const
{ {
return isRelated() || isForeign() || isFriend() && !isFriendToHide(); return isRelated() || isForeign() || (isFriend() && !isFriendToHide());
} }
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <qfile.h> #include <qfile.h>
#include <qregexp.h> #include <qregexp.h>
#include <qcstring.h> #include <qcstring.h>
#include <qdir.h>
#include "sortdict.h" #include "sortdict.h"
#include "ftextstream.h" #include "ftextstream.h"
...@@ -3465,6 +3466,25 @@ class TemplateNodeCreate : public TemplateNodeCreator<TemplateNodeCreate> ...@@ -3465,6 +3466,25 @@ class TemplateNodeCreate : public TemplateNodeCreator<TemplateNodeCreate>
delete m_templateExpr; delete m_templateExpr;
delete m_fileExpr; delete m_fileExpr;
} }
void mkpath(TemplateContextImpl *ci,const QCString &fileName)
{
int i=fileName.find('/');
QCString outputDir = ci->outputDirectory();
QDir d(outputDir);
int j=0;
while (i!=-1) // fileName contains path part
{
if (d.exists())
{
bool ok = d.mkdir(fileName.mid(j,i-j));
if (!ok) break;
QCString dirName = outputDir+'/'+fileName.left(i);
d = QDir(dirName);
j = i+1;
}
i=fileName.find('/',i+1);
}
}
void render(FTextStream &, TemplateContext *c) void render(FTextStream &, TemplateContext *c)
{ {
TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c); TemplateContextImpl* ci = dynamic_cast<TemplateContextImpl*>(c);
...@@ -3490,6 +3510,7 @@ class TemplateNodeCreate : public TemplateNodeCreator<TemplateNodeCreate> ...@@ -3490,6 +3510,7 @@ class TemplateNodeCreate : public TemplateNodeCreator<TemplateNodeCreate>
TemplateImpl *createTemplate = ct ? dynamic_cast<TemplateImpl*>(ct) : 0; TemplateImpl *createTemplate = ct ? dynamic_cast<TemplateImpl*>(ct) : 0;
if (createTemplate) if (createTemplate)
{ {
//mkpath(ci,outputFile);
QCString extension=outputFile; QCString extension=outputFile;
int i=extension.findRev('.'); int i=extension.findRev('.');
if (i!=-1) if (i!=-1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment