summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDimitri van Heesch <doxygen@gmail.com>2020-10-04 18:47:51 (GMT)
committerDimitri van Heesch <doxygen@gmail.com>2020-10-04 18:47:51 (GMT)
commit43cf803fa0c105f584da9479d0a20f704900f418 (patch)
tree1d41e0e0f53e4332c0ed8a58ba98ed0e4ae280f0 /src
parent8afc2218f92d509803c71cffa3f6ea0f41704738 (diff)
parentc46e7ae8a25ec64b91ab39bf5246aa69e729d25b (diff)
downloadDoxygen-43cf803fa0c105f584da9479d0a20f704900f418.zip
Doxygen-43cf803fa0c105f584da9479d0a20f704900f418.tar.gz
Doxygen-43cf803fa0c105f584da9479d0a20f704900f418.tar.bz2
Merge branch 'albert-github-feature/bug_md_pg_cnt'
Diffstat (limited to 'src')
-rw-r--r--src/cite.cpp2
-rw-r--r--src/commentscan.l45
-rw-r--r--src/doxygen.cpp8
-rw-r--r--src/index.cpp2
-rw-r--r--src/markdown.cpp36
-rw-r--r--src/markdown.h2
-rw-r--r--src/pagedef.cpp4
-rw-r--r--src/pagedef.h8
-rw-r--r--src/reflist.cpp2
-rw-r--r--src/util.cpp20
-rw-r--r--src/util.h4
11 files changed, 75 insertions, 58 deletions
diff --git a/src/cite.cpp b/src/cite.cpp
index 03bdb02..e02641a 100644
--- a/src/cite.cpp
+++ b/src/cite.cpp
@@ -368,7 +368,7 @@ void CitationManager::generatePage()
//printf("doc=[%s]\n",doc.data());
// 7. add it as a page
- addRelatedPage(fileName(),theTranslator->trCiteReferences(),doc,fileName(),1);
+ addRelatedPage(fileName(),theTranslator->trCiteReferences(),doc,fileName(),1,1);
// 8. for latex we just copy the bib files to the output and let
// latex do this work.
diff --git a/src/commentscan.l b/src/commentscan.l
index ce495a1..ccf71f6 100644
--- a/src/commentscan.l
+++ b/src/commentscan.l
@@ -438,6 +438,8 @@ static void handleGuard(yyscan_t yyscanner,const QCString &expr);
static yy_size_t yyread(yyscan_t yyscanner,char *buf,yy_size_t max_size);
static void addCite(yyscan_t yyscanner);
+#define unput_string(yytext,yyleng) do { for (int i=(int)yyleng-1;i>=0;i--) unput(yytext[i]); } while(0)
+
//-----------------------------------------------------------------------------
#undef YY_INPUT
@@ -872,9 +874,9 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
yyextra->briefEndsAtDot=FALSE;
}
}
-<Comment>\n { // newline
- addOutput(yyscanner,*yytext);
- yyextra->lineNr++;
+<Comment>{DOCNL} { // newline
+ addOutput(yyscanner,yytext);
+ if (*yytext == '\n') yyextra->lineNr++;
}
<Comment>. { // catch-all for anything else
addOutput(yyscanner,*yytext);
@@ -954,7 +956,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
warn(yyextra->fileName,yyextra->lineNr,
"missing argument after \\enum."
);
- unput('\n');
+ unput_string(yytext,yyleng);
//addOutput(yyscanner,'\n');
//if (*yytext=='\n') yyextra->lineNr++;
BEGIN( Comment );
@@ -977,7 +979,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
"missing argument after "
"\\namespace."
);
- unput('\n');
+ unput_string(yytext,yyleng);
//addOutput(yyscanner,'\n');
//if (*yytext=='\n') yyextra->lineNr++;
BEGIN( Comment );
@@ -1000,7 +1002,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
"missing argument after "
"\\package."
);
- unput('\n');
+ unput_string(yytext,yyleng);
//addOutput(yyscanner,'\n');
//if (*yytext=='\n') yyextra->lineNr++;
BEGIN( Comment );
@@ -1038,7 +1040,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
);
//addOutput(yyscanner,'\n');
//if (*yytext=='\n') yyextra->lineNr++;
- unput('\n');
+ unput_string(yytext,yyleng);
BEGIN( Comment );
}
<ClassDocArg1,CategoryDocArg1>. { // ignore other stuff
@@ -1047,7 +1049,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
<ClassDocArg2>{DOCNL} {
//addOutput(yyscanner,'\n');
//if (*yytext=='\n') yyextra->lineNr++;
- unput('\n');
+ unput_string(yytext,yyleng);
BEGIN( Comment );
}
<ClassDocArg2>{FILE}|"<>" { // second argument; include file
@@ -1071,7 +1073,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
}
<ClassDocArg3>{DOCNL} {
//if (*yytext=='\n') yyextra->lineNr++;
- unput('\n');
+ unput_string(yytext,yyleng);
BEGIN( Comment );
}
<ClassDocArg3>. { // ignore other stuff
@@ -1102,7 +1104,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
);
//addOutput(yyscanner,'\n');
//if (*yytext=='\n') yyextra->lineNr++;
- unput('\n');
+ unput_string(yytext,yyleng);
BEGIN( Comment );
}
<GroupDocArg1>. { // ignore other stuff
@@ -1125,7 +1127,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
"\\defgroup %s", yyextra->current->name.data()
);
}
- unput('\n');
+ unput_string(yytext,yyleng);
//if (*yytext=='\n') yyextra->lineNr++;
//addOutput(yyscanner,'\n');
BEGIN( Comment );
@@ -1150,7 +1152,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
"missing argument after "
"\\page."
);
- unput('\n');
+ unput_string(yytext,yyleng);
//if (*yytext=='\n') yyextra->lineNr++;
//addOutput(yyscanner,'\n');
BEGIN( Comment );
@@ -1158,7 +1160,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
<PageDocArg1>. { // ignore other stuff
}
<PageDocArg2>{DOCNL} { // second argument; page title
- unput('\n');
+ unput_string(yytext,yyleng);
//if (*yytext=='\n') yyextra->lineNr++;
//addOutput(yyscanner,'\n');
BEGIN( Comment );
@@ -1192,7 +1194,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
/* --------- handle arguments of the file/dir/example command ------------ */
<FileDocArg1>{DOCNL} { // no file name specified
- unput('\n');
+ unput_string(yytext,yyleng);
//if (*yytext=='\n') yyextra->lineNr++;
//addOutput(yyscanner,'\n');
BEGIN( Comment );
@@ -1290,7 +1292,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
warn(yyextra->fileName,yyextra->lineNr,
"Missing argument of '\\%s' command",yyextra->currentCmd.data()
);
- unput('\n');
+ unput_string(yytext,yyleng);
//if (*yytext=='\n') yyextra->lineNr++;
//addOutput(yyscanner,'\n');
BEGIN( Comment );
@@ -1304,7 +1306,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
<LineParam>{DOCNL} { // end of argument
//if (*yytext=='\n') yyextra->lineNr++;
//addOutput(yyscanner,'\n');
- unput('\n');
+ unput_string(yytext,yyleng);
BEGIN( Comment );
}
<LineParam>{LC} { // line continuation
@@ -1668,7 +1670,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
<NameParam>{DOCNL} { // end of argument
//if (*yytext=='\n') yyextra->lineNr++;
//addOutput(yyscanner,'\n');
- unput('\n');
+ unput_string(yytext,yyleng);
BEGIN( Comment );
}
<NameParam>{LC} { // line continuation
@@ -1706,7 +1708,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
}
//if (*yytext=='\n') yyextra->lineNr++;
//addOutput(yyscanner,'\n');
- unput('\n');
+ unput_string(yytext,yyleng);
BEGIN( Comment );
}
<InGroupParam>{LC} { // line continuation
@@ -1724,7 +1726,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
{
//if (*yytext=='\n') yyextra->lineNr++;
//addOutput(yyscanner,'\n');
- unput('\n');
+ unput_string(yytext,yyleng);
yyextra->langParser->parsePrototype(yyextra->functionProto);
BEGIN( Comment );
}
@@ -1811,7 +1813,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
);
//if (*yytext=='\n') yyextra->lineNr++;
//addOutput(yyscanner,'\n');
- unput('\n');
+ unput_string(yytext,yyleng);
BEGIN( Comment );
}
<ExtendsParam>. { // ignore other stuff
@@ -1848,7 +1850,7 @@ RCSTAG "$"{ID}":"[^\n$]+"$"
);
//if (*yytext=='\n') yyextra->lineNr++;
//addOutput(yyscanner,'\n');
- unput('\n');
+ unput_string(yytext,yyleng);
BEGIN( Comment );
}
<CiteLabel>. { // invalid character for cite label
@@ -2783,6 +2785,7 @@ static bool makeStructuralIndicator(yyscan_t yyscanner,Entry::Sections s)
yyextra->current->section = s;
yyextra->current->fileName = yyextra->fileName;
yyextra->current->startLine = yyextra->lineNr;
+ yyextra->current->docLine = yyextra->lineNr;
return FALSE;
}
}
diff --git a/src/doxygen.cpp b/src/doxygen.cpp
index ea2f68f..16dc0a6 100644
--- a/src/doxygen.cpp
+++ b/src/doxygen.cpp
@@ -347,7 +347,9 @@ static void addRelatedPage(Entry *root)
}
PageDef *pd = addRelatedPage(root->name,root->args,doc,
- root->docFile,root->docLine,
+ root->docFile,
+ root->docLine,
+ root->startLine,
root->sli,
gd,root->tagInfo(),
FALSE,
@@ -8442,6 +8444,7 @@ static void findMainPage(Entry *root)
{
if (Doxygen::mainPage==0 && root->tagInfo()==0)
{
+ //printf("mainpage: docLine=%d startLine=%d\n",root->docLine,root->startLine);
//printf("Found main page! \n======\n%s\n=======\n",root->doc.data());
QCString title=root->args.stripWhiteSpace();
//QCString indexName=Config_getBool(GENERATE_TREEVIEW)?"main":"index";
@@ -8450,6 +8453,7 @@ static void findMainPage(Entry *root)
indexName, root->brief+root->doc+root->inbodyDocs,title);
//setFileNameForSections(root->anchors,"index",Doxygen::mainPage);
Doxygen::mainPage->setBriefDescription(root->brief,root->briefFile,root->briefLine);
+ Doxygen::mainPage->setBodySegment(root->startLine,root->startLine,-1);
Doxygen::mainPage->setFileName(indexName);
Doxygen::mainPage->setLocalToc(root->localToc);
addPageToContext(Doxygen::mainPage,root);
@@ -8485,7 +8489,7 @@ static void findMainPage(Entry *root)
{
warn(root->fileName,root->startLine,
"found more than one \\mainpage comment block! (first occurrence: %s, line %d), Skipping current block!",
- Doxygen::mainPage->docFile().data(),Doxygen::mainPage->docLine());
+ Doxygen::mainPage->docFile().data(),Doxygen::mainPage->getStartBodyLine());
}
}
for (const auto &e : root->children()) findMainPage(e.get());
diff --git a/src/index.cpp b/src/index.cpp
index 12f35f2..4df2ce4 100644
--- a/src/index.cpp
+++ b/src/index.cpp
@@ -4499,7 +4499,7 @@ static void writeIndex(OutputList &ol)
{
ol.startHeaderSection();
ol.startTitleHead(0);
- ol.generateDoc(Doxygen::mainPage->docFile(),Doxygen::mainPage->docLine(),
+ ol.generateDoc(Doxygen::mainPage->docFile(),Doxygen::mainPage->getStartBodyLine(),
Doxygen::mainPage,0,Doxygen::mainPage->title(),TRUE,FALSE,
0,TRUE,FALSE,Config_getBool(MARKDOWN_SUPPORT));
headerWritten = TRUE;
diff --git a/src/markdown.cpp b/src/markdown.cpp
index e268c48..1a7a382 100644
--- a/src/markdown.cpp
+++ b/src/markdown.cpp
@@ -2491,18 +2491,20 @@ static bool isExplicitPage(const QCString &docs)
return FALSE;
}
-QCString Markdown::extractPageTitle(QCString &docs,QCString &id)
+QCString Markdown::extractPageTitle(QCString &docs,QCString &id, int &prepend)
{
TRACE(docs.data());
- int ln=0;
// first first non-empty line
+ prepend = 0;
QCString title;
- const char *data = docs.data();
int i=0;
int size=docs.size();
+ QCString docs_org(docs);
+ const char *data = docs_org.data();
+ docs = "";
while (i<size && (data[i]==' ' || data[i]=='\n'))
{
- if (data[i]=='\n') ln++;
+ if (data[i]=='\n') prepend++;
i++;
}
if (i>=size) return "";
@@ -2512,16 +2514,13 @@ QCString Markdown::extractPageTitle(QCString &docs,QCString &id)
// first line from i..end1
if (end1<size)
{
- ln++;
// second line form end1..end2
int end2=end1+1;
while (end2<size && data[end2-1]!='\n') end2++;
if (isHeaderline(data+end1,size-end1,FALSE))
{
convertStringFragment(title,data+i,end1-i-1);
- QCString lns;
- lns.fill('\n',ln);
- docs=lns+docs.mid(end2);
+ docs+="\n\n"+docs_org.mid(end2);
id = extractTitleId(title, 0);
//printf("extractPageTitle(title='%s' docs='%s' id='%s')\n",title.data(),docs.data(),id.data());
return title;
@@ -2529,10 +2528,11 @@ QCString Markdown::extractPageTitle(QCString &docs,QCString &id)
}
if (i<end1 && isAtxHeader(data+i,end1-i,title,id,FALSE)>0)
{
- docs=docs.mid(end1);
+ docs+=docs_org.mid(end1);
}
else
{
+ docs=docs_org;
id = extractTitleId(title, 0);
}
//printf("extractPageTitle(title='%s' docs='%s' id='%s')\n",title.data(),docs.data(),id.data());
@@ -2687,6 +2687,7 @@ void MarkdownOutlineParser::parseInput(const char *fileName,
ClangTUParser* /*clangParser*/)
{
std::shared_ptr<Entry> current = std::make_shared<Entry>();
+ int prepend = 0; // number of empty lines in front
current->lang = SrcLangExt_Markdown;
current->fileName = fileName;
current->docFile = fileName;
@@ -2694,7 +2695,7 @@ void MarkdownOutlineParser::parseInput(const char *fileName,
QCString docs = fileBuf;
QCString id;
Markdown markdown(fileName,1,0);
- QCString title=markdown.extractPageTitle(docs,id).stripWhiteSpace();
+ QCString title=markdown.extractPageTitle(docs,id,prepend).stripWhiteSpace();
if (id.startsWith("autotoc_md")) id = "";
int indentLevel=title.isEmpty() ? 0 : -1;
markdown.setIndentLevel(indentLevel);
@@ -2711,21 +2712,22 @@ void MarkdownOutlineParser::parseInput(const char *fileName,
QFileInfo(mdfileAsMainPage).absFilePath()) // file reference with path
)
{
- docs.prepend("@anchor " + id + "\n");
- docs.prepend("@mainpage "+title+"\n");
+ docs.prepend("@anchor " + id + "\\ilinebr ");
+ docs.prepend("@mainpage "+title+"\\ilinebr ");
}
else if (id=="mainpage" || id=="index")
{
if (title.isEmpty()) title = titleFn;
- docs.prepend("@anchor " + id + "\n");
- docs.prepend("@mainpage "+title+"\n");
+ docs.prepend("@anchor " + id + "\\ilinebr ");
+ docs.prepend("@mainpage "+title+"\\ilinebr ");
}
else
{
- if (title.isEmpty()) title = titleFn;
- if (!wasEmpty) docs.prepend("@anchor " + markdownFileNameToId(fileName) + "\n");
- docs.prepend("@page "+id+" "+title+"\n");
+ if (title.isEmpty()) {title = titleFn;prepend=0;}
+ if (!wasEmpty) docs.prepend("@anchor " + markdownFileNameToId(fileName) + "\\ilinebr ");
+ docs.prepend("@page "+id+" "+title+"\\ilinebr ");
}
+ for (int i = 0; i < prepend; i++) docs.prepend("\n");
}
int lineNr=1;
diff --git a/src/markdown.h b/src/markdown.h
index 1210967..dd4ff73 100644
--- a/src/markdown.h
+++ b/src/markdown.h
@@ -34,7 +34,7 @@ class Markdown
public:
Markdown(const char *fileName,int lineNr,int indentLevel=0);
QCString process(const QCString &input, int &startNewlines);
- QCString extractPageTitle(QCString &docs,QCString &id);
+ QCString extractPageTitle(QCString &docs,QCString &id,int &prepend);
void setIndentLevel(int level) { m_indentLevel = level; }
private:
diff --git a/src/pagedef.cpp b/src/pagedef.cpp
index 75e50ed..12a7bdc 100644
--- a/src/pagedef.cpp
+++ b/src/pagedef.cpp
@@ -230,7 +230,7 @@ void PageDefImpl::writeDocumentation(OutputList &ol)
if (si->title() != manPageName)
{
- ol.generateDoc(docFile(),docLine(),this,0,si->title(),TRUE,FALSE,
+ ol.generateDoc(docFile(),getStartBodyLine(),this,0,si->title(),TRUE,FALSE,
0,TRUE,FALSE,Config_getBool(MARKDOWN_SUPPORT));
ol.endSection(si->label(),si->type());
}
@@ -250,7 +250,7 @@ void PageDefImpl::writeDocumentation(OutputList &ol)
ol.startPageDoc(si->title());
//ol.startSection(si->label,si->title,si->type);
startTitle(ol,getOutputFileBase(),this);
- ol.generateDoc(docFile(),docLine(),this,0,si->title(),TRUE,FALSE,
+ ol.generateDoc(docFile(),getStartBodyLine(),this,0,si->title(),TRUE,FALSE,
0,TRUE,FALSE,Config_getBool(MARKDOWN_SUPPORT));
//stringToSearchIndex(getOutputFileBase(),
// theTranslator->trPage(TRUE,TRUE)+" "+si->title,
diff --git a/src/pagedef.h b/src/pagedef.h
index e4d0268..a1f08a5 100644
--- a/src/pagedef.h
+++ b/src/pagedef.h
@@ -1,12 +1,10 @@
/******************************************************************************
*
- *
- *
- * Copyright (C) 1997-2015 by Dimitri van Heesch.
+ * Copyright (C) 1997-2020 by Dimitri van Heesch.
*
* Permission to use, copy, modify, and distribute this software and its
- * documentation under the terms of the GNU General Public License is hereby
- * granted. No representations are made about the suitability of this software
+ * documentation under the terms of the GNU General Public License is hereby
+ * granted. No representations are made about the suitability of this software
* for any purpose. It is provided "as is" without express or implied warranty.
* See the GNU General Public License for more details.
*
diff --git a/src/reflist.cpp b/src/reflist.cpp
index ed26818..5840138 100644
--- a/src/reflist.cpp
+++ b/src/reflist.cpp
@@ -124,6 +124,6 @@ void RefList::generatePage()
//printf("generatePage('%s')\n",doc.data());
if (cnt>0)
{
- addRelatedPage(m_listName,m_pageTitle,doc,m_fileName,1,RefItemVector(),0,0,TRUE);
+ addRelatedPage(m_listName,m_pageTitle,doc,m_fileName,1,1,RefItemVector(),0,0,TRUE);
}
}
diff --git a/src/util.cpp b/src/util.cpp
index 869e20b..78de1a8 100644
--- a/src/util.cpp
+++ b/src/util.cpp
@@ -6004,7 +6004,9 @@ found:
PageDef *addRelatedPage(const char *name,const QCString &ptitle,
const QCString &doc,
- const char *fileName,int startLine,
+ const char *fileName,
+ int docLine,
+ int startLine,
const RefItemVector &sli,
GroupDef *gd,
const TagInfo *tagInfo,
@@ -6017,9 +6019,9 @@ PageDef *addRelatedPage(const char *name,const QCString &ptitle,
if ((pd=Doxygen::pageSDict->find(name)) && !tagInfo)
{
if (!xref) warn(fileName,startLine,"multiple use of page label '%s', (other occurrence: %s, line: %d)",
- name,pd->docFile().data(),pd->docLine());
+ name,pd->docFile().data(),pd->getStartBodyLine());
// append documentation block to the page.
- pd->setDocumentation(doc,fileName,startLine);
+ pd->setDocumentation(doc,fileName,docLine);
//printf("Adding page docs '%s' pi=%p name=%s\n",doc.data(),pd,name);
// append (x)refitems to the page.
pd->setRefItems(sli);
@@ -6033,7 +6035,8 @@ PageDef *addRelatedPage(const char *name,const QCString &ptitle,
baseName=baseName.left(baseName.length()-Doxygen::htmlFileExtension.length());
QCString title=ptitle.stripWhiteSpace();
- pd=createPageDef(fileName,startLine,baseName,doc,title);
+ pd=createPageDef(fileName,docLine,baseName,doc,title);
+ pd->setBodySegment(startLine,startLine,-1);
pd->setRefItems(sli);
pd->setLanguage(lang);
@@ -6055,24 +6058,29 @@ PageDef *addRelatedPage(const char *name,const QCString &ptitle,
// a page name is a label as well!
QCString file;
+ QCString orgFile;
+ int line = -1;
if (gd)
{
file=gd->getOutputFileBase();
+ orgFile=gd->getOutputFileBase();
}
else
{
file=pd->getOutputFileBase();
+ orgFile=pd->docFile();
+ line = pd->getStartBodyLine();
}
const SectionInfo *si = SectionManager::instance().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());
+ warn(orgFile,line,"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());
+ warn(orgFile,line,"multiple use of section label '%s', (first occurrence: %s)",pd->name().data(),si->fileName().data());
}
}
else
diff --git a/src/util.h b/src/util.h
index 708e7bf..6637554 100644
--- a/src/util.h
+++ b/src/util.h
@@ -337,7 +337,9 @@ void addRefItem(const RefItemVector &sli,
PageDef *addRelatedPage(const char *name,
const QCString &ptitle,
const QCString &doc,
- const char *fileName,int startLine,
+ const char *fileName,
+ int docLine,
+ int startLine,
const RefItemVector &sli = RefItemVector(),
GroupDef *gd=0,
const TagInfo *tagInfo=0,