diff options
author | albert-github <albert.tests@gmail.com> | 2020-09-24 13:20:13 (GMT) |
---|---|---|
committer | albert-github <albert.tests@gmail.com> | 2020-09-24 13:20:13 (GMT) |
commit | 17390b669f7a1017fa937410880da38a540dfa35 (patch) | |
tree | d6f3e41e51c2c6552c979bb460569bd88382877d /src/markdown.cpp | |
parent | 55e15c86717f38c9b510e4287cb0b4f165b8cb10 (diff) | |
download | Doxygen-17390b669f7a1017fa937410880da38a540dfa35.zip Doxygen-17390b669f7a1017fa937410880da38a540dfa35.tar.gz Doxygen-17390b669f7a1017fa937410880da38a540dfa35.tar.bz2 |
Miscounting of lines in respect to page command
All examples together are a bit big so they are all in the attached file together with the warnings before and after this patch.
When looking at the output we see that a number of lines are off by 1 ore more due to the insertion of extra lines in the code or due to the fact that there is a reference to the start of the documentation of the page and not the line of the page command.
- commentscan.l
in case of a rule contaiinge {DOCNL} this can be `=n` or `\ilinebr` in the later case this should not be replaced by `\n` as this results in an increase of the line count later on.
in case of a page like command also register the line of the command as "topline".
- entry.h, entry.cpp
storage space for the "topline" registering the line of the page like commands.
- doxygen.cpp
setting and using the "topline"
- markdown.cpp, markdown.h
don't add a `\n` as this increases the line count but use the `\ilinebr`
to get correct warnings see to it that when having empty lines at the top of the page and a page is added that the empty lines appear after the page command.
- index.cpp
using the "topline" instead of the "docLine" to get the correct warning
- pagedef.cpp, pagedef.h
set and retrieve the "topline" for page like commands.
- util.cpp, util.h
setting and using the "topline"
in `addRelatedPage` use the known file name and line for the warning regarding the section label
- cite.cpp, context.cpp, reflist.cpp
changed to have good function calls.
Diffstat (limited to 'src/markdown.cpp')
-rw-r--r-- | src/markdown.cpp | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/src/markdown.cpp b/src/markdown.cpp index 2e6ab3e..b3ee3ca 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; |