summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/context.cpp22
-rw-r--r--src/context.h1
-rw-r--r--src/doxygen.cpp7
-rw-r--r--src/resourcemgr.cpp7
-rw-r--r--src/resourcemgr.h4
-rw-r--r--src/template.cpp27
-rw-r--r--src/template.h3
7 files changed, 64 insertions, 7 deletions
diff --git a/src/context.cpp b/src/context.cpp
index 67b4e12..9973a59 100644
--- a/src/context.cpp
+++ b/src/context.cpp
@@ -46,12 +46,11 @@
#include "arguments.h"
#include "groupdef.h"
#include "searchindex.h"
+#include "resourcemgr.h"
// TODO: pass the current file to Dot*::writeGraph, so the user can put dot graphs in other
// files as well
-#define ADD_PROPERTY(name) addProperty(#name,this,&Private::name);
-
enum ContextOutputFormat
{
ContextOutputFormat_Unspecified=0,
@@ -10168,6 +10167,7 @@ void generateOutputViaTemplate()
//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)
{
@@ -10192,6 +10192,7 @@ void generateOutputViaTemplate()
//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)
{
@@ -10241,3 +10242,20 @@ void generateOutputViaTemplate()
#endif
}
+void generateTemplateFiles(const char *templateDir)
+{
+ 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;
+ }
+ ResourceMgr::instance().writeCategory("html",outDir);
+}
diff --git a/src/context.h b/src/context.h
index 7c98222..e082c4b 100644
--- a/src/context.h
+++ b/src/context.h
@@ -1347,5 +1347,6 @@ class SearchIndicesContext : public RefCountedContext, public TemplateListIntf
//----------------------------------------------------
void generateOutputViaTemplate();
+void generateTemplateFiles(const char *templateDir);
#endif
diff --git a/src/doxygen.cpp b/src/doxygen.cpp
index b67ce18..04a8b57 100644
--- a/src/doxygen.cpp
+++ b/src/doxygen.cpp
@@ -10417,6 +10417,13 @@ void readConfiguration(int argc, char **argv)
Config::init();
+ if (genConfig && g_useOutputTemplate)
+ {
+ generateTemplateFiles("templates");
+ cleanUpDoxygen();
+ exit(0);
+ }
+
if (genConfig)
{
generateConfigFile(configName,shortList);
diff --git a/src/resourcemgr.cpp b/src/resourcemgr.cpp
index 6bc1da4..ab7422a 100644
--- a/src/resourcemgr.cpp
+++ b/src/resourcemgr.cpp
@@ -56,7 +56,7 @@ void ResourceMgr::registerResources(const Resource resources[],int numResources)
}
}
-bool ResourceMgr::copyCategory(const char *categoryName,const char *targetDir) const
+bool ResourceMgr::writeCategory(const char *categoryName,const char *targetDir) const
{
QDictIterator<Resource> it(p->resources);
const Resource *res;
@@ -64,8 +64,11 @@ bool ResourceMgr::copyCategory(const char *categoryName,const char *targetDir) c
{
if (qstrcmp(res->category,categoryName)==0)
{
- if (!copyResource(res->name,targetDir))
+ QCString pathName = QCString(targetDir)+"/"+res->name;
+ QFile f(pathName);
+ if (!f.open(IO_WriteOnly) || f.writeBlock((const char *)res->data,res->size)!=res->size)
{
+ err("Failed to write resource '%s' to directory '%s'\n",res->name,targetDir);
return FALSE;
}
}
diff --git a/src/resourcemgr.h b/src/resourcemgr.h
index 57b3e37..6e1587d 100644
--- a/src/resourcemgr.h
+++ b/src/resourcemgr.h
@@ -38,8 +38,8 @@ class ResourceMgr
/** Registers an array of resources */
void registerResources(const Resource resources[],int numResources);
- /** Copies all resource belonging to a given category to a given target directory */
- bool copyCategory(const char *categoryName,const char *targetDir) const;
+ /** Writes all resource belonging to a given category to a given target directory */
+ bool writeCategory(const char *categoryName,const char *targetDir) const;
/** Copies a registered resource to a given target directory */
bool copyResource(const char *name,const char *targetDir) const;
diff --git a/src/template.cpp b/src/template.cpp
index 3e354c3..9e814d7 100644
--- a/src/template.cpp
+++ b/src/template.cpp
@@ -5027,8 +5027,23 @@ class TemplateEngine::Private
//printf("loadByName(%s,%d) {\n",fileName.data(),line);
m_includeStack.append(new IncludeEntry(IncludeEntry::Template,fileName,QCString(),line));
Template *templ = m_templateCache.find(fileName);
- if (templ==0)
+ if (templ==0) // first time template is referenced
{
+ QCString filePath = m_templateDirName+"/"+fileName;
+ QFile f(filePath);
+ if (f.open(IO_ReadOnly))
+ {
+ QFileInfo fi(filePath);
+ int size=fi.size();
+ QCString data(size+1);
+ if (f.readBlock(data.rawData(),size)==size)
+ {
+ templ = new TemplateImpl(m_engine,filePath,data,m_extension);
+ m_templateCache.insert(fileName,templ);
+ return templ;
+ }
+ }
+ // fallback to default built-in template
const QCString data = ResourceMgr::instance().getAsString(fileName);
if (!data.isEmpty())
{
@@ -5101,12 +5116,18 @@ class TemplateEngine::Private
return m_extension;
}
+ void setTemplateDir(const char *dirName)
+ {
+ m_templateDirName = dirName;
+ }
+
private:
QDict<Template> m_templateCache;
//mutable int m_indent;
TemplateEngine *m_engine;
QList<IncludeEntry> m_includeStack;
QCString m_extension;
+ QCString m_templateDirName;
};
TemplateEngine::TemplateEngine()
@@ -5164,5 +5185,9 @@ QCString TemplateEngine::outputExtension() const
return p->outputExtension();
}
+void TemplateEngine::setTemplateDir(const char *dirName)
+{
+ p->setTemplateDir(dirName);
+}
diff --git a/src/template.h b/src/template.h
index 7d6e2ff..98ae7ed 100644
--- a/src/template.h
+++ b/src/template.h
@@ -590,6 +590,9 @@ class TemplateEngine
/** Prints the current template file include stack */
void printIncludeContext(const char *fileName,int line) const;
+ /** Sets the search directory where to look for template files */
+ void setTemplateDir(const char *dirName);
+
private:
friend class TemplateNodeBlock;
friend class TemplateNodeCreate;