Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide inline namespace in html output #10070

Open
wants to merge 18 commits into
base: master
Choose a base branch
from

Conversation

zchrissirhcz
Copy link
Contributor

@zchrissirhcz zchrissirhcz commented May 22, 2023

Description

This PR try hide inline namespaces in html output, for the reason:

  • client code use API with inline namespace unspecified, e.g. use class foo::Image, instead of the tedious foo::_v1::Image
  • library authors use inline namespace for API/ABI version switching, such as foo::_v1::Image for version 1.x.y, use foo::_v2::Image for version 2.x.y.
  • Hence, I suppose there is only one of { foo::Image, foo::_v1::Image, foo::_v2::Image } in the library's code.

This PR is implemented by:

  • Add a config option: HIDE_INLINE_NAMESPACES which defaults to YES defaults to NO for compatibility, set to YES to have effect on html output
  • C++ code modified, to work along with HIDE_INLINE_NAMESPACES option.

e.g. for classes defined inside an inline namespace, show the class, but hide its direct outer scope(i.e. the inline namespace).

Visualize output html difference

doxyge_hide_inline_namespaces_effect

The config file Doxyfile is:

PROJECT_NAME = "MyProject"
INPUT = D:/dbg/doxygen_inline_namespace/src
EXTRACT_ALL = YES
HTML_TIMESTAMP = YES
RECURSIVE = YES
STRIP_FROM_PATH = ../
HTML_OUTPUT=D:/dbg/doxygen_inline_namespace/build/vs2022-x64/html
GENERATE_TREEVIEW = False
HIDE_INLINE_NAMESPACES = NO

The C++ header files that html document generated from, is with contents:

// hello.h
class Size
{
public:
  int width;
  int height;
};

class Point
{
public:
  float x;
  float y;
};

//namespace {
  namespace foo {

    /// @brief the official API
    struct Image
    {

    };

    inline namespace _v1 {
      
      /// @brief for compatability
      struct Image { };

      struct Tensor { };

      struct Bar
      {

      };

      namespace Yoho {
        struct Yahoo {};
      }
    }

    inline namespace _v2 {

      struct Music
      {

      };

    }

  }

  // class What
  // {
  //   int a;
  // };
//}

namespace rock {
  /// @brief sss
  struct Entity
  {};
}

References

Related issues and repos:

PR status

  • The previously posted picture did not effectively convey the purpose of this PR;
  • Need to add unit tests;
  • There may be an issue where namespaces appear to be the same, but actually correspond to different inline namespaces.

@zchrissirhcz
Copy link
Contributor Author

This PR currently fails for unittest case 057. I locally run unittest and don't have idea how to fix the unittest.

Run 057 unittest

I create run_tests.cmake with contents:

set(ENV{CTEST_OUTPUT_ON_FAILURE} "ON")

execute_process(
  COMMAND
    cmake -E env TEST_FLAGS="--xml --xmlxsd --xhtml --qhp --docbook --rtf --id 57"
    cmake --build build --target tests
  RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
  message(FATAL_ERROR "Running tests failed!")
endif()

Run it with:

cmake -P run_tests.cmake

Set HIDE_INLINE_NAMESPACES not working

I manually modified testing/Doxyfile, add one line:

HIDE_INLINE_NAMESPACES = NO

It seems xmllint failed, error message is:

(base) zz@localhost% cmake -P run_tests.cmake
[ 72%] Built target doxymain
[ 73%] Built target md5
[ 74%] Built target lodepng
[ 83%] Built target mscgen
[ 86%] Built target spdlog
[ 86%] Checking the doxygen version for changes...
[ 86%] Built target check_doxygen_version
[ 86%] Checking the git repository for changes...
[ 86%] Built target check_git_repository
[ 87%] Built target doxygen_version
[ 89%] Built target xml
[ 89%] Built target generate_configvalues_header
[ 92%] Built target vhdlparser
[ 98%] Built target doxycfg
[100%] Built target doxygen
[100%] Running doxygen tests...
1..1
not ok - [057_inlinenamespace.cpp]: test inline namespaces
-------------------------------------
Non-existing file /home/zz/work/github/doxygen/build/testing/test_output_057/out/namespacelibrary.xml after 'check:' statement
-------------------------------------
test_output_057/out/Doxyfile.xml:2: element doxyfile: Schemas validity error : Element 'doxyfile': No matching global declaration available for the validation root.test_output_057/out/Doxyfile.xml fails to validate
-------------------------------------
warning: No files to be processed, please check your settings, in particular INPUT, FILE_PATTERNS, and RECURSIVE

-------------------------------------
1 out of 1 tests failed
gmake[3]: *** [testing/CMakeFiles/tests.dir/build.make:71:testing/CMakeFiles/tests] 错误 1
gmake[2]: *** [CMakeFiles/Makefile2:675:testing/CMakeFiles/tests.dir/all] 错误 2
gmake[1]: *** [CMakeFiles/Makefile2:682:testing/CMakeFiles/tests.dir/rule] 错误 2
gmake: *** [Makefile:382:tests] 错误 2
CMake Error at run_tests.cmake:10 (message):
  Running tests failed!

@albert-github
Copy link
Collaborator

When you want to run locally the tests you can do e.g.:
for help

nmake tests TEST_FLAGS="--help"

for running just one test, like you did in the run_tests.cmake:

nmake tests TEST_FLAGS="--xml --xmlxsd --xhtml --qhp --docbook --rtf --id 57"

Note such a file should never entry the repository (and you created it, as far as I can see, only locally).

Furthermore it looks like there might be 2 problems:

  • the default setting of the HIDE_INLINE_NAMESPACES for compatibility this should probably be YES as now the inline namespaces are not hidden either.

  • warning: No files to be processed, please check your settings, in particular INPUT, FILE_PATTERNS, and RECURSIVE

    The first problem is that the warning signals that there are for the 057 test no files to be processed by doxygen, but the file 057_inlinenamespace.cpp is there to be processes so this warning is strange and should be investigated.

In the latest run I see at first glance 2 problems:

  • inconsistent xml tags, looks like in some cases not all end tags are provided / a start tag is created but no content is present will be present and there is no end tag created.
  • the difference (lines 7-12), not a real problem as expected and this can be adjusted by means of the test flag --updateref, though these changes have to be validated properly on their validity i.e. are the expected and correct.

@zchrissirhcz
Copy link
Contributor Author

the default setting of the HIDE_INLINE_NAMESPACES for compatibility this should probably be YES as now the inline namespaces are not hidden either.

Fixed now, let it default to NO.

@zchrissirhcz
Copy link
Contributor Author

When you want to run locally the tests you can do e.g.:
for help

nmake tests TEST_FLAGS="--help"

Actually nmake is not in my PATH and I prefer calling ctest, I guess ctest just wrap nmake. I can just it as:

cd d:/github/doxygen
cd build
ctest TEST_FLAGS="--help"

@zchrissirhcz
Copy link
Contributor Author

It seems xmllint is not installed on Windows, in .github/workflows/build_cmake.yml. I only find xmllint installed on Linux and MacOSX.

    - name: Install xmllint (Linux)
      run: |
         sudo apt-get update
         sudo apt-get install libxml2-utils
      if: startsWith(matrix.config.os,'ubuntu-')

    - name: Install xmllint (MacOS)
      run: |
         brew update
         brew install libxml2
      if: matrix.config.os == 'macos-latest'

@albert-github
Copy link
Collaborator

I'm not sure through which mechanism it is installed on GitHub Actions, but as the test are run on the Windows builds as well it must be present.
It might be present through the "Install libiconv (Windows)" installation.
See also https://stackoverflow.com/questions/19546854/installing-xmllint (for some ideas)

(Locally I run the version I obtain through Cygwin so I don't have problems)

@zchrissirhcz
Copy link
Contributor Author

I'm not sure through which mechanism it is installed on GitHub Actions, but as the test are run on the Windows builds as well it must be present. It might be present through the "Install libiconv (Windows)" installation. See also https://stackoverflow.com/questions/19546854/installing-xmllint (for some ideas)

(Locally I run the version I obtain through Cygwin so I don't have problems)

I think the github action Windows image preinstalled libxml.

Tested with an simple github action pipeline file, without manually install any thing, and printing xmllib version by xmllint --version shows

xmllint --version
  shell: C:\Program Files\Git\bin\bash.EXE --noprofile --norc -e -o pipefail {0}
C:\Strawberry\c\bin\xmllint.exe: using libxml version 20909
   compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 FTP HTTP DTDValid HTML Legacy C1[4](https://github.com/zchrissirhcz/actions/actions/runs/5173952918/jobs/9319734180#step:3:5)N Catalog XPath XPointer XInclude Iconv ISO88[5](https://github.com/zchrissirhcz/actions/actions/runs/5173952918/jobs/9319734180#step:3:6)9X Unicode Regexps Automata Expr Schemas Schematron Modules Debug Zlib Lzma

Full github action output:
https://github.com/zchrissirhcz/actions/actions/runs/5173952918/jobs/9319734180

Corresponding workflow file:
https://github.com/zchrissirhcz/actions/blob/main/.github/workflows/doxygen.yml

@rod7760
Copy link

rod7760 commented Mar 5, 2024

What is the status on this? I would love this feature.

@zchrissirhcz
Copy link
Contributor Author

@rod7760 Hi, you may use my branch or pick my commits to the official repo. The PR was stuck due to I don't how to fix some unittests and been busy other stuffs. Once I have time I'll try fix it. If interested, you may also help verify and fix unittest.

@rod7760
Copy link

rod7760 commented Mar 8, 2024

I'll take a look. Thanks!

@zchrissirhcz
Copy link
Contributor Author

zchrissirhcz commented Mar 11, 2024

Rebased, force-pushed, and re-run unittests on Linux, I find that both my branch (this PR, with force pushed commit) has same error as the upstream's master branch.

Environment

(base) zz@localhost:~/github/doxygen$ uname -r
5.15.146.1-microsoft-standard-WSL2
(base) zz@localhost:~/github/doxygen$ gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

The upstream master branch, local unittest

It use directory doxygen_official.

(base) zz@localhost:~/github/doxygen_official/build$ git log
commit 181b501cebab118c09c42ddbbd847899dde76735 (HEAD -> master, origin/master, origin/HEAD)
Author: Dimitri van Heesch <doxygen@gmail.com>
Date:   Sun Mar 10 22:22:35 2024 +0100

    Fix potential crash processing VHDL code with multithreading enabled
(base) zz@localhost:~/github/doxygen_official/build$ ctest . --rerun-failed --output-on-failure
Test project /home/zz/github/doxygen_official/build
    Start 12: 012_cite
1/1 Test #12: 012_cite .........................***Failed    0.11 sec
1..1
not ok - [012_cite.dox]: test the \cite command
-------------------------------------
Difference between generated output and reference:
--- /home/zz/github/doxygen_official/build/testing/test_output_012/indexpage.xml        2024-03-11 10:06:57.387841381 +0800
+++ /home/zz/github/doxygen_official/testing/012/indexpage.xml  2024-03-11 10:03:37.427510097 +0800
@@ -6,8 +6,8 @@
     <briefdescription>
     </briefdescription>
     <detaileddescription>
-      <para>See knuth79 for more info.</para>
-      <para>Other references with cross references see Be09 and BertholdHeinzVigerske2009 for more info. </para>
+      <para>See <ref refid="citelist_1CITEREF_knuth79" kindref="member">[3]</ref> for more info.</para>
+      <para>Other references with cross references see <ref refid="citelist_1CITEREF_Be09" kindref="member">[1]</ref> and <ref refid="citelist_1CITEREF_BertholdHeinzVigerske2009" kindref="member">[2]</ref> for more info. </para>
     </detaileddescription>
     <location file="012_cite.dox"/>
   </compounddef>

-------------------------------------
error: Problems running bibtex. Verify that the command 'perl --version' works from the command line. Exit code: 2
/home/zz/github/doxygen_official/testing/012_cite.dox:6: warning: \cite command to 'knuth79' does not have an associated number
/home/zz/github/doxygen_official/testing/012_cite.dox:8: warning: \cite command to 'Be09' does not have an associated number
/home/zz/github/doxygen_official/testing/012_cite.dox:8: warning: \cite command to 'BertholdHeinzVigerske2009' does not have an associated number

-------------------------------------
1 out of 1 tests failed


0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.11 sec

The following tests FAILED:
         12 - 012_cite (Failed)
Errors while running CTest

The output of perl --version is:

(base) zz@localhost:~/github/doxygen_official$ perl --version

This is perl 5, version 34, subversion 0 (v5.34.0) built for x86_64-linux-gnu-thread-multi
(with 60 registered patches, see perl -V for more detail)

Copyright 1987-2021, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

My PR's branch, run unitest locally

It use directory doxygen.

(base) zz@localhost:~/github/doxygen/build$ git log 
commit 91856325bbb19f7d55d9c19254e25749c586b82c (HEAD -> hide_inline_namespace, origin/hide_inline_namespace)
Author: Zhuo Zhang <imzhuo@foxmail.com>
Date:   Mon Mar 11 09:54:09 2024 +0800

    [style] Adjust code style
(base) zz@localhost:~/github/doxygen/build$ ctest . --rerun-failed --output-on-failure
Test project /home/zz/github/doxygen/build
    Start 12: 012_cite
1/1 Test #12: 012_cite .........................***Failed    0.08 sec
1..1
not ok - [012_cite.dox]: test the \cite command
-------------------------------------
Difference between generated output and reference:
--- /home/zz/github/doxygen/build/testing/test_output_012/indexpage.xml 2024-03-11 10:14:13.388483927 +0800
+++ /home/zz/github/doxygen/testing/012/indexpage.xml   2024-03-11 09:41:53.334425764 +0800
@@ -6,8 +6,8 @@
     <briefdescription>
     </briefdescription>
     <detaileddescription>
-      <para>See knuth79 for more info.</para>
-      <para>Other references with cross references see Be09 and BertholdHeinzVigerske2009 for more info. </para>
+      <para>See <ref refid="citelist_1CITEREF_knuth79" kindref="member">[3]</ref> for more info.</para>
+      <para>Other references with cross references see <ref refid="citelist_1CITEREF_Be09" kindref="member">[1]</ref> and <ref refid="citelist_1CITEREF_BertholdHeinzVigerske2009" kindref="member">[2]</ref> for more info. </para>
     </detaileddescription>
     <location file="012_cite.dox"/>
   </compounddef>

-------------------------------------
error: Problems running bibtex. Verify that the command 'perl --version' works from the command line. Exit code: 2
/home/zz/github/doxygen/testing/012_cite.dox:6: warning: \cite command to 'knuth79' does not have an associated number
/home/zz/github/doxygen/testing/012_cite.dox:8: warning: \cite command to 'Be09' does not have an associated number
/home/zz/github/doxygen/testing/012_cite.dox:8: warning: \cite command to 'BertholdHeinzVigerske2009' does not have an associated number

-------------------------------------
1 out of 1 tests failed


0% tests passed, 1 tests failed out of 1

Total Test time (real) =   0.08 sec

The following tests FAILED:
         12 - 012_cite (Failed)
Errors while running CTest

@zchrissirhcz zchrissirhcz marked this pull request as ready for review March 11, 2024 02:32
@zchrissirhcz
Copy link
Contributor Author

zchrissirhcz commented Mar 11, 2024

Unittest

I would like to add a new test, "102_a.cpp". I have no idea how to pass customized option HIDE_INLINE_NAMESPACES=YES in the unittests.

What's more, the upstream's master branch run unittests failed on my local machine (ubuntu 22.04), hence this PR's unittest is getting stuck.

branch build env local unittest CI unittest
upstream/master ubuntu 20.04 Fail(12,22,28) Pass
ubuntu 22.04 Fail(12,22,28) -
zchrissirhcz/hide_inline_namespace ubuntu 22.04 Fail Fail

How I ran unittest locally

Add test.cmake with contents: (taken from .github/workflows/build_cmake.yml)

set(ENV{CTEST_OUTPUT_ON_FAILURE} "ON")

execute_process(
  COMMAND
    cmake -E env TEST_FLAGS="--xml --xmlxsd --xhtml --qhp --docbook --rtf"
    cmake --build build --target test
  RESULT_VARIABLE result
)
if (NOT result EQUAL 0)
  message(FATAL_ERROR "Running tests failed!")
endif()

Build and run with:

#!/bin/bash

cmake \
      -S . \
      -B build-docker2 \
      -G Ninja \
      -Dbuild_doc=YES \
      -Dbuild_wizard=NO \
      -Dbuild_search=YES -Dbuild_app=YES -Dbuild_parse=YES -Dbuild_xmlparser=YES

And get result:

...
 98/101 Test  #98: 098_abstract_type ............................   Passed    0.12 sec
        Start  99: 099_a
 99/101 Test  #99: 099_a ........................................   Passed    0.11 sec
        Start 100: 100_a
100/101 Test #100: 100_a ........................................   Passed    0.17 sec
        Start 101: 101_static_assert
101/101 Test #101: 101_static_assert ............................   Passed    0.11 sec

97% tests passed, 3 tests failed out of 101

Total Test time (real) =  10.96 sec

The following tests FAILED:
         12 - 012_cite (Failed)
         22 - 022_dot (Failed)
         28 - 028_formula (Failed)
Errors while running CTest
FAILED: CMakeFiles/test.util 
cd /home/zz/github/doxygen_official/build && /home/zz/soft/cmake/3.28.1/bin/ctest --force-new-ctest-process
ninja: build stopped: subcommand failed.
CMake Error at test.cmake:10 (message):
  Running tests failed!

Failure case investigation

test case description
022_dot solution: change python command as python3 instead of python2, apt install python-is-python3

Also tried align python version to gitlab CI's, i.e. 3.11.8, but failure cases unchanged.

@albert-github
Copy link
Collaborator

Regarding comment #10070 (comment)

Rebased, force-pushed, and re-run unittests on Linux, I find that both my branch (this PR, with force pushed commit) has same error as the upstream's master branch.

I assume this is about the message

/home/runner/work/doxygen/doxygen/src/commentcnv.l:1865: error: include file commentcnv.l.h not found, perhaps you forgot to add its directory to INCLUDE_PATH?

for generating the internal documentation (a proposed pull request #10725 already exists) and about problems regarding the Mac (just ignore for the time being).

Regarding the problems with the 012_cite test I assume that you haven't installed LaTeX as this is needed here.

@albert-github
Copy link
Collaborator

Regarding the new test #10070 (comment)
I have no idea how to pass customized option HIDE_INLINE_NAMESPACES=YES in the unittests.
In the file 102_a.cpp
in the first comment lines you have to add:

// config: HIDE_INLINE_NAMESPACES = YES

(see e.g. 085_tooltip.cpp)

Regarding the python problem, the tests run the python command and this can either be python2 or python3 and it is the responsibility of the system / user to have a proper python version linked to the python command (on *nix this is typically done ly mean of a symbolic link) and this gives the most flexibility.

@zchrissirhcz
Copy link
Contributor Author

Regarding comment #10070 (comment)

Rebased, force-pushed, and re-run unittests on Linux, I find that both my branch (this PR, with force pushed commit) has same error as the upstream's master branch.

I assume this is about the message

/home/runner/work/doxygen/doxygen/src/commentcnv.l:1865: error: include file commentcnv.l.h not found, perhaps you forgot to add its directory to INCLUDE_PATH?

for generating the internal documentation (a proposed pull request #10725 already exists) and about problems regarding the Mac (just ignore for the time being).

Regarding the problems with the 012_cite test I assume that you haven't installed LaTeX as this is needed here.

Thanks, I now installed LaTeX and 001~101 tests all passed.

@zchrissirhcz
Copy link
Contributor Author

Regarding the new test #10070 (comment) I have no idea how to pass customized option HIDE_INLINE_NAMESPACES=YES in the unittests. In the file 102_a.cpp in the first comment lines you have to add:

// config: HIDE_INLINE_NAMESPACES = YES

(see e.g. 085_tooltip.cpp)

Regarding the python problem, the tests run the python command and this can either be python2 or python3 and it is the responsibility of the system / user to have a proper python version linked to the python command (on *nix this is typically done ly mean of a symbolic link) and this gives the most flexibility.

Thanks for pointing out the // config: setting. Now I pushed the updated unittest, and locally run failed with error message like: (I'm not sure what // check: 102__hide__inline__namespace_8cpp.xml means, and just copied content of generated build/testing/test_output_102/102__hide__inline__namespace_8cpp.xml as testing/102/102__hide__inline__namespace_8cpp.xml):

test_output_102/docbook/namespacefoo_1_1v1.xml:17: parser error : Opening and ending tag mismatch: para line 17 and listitem
            <listitem><para></listitem>
                                       ^
test_output_102/docbook/namespacefoo_1_1v1.xml:18: parser error : Opening and ending tag mismatch: listitem line 17 and itemizedlist
        </itemizedlist>
                       ^

Full details :

# build
cd ~/github/doxygen/
cmake --build build

# run all tests
cmake -P ./test.cmake

# run the new added test: 102_hide_inline_namespace.cpp
cd build/testing
python ../../testing/runtests.py --xml --xmlxsd --xhtml --qhp --docbook --rtf --id 102 --doxygen ../bin/doxygen --inputdir ../../testing --outputdir .
1..1
not ok - [102_hide_inline_namespace.cpp]: test collapse of inline namespace
-------------------------------------
Difference between generated output and reference:
--- ./test_output_102/102__hide__inline__namespace_8cpp.xml     2024-03-11 19:33:14.083592186 +0800
+++ ../../testing/102/102__hide__inline__namespace_8cpp.xml     2024-03-11 19:29:50.892645947 +0800
@@ -5,12 +5,12 @@
     <innerclass refid="structfoo_1_1v1_1_1_size" prot="public">foo</innerclass>
     <innerclass refid="structfoo_1_1v1_1_1cv_1_1_image" prot="public">foo::v1::cv::Image</innerclass>
     <innerclass refid="structfoo_1_1v1_1_1nn_1_1_tensor" prot="public">foo::v1::nn::Tensor</innerclass>
-    <innerclass refid="structfoo_1_1v1_1_1nn_1_1v2_1_1_conv_param" prot="public">foo</innerclass>
+    <innerclass refid="structfoo_1_1v1_1_1nn_1_1v1_1_1_conv_param" prot="public">foo</innerclass>
     <innernamespace refid="namespacefoo">foo</innernamespace>
     <innernamespace refid="namespacefoo_1_1v1" inline="yes">foo::v1</innernamespace>
     <innernamespace refid="namespacefoo_1_1v1_1_1cv">foo</innernamespace>
     <innernamespace refid="namespacefoo_1_1v1_1_1nn">foo</innernamespace>
-    <innernamespace refid="namespacefoo_1_1v1_1_1nn_1_1v2" inline="yes">foo::v1::nn::v2</innernamespace>
+    <innernamespace refid="namespacefoo_1_1v1_1_1nn_1_1v1" inline="yes">foo::v1::nn::v1</innernamespace>
     <briefdescription>
     </briefdescription>
     <detaileddescription>

-------------------------------------
test_output_102/docbook/namespacefoo_1_1v1.xml:17: parser error : Opening and ending tag mismatch: para line 17 and listitem
            <listitem><para></listitem>
                                       ^
test_output_102/docbook/namespacefoo_1_1v1.xml:18: parser error : Opening and ending tag mismatch: listitem line 17 and itemizedlist
        </itemizedlist>
                       ^
test_output_102/docbook/namespacefoo_1_1v1.xml:19: parser error : Opening and ending tag mismatch: itemizedlist line 16 and simplesect
</simplesect>
             ^
test_output_102/docbook/namespacefoo_1_1v1.xml:20: parser error : Opening and ending tag mismatch: simplesect line 14 and section
</section>
          ^
test_output_102/docbook/namespacefoo_1_1v1.xml:21: parser error : Premature end of data in tag section line 2
^
test_output_102/docbook/102__hide__inline__namespace_8cpp.xml:8: parser error : Opening and ending tag mismatch: para line 8 and listitem
            <listitem><para></listitem>
                                       ^
test_output_102/docbook/102__hide__inline__namespace_8cpp.xml:13: parser error : Opening and ending tag mismatch: para line 13 and listitem
            <listitem><para></listitem>
                                       ^
test_output_102/docbook/102__hide__inline__namespace_8cpp.xml:14: parser error : Opening and ending tag mismatch: listitem line 13 and itemizedlist
        </itemizedlist>
                       ^
test_output_102/docbook/102__hide__inline__namespace_8cpp.xml:15: parser error : Opening and ending tag mismatch: listitem line 8 and simplesect
</simplesect>
             ^
test_output_102/docbook/102__hide__inline__namespace_8cpp.xml:27: parser error : Opening and ending tag mismatch: itemizedlist line 7 and section
</section>
          ^
test_output_102/docbook/102__hide__inline__namespace_8cpp.xml:28: parser error : Premature end of data in tag simplesect line 5
^
test_output_102/docbook/namespacefoo_1_1v1_1_1nn_1_1v2.xml:8: parser error : Opening and ending tag mismatch: para line 8 and listitem
            <listitem><para></listitem>
                                       ^
test_output_102/docbook/namespacefoo_1_1v1_1_1nn_1_1v2.xml:9: parser error : Opening and ending tag mismatch: listitem line 8 and itemizedlist
        </itemizedlist>
                       ^
test_output_102/docbook/namespacefoo_1_1v1_1_1nn_1_1v2.xml:10: parser error : Opening and ending tag mismatch: itemizedlist line 7 and simplesect
</simplesect>
             ^
test_output_102/docbook/namespacefoo_1_1v1_1_1nn_1_1v2.xml:11: parser error : Opening and ending tag mismatch: simplesect line 5 and section
</section>
          ^
test_output_102/docbook/namespacefoo_1_1v1_1_1nn_1_1v2.xml:12: parser error : Premature end of data in tag section line 2
^
test_output_102/docbook/namespacefoo.xml:17: parser error : Opening and ending tag mismatch: para line 17 and listitem
            <listitem><para></listitem>
                                       ^
test_output_102/docbook/namespacefoo.xml:18: parser error : Opening and ending tag mismatch: listitem line 17 and itemizedlist
        </itemizedlist>
                       ^
test_output_102/docbook/namespacefoo.xml:19: parser error : Opening and ending tag mismatch: itemizedlist line 16 and simplesect
</simplesect>
             ^
test_output_102/docbook/namespacefoo.xml:20: parser error : Opening and ending tag mismatch: simplesect line 14 and section
</section>
          ^
test_output_102/docbook/namespacefoo.xml:21: parser error : Premature end of data in tag section line 2
^
test_output_102/docbook/namespacefoo_1_1v1_1_1nn.xml:13: parser error : Opening and ending tag mismatch: para line 13 and listitem
            <listitem><para></listitem>
                                       ^
test_output_102/docbook/namespacefoo_1_1v1_1_1nn.xml:16: parser error : Opening and ending tag mismatch: listitem line 13 and itemizedlist
        </itemizedlist>
                       ^
test_output_102/docbook/namespacefoo_1_1v1_1_1nn.xml:17: parser error : Opening and ending tag mismatch: itemizedlist line 12 and simplesect
</simplesect>
             ^
test_output_102/docbook/namespacefoo_1_1v1_1_1nn.xml:18: parser error : Opening and ending tag mismatch: simplesect line 10 and section
</section>
          ^
test_output_102/docbook/namespacefoo_1_1v1_1_1nn.xml:19: parser error : Premature end of data in tag section line 2
^

-------------------------------------
test_output_102/html/namespacefoo.xhtml:103: parser error : Opening and ending tag mismatch: td line 103 and table
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top"></table>
                                                                               ^
test_output_102/html/namespacefoo.xhtml:104: parser error : Opening and ending tag mismatch: tr line 103 and div
</div><!-- contents -->
      ^
test_output_102/html/namespacefoo.xhtml:109: parser error : Opening and ending tag mismatch: table line 100 and div
</div><!-- doc-content -->
      ^
test_output_102/html/namespacefoo.xhtml:110: parser error : Opening and ending tag mismatch: div line 92 and body
</body>
       ^
test_output_102/html/namespacefoo.xhtml:111: parser error : Opening and ending tag mismatch: div line 85 and html
</html>
       ^
test_output_102/html/namespacefoo.xhtml:112: parser error : Premature end of data in tag body line 21
^
test_output_102/html/namespacefoo_1_1v1_1_1nn.xhtml:105: parser error : Opening and ending tag mismatch: td line 103 and table
</table>
        ^
test_output_102/html/namespacefoo_1_1v1_1_1nn.xhtml:106: parser error : Opening and ending tag mismatch: tr line 103 and div
</div><!-- contents -->
      ^
test_output_102/html/namespacefoo_1_1v1_1_1nn.xhtml:111: parser error : Opening and ending tag mismatch: table line 100 and div
</div><!-- doc-content -->
      ^
test_output_102/html/namespacefoo_1_1v1_1_1nn.xhtml:112: parser error : Opening and ending tag mismatch: div line 96 and body
</body>
       ^
test_output_102/html/namespacefoo_1_1v1_1_1nn.xhtml:113: parser error : Opening and ending tag mismatch: div line 89 and html
</html>
       ^
test_output_102/html/namespacefoo_1_1v1_1_1nn.xhtml:114: parser error : Premature end of data in tag body line 21
^
test_output_102/html/namespacefoo_1_1v1.xhtml:107: parser error : Opening and ending tag mismatch: td line 107 and table
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top"></table>
                                                                               ^
test_output_102/html/namespacefoo_1_1v1.xhtml:108: parser error : Opening and ending tag mismatch: tr line 107 and div
</div><!-- contents -->
      ^
test_output_102/html/namespacefoo_1_1v1.xhtml:113: parser error : Opening and ending tag mismatch: table line 104 and div
</div><!-- doc-content -->
      ^
test_output_102/html/namespacefoo_1_1v1.xhtml:114: parser error : Opening and ending tag mismatch: div line 96 and body
</body>
       ^
test_output_102/html/namespacefoo_1_1v1.xhtml:115: parser error : Opening and ending tag mismatch: div line 89 and html
</html>
       ^
test_output_102/html/namespacefoo_1_1v1.xhtml:116: parser error : Premature end of data in tag body line 21
^
test_output_102/html/namespacefoo_1_1v1_1_1nn_1_1v2.xhtml:99: parser error : Opening and ending tag mismatch: td line 99 and table
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top"></table>
                                                                               ^
test_output_102/html/namespacefoo_1_1v1_1_1nn_1_1v2.xhtml:100: parser error : Opening and ending tag mismatch: tr line 99 and div
</div><!-- contents -->
      ^
test_output_102/html/namespacefoo_1_1v1_1_1nn_1_1v2.xhtml:105: parser error : Opening and ending tag mismatch: table line 96 and div
</div><!-- doc-content -->
      ^
test_output_102/html/namespacefoo_1_1v1_1_1nn_1_1v2.xhtml:106: parser error : Opening and ending tag mismatch: div line 95 and body
</body>
       ^
test_output_102/html/namespacefoo_1_1v1_1_1nn_1_1v2.xhtml:107: parser error : Opening and ending tag mismatch: div line 89 and html
</html>
       ^
test_output_102/html/namespacefoo_1_1v1_1_1nn_1_1v2.xhtml:108: parser error : Premature end of data in tag body line 21
^
test_output_102/html/102__hide__inline__namespace_8cpp.xhtml:100: parser error : Opening and ending tag mismatch: td line 100 and table
<tr class="memitem:"><td class="memItemLeft" align="right" valign="top"></table>
                                                                               ^
test_output_102/html/102__hide__inline__namespace_8cpp.xhtml:110: parser error : Opening and ending tag mismatch: tr line 100 and div
</div><!-- contents -->
      ^
test_output_102/html/102__hide__inline__namespace_8cpp.xhtml:115: parser error : Opening and ending tag mismatch: td line 96 and div
</div><!-- doc-content -->
      ^
test_output_102/html/102__hide__inline__namespace_8cpp.xhtml:116: parser error : Opening and ending tag mismatch: tr line 96 and body
</body>
       ^
test_output_102/html/102__hide__inline__namespace_8cpp.xhtml:117: parser error : Opening and ending tag mismatch: table line 93 and html
</html>
       ^
test_output_102/html/102__hide__inline__namespace_8cpp.xhtml:118: parser error : Premature end of data in tag div line 92
^

-------------------------------------
1 out of 1 tests failed

Copy link

sonarcloud bot commented Mar 11, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
12.9% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@albert-github
Copy link
Collaborator

Regarding:

and just copied content of generated build/testing/test_output_102/102__hide__inline__namespace_8cpp.xml as testing/102/102__hide__inline__namespace_8cpp.xml

for this there is the possibility / flag --updateref with the tests command so:

make tests TEST_FLAGS="--updateref --id 102"

see also

make tests TEST_FLAGS=--help

@albert-github
Copy link
Collaborator

Regarding:

test_output_102/docbook/namespacefoo_1_1v1.xml:17: parser error : Opening and ending tag mismatch: para line 17 and listitem
            <listitem><para></listitem>
                                       ^
test_output_102/docbook/namespacefoo_1_1v1.xml:18: parser error : Opening and ending tag mismatch: listitem line 17 and itemizedlist
        </itemizedlist>

this indicates to me that some adjustments are also needed in xmlgen.cpp / xmldocvisitor.cpp (the XML output is generated in a bit different from the e.g. the HTML / LaTeX / ... output)

@zchrissirhcz
Copy link
Contributor Author

Regarding:

test_output_102/docbook/namespacefoo_1_1v1.xml:17: parser error : Opening and ending tag mismatch: para line 17 and listitem
            <listitem><para></listitem>
                                       ^
test_output_102/docbook/namespacefoo_1_1v1.xml:18: parser error : Opening and ending tag mismatch: listitem line 17 and itemizedlist
        </itemizedlist>

this indicates to me that some adjustments are also needed in xmlgen.cpp / xmldocvisitor.cpp (the XML output is generated in a bit different from the e.g. the HTML / LaTeX / ... output)

Oh I see in the xmldocvisitor.cpp, I searched the <para>, it seems here it is truncated:

void XmlDocVisitor::operator()(const DocPara &p)
{
  if (m_hide) return;
  m_t << "<para>";
  visitChildren(p);
  m_t << "</para>\n";
}

But I'm not familiar with std::visit() now.

@albert-github
Copy link
Collaborator

albert-github commented Mar 11, 2024

I just saw that also in the test_output_102/html/namespacefoo.xhtml there are some problems (the option --xhtml in the TEST_FLAGS, so it looks like that in general due to the hiding of the inline namespaces there is a discrepancy between the number of starting and ending tags in the output.

@rod7760
Copy link

rod7760 commented Mar 18, 2024

For the first para error, it seems to be caused here:

void DocbookGenerator::startMemberItem(const QCString &,MemberItemType,const QCString &)
{
DB_GEN_C
  if (m_inListItem[m_levelListItem]) m_t << "</listitem>\n";
  m_t << "            <listitem><para>";
  m_inListItem[m_levelListItem] = TRUE;
}
void DocbookGenerator::endMemberItem(MemberItemType)
{
DB_GEN_C
  m_t << "</para>\n";
}

Each def file seems to call the start and end functions on the current generator:
for example

 ol.startMemberList();
  bool hideInlineNamespaces = Config_getBool(HIDE_INLINE_NAMESPACE);
  for (const auto &nd : *this)
  {
    if (nd->isLinkable() && nd->hasDocumentation())
    {
      if (hideInlineNamespaces && nd->isInline())
        continue;

      SrcLangExt lang = nd->getLanguage();
      if (lang==SrcLangExt::IDL && (isConstantGroup != nd->isConstantGroup()))
          continue; // will be output in another pass, see layout_default.xml
      ol.startMemberDeclaration();
      ol.startMemberItem(nd->anchor(),OutputGenerator::MemberItemType::Normal);
      QCString ct = nd->compoundTypeString();
      ol.docify(ct);
      ol.docify(" ");
      ol.insertMemberAlign();
      QCString name;
      if (localName)
      {
        name = nd->localName();
      }
      else
      {
        name = nd->displayName();
      }
      ol.writeObjectLink(nd->getReference(),nd->getOutputFileBase(),QCString(),name);
      ol.endMemberItem(OutputGenerator::MemberItemType::Normal);

Based on this information, I would guess that for some reason the ol.endMemberItem function is not being called when the namespace is hidden. Why it isn't being called? I have no clue.

@rod7760
Copy link

rod7760 commented Mar 18, 2024

Aha! I believe the first para error is caused by classdef.cpp actually.

You prematurely return before the end item can be added:

   ol.startMemberItem(anchor(),OutputGenerator::MemberItemType::Normal);
    QCString ctype = compoundTypeString();
    QCString cname = displayName(!localNames);

    Definition* outDef = getOuterScope();
    if (hideInlineNamespaces && outDef && outDef->definitionType() == Definition::DefType::TypeNamespace)
    {
      NamespaceDef* outDefReal = reinterpret_cast<NamespaceDef*>(outDef);
      if (outDefReal->isInline())
      {
        return;
      }
    }

   … (other stuff)
    ol.endMemberItem(OutputGenerator::MemberItemType::Normal);

Maybe call endMemberItem before the return? Hope this is helpful.

@albert-github
Copy link
Collaborator

Regarding the remark in #10070 (comment)

I'm not sure that the return is a good idea at all to be used in this construct as not only the memberitem is not closed properly but also the member declaration block is not correctly closed, so probably some more changes are needed / the tests logic and order has to be reconsidered.

@rod7760
Copy link

rod7760 commented Mar 19, 2024

Ah, yes the member declaration does need to be closed too.

--- a/src/classdef.cpp
+++ b/src/classdef.cpp
@@ -2481,6 +2481,8 @@ void ClassDefImpl::writeDeclarationLink(OutputList &ol,bool &found,const QCStrin
       NamespaceDef* outDefReal = reinterpret_cast<NamespaceDef*>(outDef);
       if (outDefReal->isInline())
       {
+        ol.endMemberItem(OutputGenerator::MemberItemType::Normal);
+        ol.endMemberDeclaration(anchor(),QCString());
         return;
       }
     }

It seems that closing both fixes the errors.

make tests TEST_FLAGS="--xml --xmlxsd --xhtml --qhp --docbook --rtf --id 102"     2.7.8
[  3%] Built target spdlog
[ 74%] Built target doxymain
[ 75%] Built target md5
[ 75%] Built target lodepng
[ 84%] Built target mscgen
[ 84%] Built target sqlite3
[ 84%] Checking the doxygen version for changes...
[ 84%] Built target check_doxygen_version
[ 84%] Checking the git repository for changes...
[ 84%] Built target check_git_repository
[ 85%] Built target doxygen_version
[ 87%] Built target xml
[ 88%] Built target generate_configvalues_header
[ 91%] Built target vhdlparser
[ 97%] Built target doxycfg
[ 98%] Built target doxygen
[100%] Running doxygen tests...
1..1
ok - [102_hide_inline_namespace.cpp]: test collapse of inline namespace
All tests passed!
[100%] Built target tests

However, I am a bit confused by the testing/102/102__hide__inline__namespace_8cpp.xml file. It looks like it contains the inline namespaces i.e. v1. Is this file correct? (I honestly don't know what the expected should look like)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants