Commit 31198c21 authored by Dimitri van Heesch's avatar Dimitri van Heesch

More template and context updates

parent 7cda115a
......@@ -94,7 +94,7 @@ class ClassDefImpl
ArgumentList *typeConstraints;
/*! Files that were used for generating the class documentation. */
QStrList files;
FileList files;
/*! Examples that use this class */
ExampleSDict *exampleSDict;
......@@ -764,16 +764,17 @@ void ClassDef::findSectionsInDocumentation()
// add a file name to the used files set
void ClassDef::insertUsedFile(const char *f)
void ClassDef::insertUsedFile(FileDef *fd)
{
if (m_impl->files.find(f)==-1) m_impl->files.append(f);
if (fd==0) return;
if (m_impl->files.find(fd)==-1) m_impl->files.append(fd);
if (m_impl->templateInstances)
{
QDictIterator<ClassDef> qdi(*m_impl->templateInstances);
ClassDef *cd;
for (qdi.toFirst();(cd=qdi.current());++qdi)
{
cd->insertUsedFile(f);
cd->insertUsedFile(fd);
}
}
}
......@@ -916,12 +917,6 @@ static void writeTemplateSpec(OutputList &ol,Definition *d,
}
}
bool ClassDef::hasBriefDescription() const
{
static bool briefMemberDesc = Config_getBool("BRIEF_MEMBER_DESC");
return !briefDescription().isEmpty() && briefMemberDesc;
}
void ClassDef::writeBriefDescription(OutputList &ol,bool exampleFlag)
{
if (hasBriefDescription())
......@@ -1039,45 +1034,49 @@ void ClassDef::writeDetailedDescription(OutputList &ol, const QCString &/*pageTy
}
}
void ClassDef::showUsedFiles(OutputList &ol)
QCString ClassDef::generatedFromFiles() const
{
ol.pushGeneratorState();
ol.disable(OutputGenerator::Man);
QCString result;
SrcLangExt lang = getLanguage();
ol.writeRuler();
if (lang==SrcLangExt_Fortran)
{
ol.parseText(theTranslator->trGeneratedFromFilesFortran(
result = theTranslator->trGeneratedFromFilesFortran(
getLanguage()==SrcLangExt_ObjC && m_impl->compType==Interface ? Class : m_impl->compType,
m_impl->files.count()==1));
m_impl->files.count()==1);
}
else if (isJavaEnum())
{
ol.parseText(theTranslator->trEnumGeneratedFromFiles(m_impl->files.count()==1));
result = theTranslator->trEnumGeneratedFromFiles(m_impl->files.count()==1);
}
else if (m_impl->compType==Service)
{
ol.parseText(theTranslator->trServiceGeneratedFromFiles(m_impl->files.count()==1));
result = theTranslator->trServiceGeneratedFromFiles(m_impl->files.count()==1);
}
else if (m_impl->compType==Singleton)
{
ol.parseText(theTranslator->trSingletonGeneratedFromFiles(m_impl->files.count()==1));
result = theTranslator->trSingletonGeneratedFromFiles(m_impl->files.count()==1);
}
else
{
ol.parseText(theTranslator->trGeneratedFromFiles(
result = theTranslator->trGeneratedFromFiles(
getLanguage()==SrcLangExt_ObjC && m_impl->compType==Interface ? Class : m_impl->compType,
m_impl->files.count()==1));
m_impl->files.count()==1);
}
return result;
}
void ClassDef::showUsedFiles(OutputList &ol)
{
ol.pushGeneratorState();
ol.disable(OutputGenerator::Man);
ol.writeRuler();
ol.parseText(generatedFromFiles());
bool first=TRUE;
const char *file = m_impl->files.first();
while (file)
{
bool ambig;
FileDef *fd=findFileDef(Doxygen::inputNameDict,file,ambig);
if (fd)
FileDef *fd = m_impl->files.first();
while (fd)
{
if (first)
{
......@@ -1131,18 +1130,16 @@ void ClassDef::showUsedFiles(OutputList &ol)
ol.popGeneratorState();
ol.endItemListItem();
}
file=m_impl->files.next();
fd=m_impl->files.next();
}
if (!first) ol.endItemList();
ol.popGeneratorState();
}
void ClassDef::writeInheritanceGraph(OutputList &ol)
int ClassDef::countInheritanceNodes()
{
// count direct inheritance relations
int count=0;
BaseClassDef *ibcd;
if (m_impl->inheritedBy)
......@@ -1165,7 +1162,13 @@ void ClassDef::writeInheritanceGraph(OutputList &ol)
ibcd=m_impl->inherits->next();
}
}
return count;
}
void ClassDef::writeInheritanceGraph(OutputList &ol)
{
// count direct inheritance relations
int count=countInheritanceNodes();
bool renderDiagram = FALSE;
if (Config_getBool("HAVE_DOT") &&
......@@ -1322,6 +1325,24 @@ void ClassDef::writeCollaborationGraph(OutputList &ol)
}
}
QCString ClassDef::includeStatement() const
{
SrcLangExt lang = getLanguage();
bool isIDLorJava = lang==SrcLangExt_IDL || lang==SrcLangExt_Java;
if (isIDLorJava)
{
return "import";
}
else if (isObjectiveC())
{
return "#import ";
}
else
{
return "#include ";
}
}
void ClassDef::writeIncludeFiles(OutputList &ol)
{
if (m_impl->incInfo /*&& Config_getBool("SHOW_INCLUDE_FILES")*/)
......@@ -1335,20 +1356,9 @@ void ClassDef::writeIncludeFiles(OutputList &ol)
{
ol.startParagraph();
ol.startTypewriter();
ol.docify(includeStatement());
SrcLangExt lang = getLanguage();
bool isIDLorJava = lang==SrcLangExt_IDL || lang==SrcLangExt_Java;
if (isIDLorJava)
{
ol.docify("import ");
}
else if (isObjectiveC())
{
ol.docify("#import ");
}
else
{
ol.docify("#include ");
}
if (m_impl->incInfo->local || isIDLorJava)
ol.docify("\"");
else
......@@ -4743,3 +4753,8 @@ const ClassSDict *ClassDef::innerClasses() const
return m_impl->innerClasses;
}
const FileList &ClassDef::usedFiles() const
{
return m_impl->files;
}
......@@ -31,6 +31,7 @@ class ClassList;
class ClassSDict;
class OutputList;
class FileDef;
class FileList;
class BaseClassList;
class NamespaceDef;
class MemberDef;
......@@ -125,9 +126,6 @@ class ClassDef : public Definition
/** returns TRUE if this class has documentation */
bool hasDocumentation() const;
/** returns TRUE if this class has a brief description */
bool hasBriefDescription() const;
/** returns TRUE if this class has a non-empty detailed description */
bool hasDetailedDescription() const;
......@@ -310,6 +308,11 @@ class ClassDef : public Definition
const ClassSDict *innerClasses() const;
QCString title() const;
QCString generatedFromFiles() const;
const FileList &usedFiles() const;
QCString includeStatement() const;
//-----------------------------------------------------------------------------------
// --- setters ----
//-----------------------------------------------------------------------------------
......@@ -318,7 +321,7 @@ class ClassDef : public Definition
void insertSubClass(ClassDef *,Protection p,Specifier s,const char *t=0);
void setIncludeFile(FileDef *fd,const char *incName,bool local,bool force);
void insertMember(MemberDef *);
void insertUsedFile(const char *);
void insertUsedFile(FileDef *);
bool addExample(const char *anchor,const char *name, const char *file);
void mergeCategory(ClassDef *category);
void setNamespace(NamespaceDef *nd);
......@@ -375,6 +378,7 @@ class ClassDef : public Definition
void addGroupedInheritedMembers(OutputList &ol,MemberListType lt,
ClassDef *inheritedFrom,const QCString &inheritId);
int countMembersIncludingGrouped(MemberListType lt,ClassDef *inheritedFrom,bool additional);
int countInheritanceNodes();
bool visited;
......
This diff is collapsed.
#ifndef CONTEXT_H
#define CONTEXT_H
#include "types.h"
#include "template.h"
class Definition;
class ClassDef;
class ClassSDict;
class BaseClassList;
class PageDef;
class GroupDef;
class NamespaceDef;
......@@ -21,6 +23,11 @@ class PageSDict;
class GroupSDict;
class GroupDef;
class GroupList;
struct IncludeInfo;
class MemberList;
class MemberDef;
struct Argument;
class ArgumentList;
//----------------------------------------------------
......@@ -72,6 +79,42 @@ class TranslateContext : public TemplateStructIntf
//----------------------------------------------------
class UsedFilesContext : public TemplateListIntf
{
public:
UsedFilesContext(ClassDef *cd);
~UsedFilesContext();
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
void addFile(FileDef *fd);
private:
class Private;
Private *p;
};
//----------------------------------------------------
class IncludeInfoContext : public TemplateStructIntf
{
public:
IncludeInfoContext(IncludeInfo *,SrcLangExt lang);
~IncludeInfoContext();
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
private:
class Private;
Private *p;
};
//----------------------------------------------------
class ClassContext : public TemplateStructIntf
{
public:
......@@ -150,6 +193,23 @@ class PageContext : public TemplateStructIntf
Private *p;
};
//----------------------------------------------------
class MemberContext : public TemplateStructIntf
{
public:
MemberContext(MemberDef *);
~MemberContext();
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
private:
class Private;
Private *p;
};
//----------------------------------------------------
class ModuleContext : public TemplateStructIntf
......@@ -168,6 +228,26 @@ class ModuleContext : public TemplateStructIntf
//----------------------------------------------------
class NestedClassListContext : public TemplateListIntf
{
public:
NestedClassListContext();
~NestedClassListContext();
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
void append(ClassDef *cd);
private:
class Private;
Private *p;
};
//----------------------------------------------------
class ClassListContext : public TemplateListIntf
{
public:
......@@ -530,6 +610,109 @@ class ExampleListContext : public TemplateStructIntf
//----------------------------------------------------
class InheritanceNodeContext : public TemplateStructIntf
{
public:
InheritanceNodeContext(ClassDef *cd,const QCString &name);
~InheritanceNodeContext();
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
private:
class Private;
Private *p;
};
//----------------------------------------------------
class InheritanceListContext : public TemplateListIntf
{
public:
InheritanceListContext(const BaseClassList *list,bool baseClasses);
~InheritanceListContext();
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
private:
class Private;
Private *p;
};
//----------------------------------------------------
class MemberListContext : public TemplateListIntf
{
public:
MemberListContext(const MemberList *ml);
~MemberListContext();
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
private:
class Private;
Private *p;
};
//----------------------------------------------------
class MemberListInfoContext : public TemplateStructIntf
{
public:
MemberListInfoContext(const MemberList *ml,const QCString &title,
const QCString &subtitle=QCString());
~MemberListInfoContext();
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
private:
class Private;
Private *p;
};
//----------------------------------------------------
class ArgumentContext : public TemplateStructIntf
{
public:
ArgumentContext(const Argument *arg);
~ArgumentContext();
// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
private:
class Private;
Private *p;
};
//----------------------------------------------------
class ArgumentListContext : public TemplateListIntf
{
public:
ArgumentListContext(const ArgumentList *al);
~ArgumentListContext();
// TemplateListIntf
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
private:
class Private;
Private *p;
};
//----------------------------------------------------
void generateOutputViaTemplate();
#endif
......@@ -1876,4 +1876,10 @@ void Definition::_setSymbolName(const QCString &name)
m_symbolName=name;
}
bool Definition::hasBriefDescription() const
{
static bool briefMemberDesc = Config_getBool("BRIEF_MEMBER_DESC");
return !briefDescription().isEmpty() && briefMemberDesc;
}
......@@ -260,6 +260,9 @@ class Definition : public DefinitionIntf
bool hasSections() const;
/** returns TRUE if this class has a brief description */
bool hasBriefDescription() const;
QCString id() const;
//-----------------------------------------------------------------------------------
......
......@@ -1336,8 +1336,7 @@ static void addClassToContext(EntryNav *rootNav)
// see if the class is found inside a namespace
//bool found=addNamespace(root,cd);
// the empty string test is needed for extract all case
cd->insertUsedFile(root->fileName);
cd->insertUsedFile(fd);
// add class to the list
//printf("ClassDict.insert(%s)\n",resolveDefines(fullName).data());
......@@ -1537,7 +1536,6 @@ static ClassDef *createTagLessInstance(ClassDef *rootCd,ClassDef *templ,const QC
gd->addClass(cd);
}
}
//cd->insertUsedFile(root->fileName);
//printf("** adding class %s based on %s\n",fullName.data(),templ->name().data());
Doxygen::classSDict->append(fullName,cd);
......@@ -1776,7 +1774,7 @@ static void buildNamespaceList(EntryNav *rootNav)
// the empty string test is needed for extract all case
nd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
nd->insertUsedFile(root->fileName);
nd->insertUsedFile(fd);
nd->setBodySegment(root->bodyLine,root->endBodyLine);
nd->setBodyDef(fd);
// add class to the list
......@@ -1954,7 +1952,7 @@ static void findUsingDirectives(EntryNav *rootNav)
// the empty string test is needed for extract all case
nd->setBriefDescription(root->brief,root->briefFile,root->briefLine);
nd->insertUsedFile(root->fileName);
nd->insertUsedFile(fd);
// add class to the list
Doxygen::namespaceSDict->inSort(name,nd);
nd->setRefItems(root->sli);
......@@ -2373,7 +2371,7 @@ static MemberDef *addVariableToClass(
md->setRefItems(root->sli);
//TODO: insert FileDef instead of filename strings.
cd->insertUsedFile(root->fileName);
cd->insertUsedFile(rootNav->fileDef());
rootNav->changeSection(Entry::EMPTY_SEC);
return md;
}
......@@ -3114,7 +3112,7 @@ static void addInterfaceOrServiceToServiceOrSingleton(
findClassRelation(rootNav,cd,cd,&base,0,DocumentedOnly,true)
|| findClassRelation(rootNav,cd,cd,&base,0,Undocumented,true);
// add file to list of used files
cd->insertUsedFile(root->fileName);
cd->insertUsedFile(fd);
addMemberToGroups(root,md);
rootNav->changeSection(Entry::EMPTY_SEC);
......@@ -3357,7 +3355,7 @@ static void addMethodToClass(EntryNav *rootNav,ClassDef *cd,
// add member to the class cd
cd->insertMember(md);
// add file to list of used files
cd->insertUsedFile(root->fileName);
cd->insertUsedFile(fd);
addMemberToGroups(root,md);
rootNav->changeSection(Entry::EMPTY_SEC);
......@@ -4831,7 +4829,7 @@ static bool findClassRelation(
// add this class as super class to the base class
baseClass->insertSubClass(cd,bi->prot,bi->virt,templSpec);
// the undocumented base was found in this file
baseClass->insertUsedFile(root->fileName);
baseClass->insertUsedFile(rootNav->fileDef());
baseClass->setOuterScope(Doxygen::globalScope);
if (baseClassName.right(2)=="-p")
{
......@@ -5344,7 +5342,7 @@ static void addMemberDocs(EntryNav *rootNav,
md->mergeMemberSpecifiers(root->spec);
md->addSectionsToDefinition(root->anchors);
addMemberToGroups(root,md);
if (cd) cd->insertUsedFile(root->fileName);
if (cd) cd->insertUsedFile(rfd);
//printf("root->mGrpId=%d\n",root->mGrpId);
if (root->mGrpId!=-1)
{
......@@ -6424,7 +6422,7 @@ static void findMember(EntryNav *rootNav,
md->setMemberGroupId(root->mGrpId);
mn->append(md);
cd->insertMember(md);
cd->insertUsedFile(root->fileName);
cd->insertUsedFile(fd);
md->setRefItems(root->sli);
}
}
......@@ -6621,7 +6619,7 @@ static void findMember(EntryNav *rootNav,
//md->setMemberDefTemplateArguments(root->mtArgList);
mn->append(md);
cd->insertMember(md);
cd->insertUsedFile(root->fileName);
cd->insertUsedFile(fd);
md->setRefItems(root->sli);
if (root->relatesType == Duplicate) md->setRelatedAlso(cd);
if (!isDefine)
......@@ -6693,7 +6691,7 @@ localObjCMethod:
md->setMemberSpecifiers(root->spec);
md->setMemberGroupId(root->mGrpId);
cd->insertMember(md);
cd->insertUsedFile(root->fileName);
cd->insertUsedFile(fd);
md->setRefItems(root->sli);
if ((mn=Doxygen::memberNameSDict->find(root->name)))
{
......@@ -7077,7 +7075,7 @@ static void findEnums(EntryNav *rootNav)
md->setDefinition(cd->name()+"::"+name+baseType);
}
cd->insertMember(md);
cd->insertUsedFile(root->fileName);
cd->insertUsedFile(fd);
}
md->setDocumentation(root->doc,root->docFile,root->docLine);
md->setDocsForDefinition(!root->proto);
......
......@@ -1390,6 +1390,33 @@ bool MemberDef::isBriefSectionVisible() const
return visible;
}
QCString MemberDef::getDeclType() const
{
QCString ltype(m_impl->type);
if (m_impl->mtype==MemberType_Typedef)
{
ltype.prepend("typedef ");
}
if (isAlias())
{
ltype="using";
}
// strip `friend' keyword from ltype
ltype.stripPrefix("friend ");
if (ltype=="@") // rename type from enum values
{
ltype="";
}
else
{
if (isObjCMethod())
{
ltype.prepend("(");
ltype.append(")");
}
}
return ltype;
}
void MemberDef::writeDeclaration(OutputList &ol,
ClassDef *cd,NamespaceDef *nd,FileDef *fd,GroupDef *gd,
......@@ -1678,7 +1705,7 @@ void MemberDef::writeDeclaration(OutputList &ol,
// *** write bitfields
if (!m_impl->bitfields.isEmpty()) // add bitfields
{
linkifyText(TextGeneratorOLImpl(ol),d,getBodyDef(),this,m_impl->bitfields.simplifyWhiteSpace());
linkifyText(TextGeneratorOLImpl(ol),d,getBodyDef(),this,m_impl->bitfields);
}
else if (hasOneLineInitializer()
//!init.isEmpty() && initLines==0 && // one line initializer
......@@ -2978,7 +3005,7 @@ void MemberDef::writeMemberDocSimple(OutputList &ol, Definition *container)
}
if (!m_impl->bitfields.isEmpty()) // add bitfields
{
linkifyText(TextGeneratorOLImpl(ol),getOuterScope(),getBodyDef(),this,m_impl->bitfields.simplifyWhiteSpace());
linkifyText(TextGeneratorOLImpl(ol),getOuterScope(),getBodyDef(),this,m_impl->bitfields);
}
ol.endInlineMemberName();
......@@ -4433,7 +4460,7 @@ void MemberDef::mergeMemberSpecifiers(uint64 s)
void MemberDef::setBitfields(const char *s)
{
m_impl->bitfields = s;
m_impl->bitfields = QCString(s).simplifyWhiteSpace();
}
void MemberDef::setMaxInitLines(int lines)
......
......@@ -241,6 +241,7 @@ class MemberDef : public Definition
MemberDef *categoryRelation() const;
QCString displayName(bool=TRUE) const;
QCString getDeclType() const;
//-----------------------------------------------------------------------------------
// ---- setters -----
......
......@@ -115,14 +115,15 @@ void NamespaceDef::findSectionsInDocumentation()
}
}
void NamespaceDef::insertUsedFile(const char *f)
void NamespaceDef::insertUsedFile(FileDef *fd)
{
if (files.find(f)==-1)
if (fd==0) return;
if (files.find(fd)==-1)
{
if (Config_getBool("SORT_MEMBER_DOCS"))
files.inSort(f);
files.inSort(fd);
else
files.append(f);
files.append(fd);
}
}
......
......@@ -22,6 +22,7 @@
#include <qdict.h>
#include "sortdict.h"
#include "definition.h"
#include "filedef.h"
class MemberList;
class ClassDef;
......@@ -45,7 +46,7 @@ class NamespaceDef : public Definition
DefType definitionType() const { return TypeNamespace; }
QCString getOutputFileBase() const;
QCString anchor() const { return QCString(); }
void insertUsedFile(const char *fname);
void insertUsedFile(FileDef *fd);
void writeDocumentation(OutputList &ol);
void writeMemberPages(OutputList &ol);
......@@ -117,7 +118,7 @@ class NamespaceDef : public Definition
void addNamespaceAttributes(OutputList &ol);
QCString fileName;
QStrList files;
FileList files;
NamespaceSDict *usingDirList;
SDict<Definition> *usingDeclList;
......
This diff is collapsed.
......@@ -42,8 +42,10 @@ class TemplateEngine;
* - `for ... empty ... endfor`
* - `if ... else ... endif`
* - `block ... endblock`
* - `extends`
* - `extend`
* - `include`
* - `with ... endwith`
* - `spaceless ... endspaceless`
*
* Supported Django filters:
* - `default`
......@@ -53,6 +55,13 @@ class TemplateEngine;
* Extension tags:
* - `create` which instantiates a template and writes the result to a file.
* The syntax is `{% create 'filename' from 'template' %}`.
* - `recursetree`
* - `markers`
*
* Extension filters:
* - `stripPath`
* - `nowrap`
* - `prepend`
*
* @{
*/
......@@ -62,7 +71,7 @@ class TemplateVariant
{
public:
/** Signature of the callback function, used for function type variants */
typedef QCString (*FuncType)(const void *obj, const QValueList<TemplateVariant> &args);
typedef TemplateVariant (*FuncType)(const void *obj, const QValueList<TemplateVariant> &args);
/** Types of data that can be stored in a TemplateVariant */
enum Type { None, Bool, Integer, String, Struct, List, Function };
......@@ -83,10 +92,10 @@ class TemplateVariant
TemplateVariant(int v);
/** Constructs a new variant with a string value \a s. */
TemplateVariant(const char *s);
TemplateVariant(const char *s,bool raw=FALSE);
/** Constructs a new variant with a string value \a s. */
TemplateVariant(const QCString &s);
TemplateVariant(const QCString &s,bool raw=FALSE);
/** Constructs a new variant with a struct value \a s.
* @note. Only a pointer to the struct is stored. The caller
......@@ -146,7 +155,7 @@ class TemplateVariant
/** Return the result of apply this function with \a args.
* Returns an empty string if the variant type is not a function.
*/
QCString call(const QValueList<TemplateVariant> &args);
TemplateVariant call(const QValueList<TemplateVariant> &args);
/** Sets whether or not the value of the Variant should be
* escaped or written as-is (raw).
......@@ -283,6 +292,16 @@ class TemplateEscapeIntf
//------------------------------------------------------------------------
/** @brief Interface used to remove redundant spaces inside a spaceless block */
class TemplateSpacelessIntf
{
public:
/** Returns the \a input after removing redundant whitespace */
virtual QCString remove(const QCString &input) = 0;
};
//------------------------------------------------------------------------
/** @brief Abstract interface for a template context.
*
* A Context consists of a stack of dictionaries.
......@@ -333,6 +352,11 @@ class TemplateContext
* of variable expansion before writing it to the output.
*/
virtual void setEscapeIntf(TemplateEscapeIntf *intf) = 0;
/** Sets the interface that will be used inside a spaceless block
* to remove any redundant whitespace.
*/
virtual void setSpacelessIntf(TemplateSpacelessIntf *intf) = 0;
};
//------------------------------------------------------------------------
......
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