Skip to content

Commit

Permalink
Template enhancements and various other small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitri van Heesch committed Sep 8, 2015
1 parent 5aa4ade commit e58fb0a
Show file tree
Hide file tree
Showing 69 changed files with 739 additions and 219 deletions.
386 changes: 350 additions & 36 deletions src/context.cpp

Large diffs are not rendered by default.

38 changes: 30 additions & 8 deletions src/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,15 @@ class DirContext : public RefCountedContext, public TemplateStructIntf
class PageContext : public RefCountedContext, public TemplateStructIntf
{
public:
static PageContext *alloc(PageDef *pd,bool isMainPage=FALSE) { return new PageContext(pd,isMainPage); }
static PageContext *alloc(PageDef *pd,bool isMainPage,bool isExample) { return new PageContext(pd,isMainPage,isExample); }

// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
virtual int addRef() { return RefCountedContext::addRef(); }
virtual int release() { return RefCountedContext::release(); }

private:
PageContext(PageDef *,bool isMainPage);
PageContext(PageDef *,bool isMainPage,bool isExample);
~PageContext();
class Private;
Private *p;
Expand Down Expand Up @@ -710,15 +710,15 @@ class PageListContext : public RefCountedContext, public TemplateListIntf
class PageTreeContext : public RefCountedContext, public TemplateStructIntf
{
public:
static PageTreeContext *alloc() { return new PageTreeContext; }
static PageTreeContext *alloc(const PageSDict *pages) { return new PageTreeContext(pages); }

// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
virtual int addRef() { return RefCountedContext::addRef(); }
virtual int release() { return RefCountedContext::release(); }

private:
PageTreeContext();
PageTreeContext(const PageSDict *pages);
~PageTreeContext();
class Private;
Private *p;
Expand Down Expand Up @@ -788,13 +788,15 @@ class ModuleTreeContext : public RefCountedContext, public TemplateStructIntf

//----------------------------------------------------

class ExampleListContext : public RefCountedContext, public TemplateStructIntf
class ExampleListContext : public RefCountedContext, public TemplateListIntf
{
public:
static ExampleListContext *alloc() { return new ExampleListContext(); }
static ExampleListContext *alloc() { return new ExampleListContext; }

// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
// TemplateListIntf methods
virtual int count() const;
virtual TemplateVariant at(int index) const;
virtual TemplateListIntf::ConstIterator *createIterator() const;
virtual int addRef() { return RefCountedContext::addRef(); }
virtual int release() { return RefCountedContext::release(); }

Expand All @@ -807,6 +809,26 @@ class ExampleListContext : public RefCountedContext, public TemplateStructIntf

//----------------------------------------------------


class ExampleTreeContext : public RefCountedContext, public TemplateStructIntf
{
public:
static ExampleTreeContext *alloc() { return new ExampleTreeContext; }

// TemplateStructIntf methods
virtual TemplateVariant get(const char *name) const;
virtual int addRef() { return RefCountedContext::addRef(); }
virtual int release() { return RefCountedContext::release(); }

private:
ExampleTreeContext();
~ExampleTreeContext();
class Private;
Private *p;
};

//----------------------------------------------------

class GlobalsIndexContext : public RefCountedContext, public TemplateStructIntf
{
public:
Expand Down
23 changes: 23 additions & 0 deletions src/definition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1943,4 +1943,27 @@ bool Definition::hasBriefDescription() const
return !briefDescription().isEmpty() && briefMemberDesc;
}

QCString Definition::externalReference(const QCString &relPath) const
{
QCString ref = getReference();
if (!ref.isEmpty())
{
QCString *dest = Doxygen::tagDestinationDict[ref];
if (dest)
{
QCString result = *dest;
int l = result.length();
if (!relPath.isEmpty() && l>0 && result.at(0)=='.')
{ // relative path -> prepend relPath.
result.prepend(relPath);
l+=relPath.length();
}
if (l>0 && result.at(l-1)!='/') result+='/';
return result;
}
}
return relPath;
}



3 changes: 3 additions & 0 deletions src/definition.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ class Definition : public DefinitionIntf
/*! Returns TRUE if this definition is imported via a tag file. */
virtual bool isReference() const;

/*! Convenience method to return a resolved external link */
QCString externalReference(const QCString &relPath) const;

/*! Returns the first line of the body of this item (applicable to classes and
* functions).
*/
Expand Down
2 changes: 1 addition & 1 deletion src/diagram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ static void writeMapArea(FTextStream &t,ClassDef *cd,QCString relPath,
QCString tooltip = cd->briefDescriptionAsTooltip();
if (!tooltip.isEmpty())
{
t << "title=\"" << tooltip << "\" ";
t << "title=\"" << convertToHtml(tooltip) << "\" ";
}
t << "alt=\"" << convertToXML(cd->displayName());
t << "\" shape=\"rect\" coords=\"" << x << "," << y << ",";
Expand Down
8 changes: 4 additions & 4 deletions src/doxygen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7847,7 +7847,7 @@ static void generateFileSources()
QStrList filesInSameTu;
fd->getAllIncludeFilesRecursively(filesInSameTu);
fd->startParsing();
if (fd->generateSourceFile()) // sources need to be shown in the output
if (fd->generateSourceFile() && !g_useOutputTemplate) // sources need to be shown in the output
{
msg("Generating code for file %s...\n",fd->docName().data());
fd->writeSource(*g_outputList,FALSE,filesInSameTu);
Expand All @@ -7870,7 +7870,7 @@ static void generateFileSources()
FileDef *ifd=findFileDef(Doxygen::inputNameDict,incFile,ambig);
if (ifd && !ifd->isReference())
{
if (ifd->generateSourceFile()) // sources need to be shown in the output
if (ifd->generateSourceFile() && !g_useOutputTemplate) // sources need to be shown in the output
{
msg(" Generating code for file %s...\n",ifd->docName().data());
ifd->writeSource(*g_outputList,TRUE,moreFiles);
Expand Down Expand Up @@ -7903,7 +7903,7 @@ static void generateFileSources()
{
QStrList filesInSameTu;
fd->startParsing();
if (fd->generateSourceFile()) // sources need to be shown in the output
if (fd->generateSourceFile() && !g_useOutputTemplate) // sources need to be shown in the output
{
msg("Generating code for file %s...\n",fd->docName().data());
fd->writeSource(*g_outputList,FALSE,filesInSameTu);
Expand Down Expand Up @@ -7933,7 +7933,7 @@ static void generateFileSources()
{
QStrList filesInSameTu;
fd->startParsing();
if (fd->generateSourceFile()) // sources need to be shown in the output
if (fd->generateSourceFile() && !g_useOutputTemplate) // sources need to be shown in the output
{
msg("Generating code for file %s...\n",fd->docName().data());
fd->writeSource(*g_outputList,FALSE,filesInSameTu);
Expand Down
2 changes: 1 addition & 1 deletion src/htmldocvisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1927,7 +1927,7 @@ void HtmlDocVisitor::startLink(const QCString &ref,const QCString &file,
if (!file.isEmpty()) m_t << file << Doxygen::htmlFileExtension;
if (!anchor.isEmpty()) m_t << "#" << anchor;
m_t << "\"";
if (!tooltip.isEmpty()) m_t << " title=\"" << substitute(tooltip,"\"","&quot;") << "\"";
if (!tooltip.isEmpty()) m_t << " title=\"" << convertToHtml(tooltip) << "\"";
m_t << ">";
}

Expand Down
8 changes: 3 additions & 5 deletions src/htmlgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ void HtmlCodeGenerator::_writeCodeLink(const char *className,
if (f) m_t << f << Doxygen::htmlFileExtension;
if (anchor) m_t << "#" << anchor;
m_t << "\"";
if (tooltip) m_t << " title=\"" << tooltip << "\"";
if (tooltip) m_t << " title=\"" << convertToHtml(tooltip) << "\"";
m_t << ">";
docify(name);
m_t << "</a>";
Expand Down Expand Up @@ -1340,11 +1340,9 @@ void HtmlGenerator::endClassDiagram(const ClassDiagram &d,
startSectionContent(t,m_sectionCount);
t << " <div class=\"center\">" << endl;
t << " <img src=\"";
t << relPath << fileName << ".png\" usemap=\"#";
docify(name);
t << relPath << fileName << ".png\" usemap=\"#" << convertToId(name);
t << "_map\" alt=\"\"/>" << endl;
t << " <map id=\"";
docify(name);
t << " <map id=\"" << convertToId(name);
t << "_map\" name=\"";
docify(name);
t << "_map\">" << endl;
Expand Down
6 changes: 3 additions & 3 deletions src/index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1640,7 +1640,7 @@ static void writeAnnotatedClassList(OutputList &ol)
static QCString letterToLabel(uint startLetter)
{
char s[11]; // max 0x12345678 + '\0'
if (startLetter>0x20 && startLetter<=0x7f) // printable ASCII character
if (isId(startLetter)) // printable ASCII character
{
s[0]=(char)startLetter;
s[1]=0;
Expand Down Expand Up @@ -2476,8 +2476,8 @@ static void writeQuickMemberIndex(OutputList &ol,
anchor=fullName+extension+"#index_";
else
anchor=fullName+"_"+letterToLabel(i)+extension+"#index_";
startQuickIndexItem(ol,anchor+ci,i==page,TRUE,first);
ol.writeString(is);
startQuickIndexItem(ol,anchor+is,i==page,TRUE,first);
ol.writeString(ci);
endQuickIndexItem(ol);
first=FALSE;
}
Expand Down
2 changes: 1 addition & 1 deletion src/latexgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ LatexCodeGenerator::LatexCodeGenerator(FTextStream &t,const QCString &relPath,co
setTextStream(t);
}

LatexCodeGenerator::LatexCodeGenerator() : m_col(0)
LatexCodeGenerator::LatexCodeGenerator() : m_col(0), m_streamSet(FALSE)
{
m_prettyCode=Config_getBool("LATEX_SOURCE_CODE");
}
Expand Down
16 changes: 11 additions & 5 deletions src/memberdef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -967,7 +967,7 @@ QCString MemberDef::getOutputFileBase() const
return baseName;
}
}
else if (m_impl->nspace)
else if (m_impl->nspace && m_impl->nspace->isLinkableInProject())
{
baseName=m_impl->nspace->getOutputFileBase();
}
Expand Down Expand Up @@ -1092,7 +1092,8 @@ void MemberDef::_computeLinkableInProject()
m_isLinkableCached = 1; // in class but class not linkable
return;
}
if (!m_impl->group && m_impl->nspace && !m_impl->related && !m_impl->nspace->isLinkableInProject())
if (!m_impl->group && m_impl->nspace && !m_impl->related && !m_impl->nspace->isLinkableInProject()
&& (m_impl->fileDef==0 || !m_impl->fileDef->isLinkableInProject()))
{
//printf("in a namespace but namespace not linkable!\n");
m_isLinkableCached = 1; // in namespace but namespace not linkable
Expand Down Expand Up @@ -1914,7 +1915,7 @@ bool MemberDef::isDetailedSectionVisible(bool inGroup,bool inFile) const
static bool inlineSimpleStructs = Config_getBool("INLINE_SIMPLE_STRUCTS");
static bool hideUndocMembers = Config_getBool("HIDE_UNDOC_MEMBERS");
bool groupFilter = getGroupDef()==0 || inGroup || separateMemPages;
bool fileFilter = getNamespaceDef()==0 || !inFile;
bool fileFilter = getNamespaceDef()==0 || !getNamespaceDef()->isLinkable() || !inFile;
bool simpleFilter = (hasBriefDescription() || !hideUndocMembers) && inlineSimpleStructs &&
getClassDef()!=0 && getClassDef()->isSimple();

Expand Down Expand Up @@ -2261,7 +2262,7 @@ void MemberDef::_writeCategoryRelation(OutputList &ol)
text = theTranslator->trExtendsClass();
name = m_impl->classDef->categoryOf()->displayName();
}
i=text.find("@1");
i=text.find("@0");
if (i!=-1)
{
MemberDef *md = m_impl->categoryRelation;
Expand Down Expand Up @@ -2495,7 +2496,7 @@ void MemberDef::_writeGroupInclude(OutputList &ol,bool inGroup)

if (isIDLorJava) ol.docify("\""); else ol.docify("<");

if (fd && fd->isLinkable())
if (fd->isLinkable())
{
ol.writeObjectLink(fd->getReference(),fd->getOutputFileBase(),fd->anchor(),nm);
}
Expand Down Expand Up @@ -4481,6 +4482,11 @@ MemberDef *MemberDef::getEnumScope() const
return m_impl->enumScope;
}

bool MemberDef::livesInsideEnum() const
{
return m_impl->livesInsideEnum;
}

MemberList *MemberDef::enumFieldList() const
{
return m_impl->enumFields;
Expand Down
1 change: 1 addition & 0 deletions src/memberdef.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class MemberDef : public Definition
bool protectionVisible() const;
bool showInCallGraph() const;
bool isStrongEnumValue() const;
bool livesInsideEnum() const;

// derived getters
bool isFriendToHide() const;
Expand Down
4 changes: 2 additions & 2 deletions src/memberlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,8 +435,8 @@ void MemberList::writePlainDeclarations(OutputList &ol,
}
delete rootNode;
}
ol.endMemberDeclaration(md->anchor(),inheritId);
ol.endMemberItem();
ol.endMemberDeclaration(md->anchor(),inheritId);
}
md->warnIfUndocumented();
break;
Expand Down Expand Up @@ -681,7 +681,7 @@ void MemberList::writeDocumentation(OutputList &ol,
}
if (memberGroupList)
{
//printf("MemberList::writeDocumentation() -- member groups\n");
printf("MemberList::writeDocumentation() -- member groups %d\n",memberGroupList->count());
MemberGroupListIterator mgli(*memberGroupList);
MemberGroup *mg;
for (;(mg=mgli.current());++mgli)
Expand Down
39 changes: 34 additions & 5 deletions src/template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,31 @@ class FilterRaw

//-----------------------------------------------------------------------------

/** @brief The implementation of the "list" filter */
class FilterList
{
public:
static TemplateVariant apply(const TemplateVariant &v,const TemplateVariant &)
{
if (v.isValid())
{
if (v.type()==TemplateVariant::List) // input is already a list
{
return v;
}
// create a list with v as the only element
TemplateList *list = TemplateList::alloc();
list->append(v);
return list;
}
else
{
return v;
}
}
};

//-----------------------------------------------------------------------------
/** @brief The implementation of the "texlabel" filter */
class FilterTexLabel
{
Expand Down Expand Up @@ -1268,16 +1293,19 @@ class FilterAlphaIndex
static QCString keyToLabel(uint startLetter)
{
char s[11]; // 0x12345678 + '\0'
if (startLetter>0x20 && startLetter<=0x7f) // printable ASCII character
if ((startLetter>='0' && startLetter<='9') ||
(startLetter>='a' && startLetter<='z') ||
(startLetter>='A' && startLetter<='Z'))
{
s[0]=tolower((char)startLetter);
s[1]=0;
int i=0;
if (startLetter>='0' && startLetter<='9') s[i++] = 'x';
s[i++]=tolower((char)startLetter);
s[i++]=0;
}
else
{
const char hex[]="0123456789abcdef";
int i=0;
s[i++]='0';
s[i++]='x';
if (startLetter>(1<<24)) // 4 byte character
{
Expand Down Expand Up @@ -1492,6 +1520,7 @@ class TemplateFilterFactory
static TemplateFilterFactory::AutoRegister<FilterAdd> fAdd("add");
static TemplateFilterFactory::AutoRegister<FilterGet> fGet("get");
static TemplateFilterFactory::AutoRegister<FilterRaw> fRaw("raw");
static TemplateFilterFactory::AutoRegister<FilterList> fList("list");
static TemplateFilterFactory::AutoRegister<FilterAppend> fAppend("append");
static TemplateFilterFactory::AutoRegister<FilterLength> fLength("length");
static TemplateFilterFactory::AutoRegister<FilterNoWrap> fNoWrap("nowrap");
Expand Down Expand Up @@ -2429,7 +2458,7 @@ class TemplateImpl : public TemplateNode, public Template

TemplateContextImpl::TemplateContextImpl(const TemplateEngine *e)
: m_engine(e), m_templateName("<unknown>"), m_line(1), m_activeEscapeIntf(0),
m_spacelessIntf(0), m_spacelessEnabled(FALSE), m_indices(TemplateStruct::alloc())
m_spacelessIntf(0), m_spacelessEnabled(FALSE), m_tabbingEnabled(FALSE), m_indices(TemplateStruct::alloc())
{
m_indexStacks.setAutoDelete(TRUE);
m_contextStack.setAutoDelete(TRUE);
Expand Down
Loading

0 comments on commit e58fb0a

Please sign in to comment.