Commit bcd90114 authored by Dimitri van Heesch's avatar Dimitri van Heesch

Merge pull request #131 from albert-github/feature/bug_725516

Bug 725516 - In case of sections with the same name they are not reported.
parents 4c707ade ac611be4
......@@ -553,7 +553,7 @@ static void addXRefItem(const char *listName,const char *itemTitle,
item->text += " <p>";
if (Doxygen::markdownSupport)
{
item->text += processMarkdown(yyFileName,current,outputXRef);
item->text += processMarkdown(yyFileName,yyLineNr,current,outputXRef);
}
else
{
......@@ -575,7 +575,7 @@ static void addXRefItem(const char *listName,const char *itemTitle,
ASSERT(item!=0);
if (Doxygen::markdownSupport)
{
item->text = processMarkdown(yyFileName,current,outputXRef);
item->text = processMarkdown(yyFileName,yyLineNr,current,outputXRef);
}
else
{
......@@ -593,11 +593,26 @@ static void addXRefItem(const char *listName,const char *itemTitle,
{
docEntry->doc += cmdString;
}
SectionInfo *si=new SectionInfo(listName,anchorLabel,
g_sectionTitle,SectionInfo::Anchor,
g_sectionLevel);
Doxygen::sectionDict->append(anchorLabel,si);
docEntry->anchors->append(si);
SectionInfo *si = Doxygen::sectionDict->find(anchorLabel);
if (si)
{
if (si->lineNr != -1)
{
warn(listName,yyLineNr,"multiple use of section label '%s', (first occurrence: %s, line %d)",anchorLabel,si->fileName.data(),si->lineNr);
}
else
{
warn(listName,yyLineNr,"multiple use of section label '%s', (first occurrence: %s)",anchorLabel,si->fileName.data());
}
}
else
{
si=new SectionInfo(listName,yyLineNr,anchorLabel,
g_sectionTitle,SectionInfo::Anchor,
g_sectionLevel);
Doxygen::sectionDict->append(anchorLabel,si);
docEntry->anchors->append(si);
}
}
outputXRef.resize(0);
}
......@@ -643,18 +658,32 @@ static SectionInfo::SectionType sectionLevelToType(int level)
static void addSection()
{
// create a new section element
g_sectionTitle+=yytext;
g_sectionTitle=g_sectionTitle.stripWhiteSpace();
SectionInfo *si = new SectionInfo(yyFileName,g_sectionLabel,
SectionInfo *si = Doxygen::sectionDict->find(g_sectionLabel);
if (si)
{
if (si->lineNr != -1)
{
warn(yyFileName,yyLineNr,"multiple use of section label '%s', (first occurrence: %s, line %d)",g_sectionLabel.data(),si->fileName.data(),si->lineNr);
}
else
{
warn(yyFileName,yyLineNr,"multiple use of section label '%s', (first occurrence: %s)",g_sectionLabel.data(),si->fileName.data());
}
}
else
{
// create a new section element
g_sectionTitle+=yytext;
g_sectionTitle=g_sectionTitle.stripWhiteSpace();
si = new SectionInfo(yyFileName,yyLineNr,g_sectionLabel,
g_sectionTitle,sectionLevelToType(g_sectionLevel),g_sectionLevel);
// add section to this entry
current->anchors->append(si);
// add section to the global dictionary
Doxygen::sectionDict->append(g_sectionLabel,si);
// add section to this entry
current->anchors->append(si);
// add section to the global dictionary
Doxygen::sectionDict->append(g_sectionLabel,si);
}
}
//-----------------------------------------------------------------------------
......@@ -1701,9 +1730,24 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
/* ----- handle arguments of the anchor command ------- */
<AnchorLabel>{LABELID} { // found argument
SectionInfo *si = new SectionInfo(yyFileName,yytext,0,SectionInfo::Anchor,0);
Doxygen::sectionDict->append(yytext,si);
current->anchors->append(si);
SectionInfo *si = Doxygen::sectionDict->find(yytext);
if (si)
{
if (si->lineNr != -1)
{
warn(yyFileName,yyLineNr,"multiple use of section label '%s', (first occurrence: %s, line %d)",yytext,si->fileName.data(),si->lineNr);
}
else
{
warn(yyFileName,yyLineNr,"multiple use of section label '%s', (first occurrence: %s)",yytext,si->fileName.data());
}
}
else
{
si = new SectionInfo(yyFileName,yyLineNr,yytext,0,SectionInfo::Anchor,0);
Doxygen::sectionDict->append(yytext,si);
current->anchors->append(si);
}
addOutput(yytext);
BEGIN( Comment );
}
......@@ -2876,9 +2920,9 @@ bool parseCommentBlock(/* in */ ParserInterface *parser,
if (Doxygen::markdownSupport)
{
current->brief = processMarkdown(fileName,current,current->brief);
current->doc = processMarkdown(fileName,current,current->doc);
current->inbodyDocs = processMarkdown(fileName,current,current->inbodyDocs);
current->brief = processMarkdown(fileName,lineNr,current,current->brief);
current->doc = processMarkdown(fileName,lineNr,current,current->doc);
current->inbodyDocs = processMarkdown(fileName,lineNr,current,current->inbodyDocs);
}
Debug::print(Debug::CommentScan,0,
......
......@@ -8643,15 +8643,30 @@ static void findMainPage(EntryNav *rootNav)
Doxygen::mainPage->setShowToc(root->stat);
addPageToContext(Doxygen::mainPage,rootNav);
// a page name is a label as well!
SectionInfo *si=new SectionInfo(
indexName,
SectionInfo *si = Doxygen::sectionDict->find(Doxygen::mainPage->name());
if (si)
{
if (si->lineNr != -1)
{
warn(root->fileName,root->startLine,"multiple use of section label '%s', (first occurrence: %s, line %d)",Doxygen::mainPage->name().data(),si->fileName.data(),si->lineNr);
}
else
{
warn(root->fileName,root->startLine,"multiple use of section label '%s', (first occurrence: %s)",Doxygen::mainPage->name().data(),si->fileName.data());
}
}
else
{
// a page name is a label as well! but should no be double either
si=new SectionInfo(
indexName, root->startLine,
Doxygen::mainPage->name(),
Doxygen::mainPage->title(),
SectionInfo::Page,
0); // level 0
Doxygen::sectionDict->append(indexName,si);
Doxygen::mainPage->addSectionsToDefinition(root->anchors);
Doxygen::sectionDict->append(indexName,si);
Doxygen::mainPage->addSectionsToDefinition(root->anchors);
}
}
else
{
......
......@@ -48,6 +48,7 @@
#include "commentcnv.h"
#include "config.h"
#include "section.h"
#include "message.h"
//-----------
......@@ -90,6 +91,7 @@ static QDict<LinkRef> g_linkRefs(257);
static action_t g_actions[256];
static Entry *g_current;
static QCString g_fileName;
static int g_lineNr;
// In case a markdown page starts with a level1 header, that header is used
// as a title of the page, in effect making it a level0 header, so the
......@@ -1690,12 +1692,27 @@ void writeOneLineHeaderOrRuler(GrowBuf &out,const char *data,int size)
out.addStr(" ");
out.addStr(header);
out.addStr("\n");
SectionInfo *si = new SectionInfo(g_fileName,id,header,type,level);
if (g_current)
SectionInfo *si = Doxygen::sectionDict->find(header);
if (si)
{
g_current->anchors->append(si);
if (si->lineNr != -1)
{
warn(g_fileName,g_lineNr,"multiple use of section label '%s', (first occurrence: %s, line %d)",header.data(),si->fileName.data(),si->lineNr);
}
else
{
warn(g_fileName,g_lineNr,"multiple use of section label '%s', (first occurrence: %s)",header.data(),si->fileName.data());
}
}
else
{
si = new SectionInfo(g_fileName,g_lineNr,id,header,type,level);
if (g_current)
{
g_current->anchors->append(si);
}
Doxygen::sectionDict->append(header,si);
}
Doxygen::sectionDict->append(header,si);
}
else
{
......@@ -2020,13 +2037,28 @@ static QCString processBlocks(const QCString &s,int indent)
out.addStr(" ");
out.addStr(header);
out.addStr("\n\n");
SectionInfo *si = new SectionInfo(g_fileName,id,header,
level==1 ? SectionInfo::Section : SectionInfo::Subsection,level);
if (g_current)
SectionInfo *si = Doxygen::sectionDict->find(header);
if (si)
{
g_current->anchors->append(si);
if (si->lineNr != -1)
{
warn(g_fileName,g_lineNr,"multiple use of section label '%s', (first occurrence: %s, line %d)",header.data(),si->fileName.data(),si->lineNr);
}
else
{
warn(g_fileName,g_lineNr,"multiple use of section label '%s', (first occurrence: %s)",header.data(),si->fileName.data());
}
}
else
{
si = new SectionInfo(g_fileName,g_lineNr,id,header,
level==1 ? SectionInfo::Section : SectionInfo::Subsection,level);
if (g_current)
{
g_current->anchors->append(si);
}
Doxygen::sectionDict->append(header,si);
}
Doxygen::sectionDict->append(header,si);
}
else
{
......@@ -2214,7 +2246,7 @@ static QCString detab(const QCString &s,int &refIndent)
//---------------------------------------------------------------------------
QCString processMarkdown(const QCString &fileName,Entry *e,const QCString &input)
QCString processMarkdown(const QCString &fileName,const int lineNr,Entry *e,const QCString &input)
{
static bool init=FALSE;
if (!init)
......@@ -2237,6 +2269,7 @@ QCString processMarkdown(const QCString &fileName,Entry *e,const QCString &input
g_linkRefs.clear();
g_current = e;
g_fileName = fileName;
g_lineNr = lineNr;
static GrowBuf out;
if (input.isEmpty()) return input;
out.clear();
......
......@@ -22,7 +22,7 @@
class Entry;
/** processes string \a s and converts markdown into doxygen/html commands. */
QCString processMarkdown(const QCString &fileName,Entry *e,const QCString &s);
QCString processMarkdown(const QCString &fileName,const int lineNr,Entry *e,const QCString &s);
QCString markdownFileNameToId(const QCString &fileName);
class MarkdownFileParser : public ParserInterface
......
......@@ -139,6 +139,7 @@ void marshalSectionInfoList(StorageIntf *s, QList<SectionInfo> *anchors)
marshalQCString(s,si->ref);
marshalInt(s,(int)si->type);
marshalQCString(s,si->fileName);
marshalInt(s,si->lineNr);
marshalInt(s,si->level);
}
}
......@@ -546,8 +547,9 @@ QList<SectionInfo> *unmarshalSectionInfoList(StorageIntf *s)
QCString ref = unmarshalQCString(s);
SectionInfo::SectionType type = (SectionInfo::SectionType)unmarshalInt(s);
QCString fileName = unmarshalQCString(s);
int lineNr = unmarshalInt(s);
int level = unmarshalInt(s);
result->append(new SectionInfo(fileName,label,title,type,level,ref));
result->append(new SectionInfo(fileName,lineNr,label,title,type,level,ref));
}
return result;
}
......
......@@ -33,17 +33,23 @@ struct SectionInfo
Paragraph = 4,
Anchor = 5
};
SectionInfo(const char *f,const char *l,const char *t,
SectionInfo(const char *f,const int lin,const char *l,const char *t,
SectionType st,int lev,const char *r=0) :
label(l), title(t), type(st), ref(r), definition(0),
fileName(f), generated(FALSE), level(lev)
fileName(f), generated(FALSE), level(lev), lineNr(lin)
{
}
SectionInfo(const SectionInfo &s)
{
label=s.label.copy(); title=s.title.copy(); ref=s.ref.copy();
type =s.type; definition=s.definition;
fileName=s.fileName.copy(); generated=s.generated;
label=s.label.copy();
title=s.title.copy();
type =s.type;
ref=s.ref.copy();
definition=s.definition;
fileName=s.fileName.copy();
lineNr=s.lineNr;
generated=s.generated;
level=s.level;
}
~SectionInfo() {}
QCString label;
......@@ -52,6 +58,7 @@ struct SectionInfo
QCString ref;
Definition *definition;
QCString fileName;
int lineNr;
bool generated;
int level;
};
......
......@@ -1120,7 +1120,7 @@ void TagFileParser::addDocAnchors(Entry *e,const TagAnchorInfoList &l)
{
//printf("New sectionInfo file=%s anchor=%s\n",
// ta->fileName.data(),ta->label.data());
SectionInfo *si=new SectionInfo(ta->fileName,ta->label,ta->title,
SectionInfo *si=new SectionInfo(ta->fileName,-1,ta->label,ta->title,
SectionInfo::Anchor,0,m_tagName);
Doxygen::sectionDict->append(ta->label,si);
e->anchors->append(si);
......
......@@ -6280,14 +6280,29 @@ PageDef *addRelatedPage(const char *name,const QCString &ptitle,
{
file=pd->getOutputFileBase();
}
SectionInfo *si=new SectionInfo(
file,pd->name(),pd->title(),SectionInfo::Page,0,pd->getReference());
//printf("si->label=`%s' si->definition=%s si->fileName=`%s'\n",
// si->label.data(),si->definition?si->definition->name().data():"<none>",
// si->fileName.data());
//printf(" SectionInfo: sec=%p sec->fileName=%s\n",si,si->fileName.data());
//printf("Adding section key=%s si->fileName=%s\n",pageName.data(),si->fileName.data());
Doxygen::sectionDict->append(pd->name(),si);
SectionInfo *si = Doxygen::sectionDict->find(pd->name());
if (si)
{
if (si->lineNr != -1)
{
warn(file,-1,"multiple use of section label '%s', (first occurrence: %s, line %d)",pd->name().data(),si->fileName.data(),si->lineNr);
}
else
{
warn(file,-1,"multiple use of section label '%s', (first occurrence: %s)",pd->name().data(),si->fileName.data());
}
}
else
{
si=new SectionInfo(
file,-1,pd->name(),pd->title(),SectionInfo::Page,0,pd->getReference());
//printf("si->label=`%s' si->definition=%s si->fileName=`%s'\n",
// si->label.data(),si->definition?si->definition->name().data():"<none>",
// si->fileName.data());
//printf(" SectionInfo: sec=%p sec->fileName=%s\n",si,si->fileName.data());
//printf("Adding section key=%s si->fileName=%s\n",pageName.data(),si->fileName.data());
Doxygen::sectionDict->append(pd->name(),si);
}
}
}
return pd;
......
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