summaryrefslogtreecommitdiffstats
path: root/src/markdown.cpp
diff options
context:
space:
mode:
authoralbert-github <albert.tests@gmail.com>2014-03-02 19:32:42 (GMT)
committeralbert-github <albert.tests@gmail.com>2014-03-02 19:32:42 (GMT)
commitac611be473c2d9bf65bcafb53b0577274c4ae706 (patch)
tree3fa0e5b2798121b937fce6169d6a23e2575d4e1d /src/markdown.cpp
parent8eeaae0b06fd320745f22efe176e0f19d6c8e2a6 (diff)
downloadDoxygen-ac611be473c2d9bf65bcafb53b0577274c4ae706.zip
Doxygen-ac611be473c2d9bf65bcafb53b0577274c4ae706.tar.gz
Doxygen-ac611be473c2d9bf65bcafb53b0577274c4ae706.tar.bz2
In case of sections with the same name they are not reported.
In this patch it is checked if a section label has been used before and if so a warning is given with file name and line number (when possible) where the section label was used the first time. Note in section.h the item level was not initialized in the past in case of a copy constructor.
Diffstat (limited to 'src/markdown.cpp')
-rw-r--r--src/markdown.cpp53
1 files changed, 43 insertions, 10 deletions
diff --git a/src/markdown.cpp b/src/markdown.cpp
index 6ae95fe..9605f31 100644
--- a/src/markdown.cpp
+++ b/src/markdown.cpp
@@ -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();