Skip to content

Commit

Permalink
Missing anchors to source code in RTF
Browse files Browse the repository at this point in the history
When running the doxygen test 25, like `make tests TEST_FLAGS="--rtf  --id=25 --keep --noredir --cfg RTF_HYPERLINKS=YES"`) and clicking on the `example_test.cpp` a jump occurs to the top of the document and not to the (available) source code.
- corrected generation of anchors (not the name was important for the anchor but the fileName.
- adding test possibility for detecting missing anchors in test procedure

We should also check whether or not a bookmark is double defined, but test 57 (inline namespace) gives a, small, problem here (in all formats!). This has to be handled in a separate issue.
  • Loading branch information
albert-github committed Jun 17, 2021
1 parent 6fc45ba commit 60bb70b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
12 changes: 2 additions & 10 deletions src/rtfgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1478,17 +1478,9 @@ void RTFGenerator::endTitleHead(const QCString &fileName,const QCString &name)

// make an index entry
addIndexItem(name,QCString());

//if (name)
//{
// writeAnchor(0,name);
//}
//
//if (Config_getBool(RTF_HYPERLINKS) && fileName)
//{
writeAnchor(fileName,QCString());
//}
}

if (!fileName.isEmpty()) writeAnchor(fileName,QCString());
}

void RTFGenerator::startTitle()
Expand Down
37 changes: 35 additions & 2 deletions testing/runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import shlex

config_reg = re.compile('.*\/\/\s*(?P<name>\S+):\s*(?P<value>.*)$')
bkmk_reg = re.compile(r'.*bkmkstart\s+([A-Z][A-Z][A-Z][A-Z][A-Z][A-Z][A-Z][A-Z][A-Z][A-Z]).*')
hyper_reg = re.compile(r'.*HYPERLINK\s+[\\l]*\s+"([A-Z][A-Z][A-Z][A-Z][A-Z][A-Z][A-Z][A-Z][A-Z][A-Z])".*')


def xopen(fname, mode='r', encoding='utf-8'):
Expand Down Expand Up @@ -149,6 +151,7 @@ def prepare_test(self):
print('GENERATE_XML=NO', file=f)
if (self.args.rtf):
print('GENERATE_RTF=YES', file=f)
print('RTF_HYPERLINKS=YES', file=f)
print('RTF_OUTPUT=%s/rtf' % self.test_out, file=f)
else:
print('GENERATE_RTF=NO', file=f)
Expand Down Expand Up @@ -194,6 +197,33 @@ def prepare_test(self):
print('Error: failed to run %s on %s/Doxyfile' % (self.args.doxygen,self.test_out))
sys.exit(1)


def check_link_rtf_file(self,fil):
bkmk_res = []
hyper_res = []
with xopen(fil,'r') as f:
for line in f.readlines():
if ("bkmkstart" in line) or ("HYPERLINK" in line):
msg = line.split('}')
for m in msg:
if bkmk_reg.match(m):
m1 = re.sub(bkmk_reg, '\\1', m)
bkmk_res.append(m1)
elif hyper_reg.match(m):
m1 = re.sub(hyper_reg, '\\1', m)
hyper_res.append(m1)
# Has been commented out as in the test 57, inline namespace, there is stil a small problem.
#if sorted(bkmk_res) != sorted(set(bkmk_res)):
# return (False, "RTF: one (or more) bookmark(s) has(have) been defined multiple times")
hyper_res = sorted(set(hyper_res))
for h in hyper_res:
if h not in bkmk_res:
#print(bkmk_res)
#print(hyper_res)
return (False, "RTF: Not all used hyperlinks have been defined")
return (True,"")


# update the reference data for this test
def update_test(self,testmgr):
print('Updating reference for %s' % self.test_name)
Expand Down Expand Up @@ -368,8 +398,11 @@ def perform_test(self,testmgr):
shutil.rmtree(xml_output,ignore_errors=True)

if (self.args.rtf):
# no tests defined yet
pass
(res, msg1) = self.check_link_rtf_file("%s/rtf/refman.rtf" % self.test_out)
if not res:
#msg += ("RTF: Not all used hyperlinks have been defined",)
msg += (msg1,)
failed_rtf=True

if (self.args.docbook):
docbook_output='%s/docbook' % self.test_out
Expand Down

0 comments on commit 60bb70b

Please sign in to comment.