From 4f28f621b67d96c3f9eb78f01009867377695558 Mon Sep 17 00:00:00 2001 From: albert-github Date: Sun, 28 Jun 2020 14:08:24 +0200 Subject: More flexible and correct detection of direction of an argument In the current version a line like: ``` uint8_t innInstances, ///< [inn]Number of CIP node instances. ``` was seen as an input parameter. Also not all combinations were checked (`[inout]` was OK but `[outin]` wasn't although `[in,out]` and `[out,in]` were working in the tokenizer. Line up the detection of the direction between the tokenizer and the method `extractDirection` Note: this problem was found when working on #7879. --- src/doctokenizer.l | 2 +- src/util.cpp | 23 +++++++++++++++++++---- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/doctokenizer.l b/src/doctokenizer.l index b1aa82f..a08fef0 100644 --- a/src/doctokenizer.l +++ b/src/doctokenizer.l @@ -378,7 +378,7 @@ SPCMD2 {CMD}[\\@<>&$#%~".+=|-] SPCMD3 {CMD}_form#[0-9]+ SPCMD4 {CMD}"::" SPCMD5 {CMD}":" -INOUT "inout"|"in"|"out"|("in"{BLANK}*","{BLANK}*"out")|("out"{BLANK}*","{BLANK}*"in") +INOUT "in"|"out"|("in"{BLANK}*","?{BLANK}*"out")|("out"{BLANK}*","?{BLANK}*"in") PARAMIO {CMD}param{BLANK}*"["{BLANK}*{INOUT}{BLANK}*"]" VARARGS "..." TEMPCHAR [a-z_A-Z0-9.,: \t\*\&\(\)\[\]] diff --git a/src/util.cpp b/src/util.cpp index 8b3f618..7b90982 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -8138,10 +8138,25 @@ QCString extractDirection(QCString &docs) int l=0; if (re.match(docs,0,&l)==0) { - int inPos = docs.find("in", 1,FALSE); - int outPos = docs.find("out",1,FALSE); - bool input = inPos!=-1 && inPos Date: Thu, 30 Jul 2020 13:48:32 +0200 Subject: Simplified extractDirection() Also fixed bug preventing direction to be stripped from the parameter documentation. --- src/memberdef.cpp | 2 +- src/util.cpp | 24 ++++-------------------- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/src/memberdef.cpp b/src/memberdef.cpp index 7d6acb5..7645a01 100644 --- a/src/memberdef.cpp +++ b/src/memberdef.cpp @@ -3761,7 +3761,7 @@ void MemberDefImpl::writeDocumentation(const MemberList *ml, { QCString docsWithoutDir = a.docs; QCString direction = extractDirection(docsWithoutDir); - paramDocs+="@param"+direction+" "+a.name+" "+a.docs; + paramDocs+="@param"+direction+" "+a.name+" "+docsWithoutDir; } } // feed the result to the documentation parser diff --git a/src/util.cpp b/src/util.cpp index c810db5..bebfbb1 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -8137,29 +8137,13 @@ bool classVisibleInIndex(const ClassDef *cd) QCString extractDirection(QCString &docs) { - QRegExp re("\\[[^\\]]+\\]"); // [...] + QRegExp re("\\[[ inout,]+\\]"); // [...] int l=0; if (re.match(docs,0,&l)==0) { - QRegExp re_in("\\[ *in *\\]"); // [in] - QRegExp re_out("\\[ *out *\\]"); // [out] - QRegExp re_inout("\\[ *in *[,]? *out *\\]"); // [in,out] - QRegExp re_outin("\\[ *out *[,]? *in *\\]"); // [out,in] - int l_in = 0; - int l_out = 0; - int l_inout = 0; - int l_outin = 0; - int inPos = re_in.match(docs,0,&l_in); - int outPos = re_out.match(docs,0,&l_out); - int inoutPos = re_inout.match(docs,0,&l_inout); - int outinPos = re_outin.match(docs,0,&l_outin); - // we only take the first occurrence into account - bool input = (inPos!=-1 && l==l_in) || - (inoutPos!=-1 && l==l_inout) || - (outinPos!=-1 && l==l_outin); - bool output = (outPos!=-1 && l==l_out) || - (inoutPos!=-1 && l==l_inout) || - (outinPos!=-1 && l==l_outin); + QCString dir=docs.left(l); + bool input = dir.find("in")!=-1; + bool output = dir.find("out")!=-1; if (input || output) // in,out attributes { docs = docs.mid(l); // strip attributes -- cgit v0.12