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

Problems due to unquoted initializers in C++ structs / classes #119

Open
g-braeunlich opened this issue Dec 2, 2024 · 2 comments · May be fixed by #120
Open

Problems due to unquoted initializers in C++ structs / classes #119

g-braeunlich opened this issue Dec 2, 2024 · 2 comments · May be fixed by #120

Comments

@g-braeunlich
Copy link

g-braeunlich commented Dec 2, 2024

Given this example:

struct Example{
  int number = 1;
  bool logical = [](){ return true; }();
};

doxygen outputs this xml:

<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.12.0" xml:lang="en-US">
  <compounddef id="structExample" kind="struct" language="C++" prot="public">
    <compoundname>Example</compoundname>
    <sectiondef kind="public-attrib">
      <memberdef kind="variable" id="structExample_1a09f7763a5fb31fea43835bbeee959437" prot="public" static="no" mutable="no">
        <type>int</type>
        <name>number</name>
        <initializer>= 1</initializer>
        ...
      </memberdef>
      <memberdef kind="variable" id="structExample_1a3bf3d46e677ff30a1aaaa087d8e3ce2c" prot="public" static="no" mutable="no">
        <type>bool</type>
        <name>logical</name>
        <initializer>= []() { return true; }()</initializer>
       ...
      </memberdef>
    </sectiondef>
    ...
  </compounddef>
</doxygen>

Which then gets translated to this md:

# Struct Example

[**ClassList**](annotated.md) **>** [**Example**](structExample.md)

## Public Attributes

| Type | Name |
| ---: | :--- |
|  bool | [**logical**](#variable-logical)   = = []() { return true; }()<br> |
|  int | [**number**](#variable-number)   = = 1<br> |
...

At this point 2 issues become visible:

  • There is a duplicated = sign.
  • The []() appears unquoted and thus will be interpreted as a md reference instead of code.

Suggestions:

  • Strip leading / = chars from initializers when reading from xml.
  • Quote all parsed initializer strings with md backticks before writing out to md
@JakubAndrysek
Copy link
Owner

Hi, thank you for providing a detailed example. If you know how to fix it, feel free to make PR. I'll look at it first over the Christmas holidays.

Have a nice day, Jacob

@g-braeunlich g-braeunlich linked a pull request Dec 3, 2024 that will close this issue
@g-braeunlich
Copy link
Author

Thanks for the quick reply. I already created a PR. I did not find any unit tests. Therefore I also did not write one for this use case.
If you still want some or if I violated some contributing guidelines, please let me know!

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 a pull request may close this issue.

2 participants