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

doxygenfunction fixes #623

Merged
merged 3 commits into from
Jan 21, 2021
Merged

Conversation

jakobandersen
Copy link
Collaborator

Three fixes:

  1. Render the friend keyword in friend functions.
  2. Fix (C++) Errors when parsing friend functions in a class #613.
    In the Doxygen XML a friend function does not have function as kind, but friend. Unfortunately so does a friend class. One way to distinguish between them is then to check emptiness of the argsstring.
    E.g., for
    struct D {
            friend class A;
            friend D operator+();
    };
    the xml for the content of D is then
    <memberdef kind="friend" id="structD_1a3c84b3381e0c864a7415d891b6a053ba" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
       <type>class</type>
       <definition>friend class A</definition>
       <argsstring></argsstring>
       <name>A</name>
       <param>
          <type><ref refid="structA" kindref="compound">A</ref></type>
       </param>
       ...
    </memberdef>
    <memberdef kind="friend" id="structD_1a35b414831ab33977d59b0e2959c354b4" prot="public" static="no" const="no" explicit="no" inline="no" virt="non-virtual">
       <type><ref refid="structD" kindref="compound">D</ref></type>
        <definition>D operator+</definition>
        <argsstring>()</argsstring>
        <name>operator+</name>
        ...
    </memberdef>
    However, when searching the XML the filters (e.g., https://github.com/michaeljones/breathe/blob/v4.26.0/breathe/renderer/filter.py#L1001) do not search in this XML, but in index.xml which has
    <member refid="structD_1a3c84b3381e0c864a7415d891b6a053ba" kind="friend"><name>A</name></member>
    <member refid="structD_1a35b414831ab33977d59b0e2959c354b4" kind="friend"><name>operator+</name></member>
    and then those index nodes are converted to the corresponding content nodes at some point before they come out at https://github.com/michaeljones/breathe/blob/v4.26.0/breathe/directives.py#L85.
    The filtering of friends is thus done in the directive instead of in the filter.
  3. Strengthen check on arguments when there is only one candidate.
    Consider the C++
    void f(int);
    and the rst
    .. doxygenfunction:: f(int, double, std::string)
    This previously succeeded. Now, if parameters are given in the directive, they are always checked for each candidate. The example will now given a lookup warning.

In addition I removed the deduplication of candidates in the lookup warning. I'm not sure when it makes a difference, but it is only in the output, and is more in line with the internal check. Would be good to see an example where duplicates appear.

With:
	void f(int);
and
	.. doxygenfunction:: f(int, double, std::string)
with no other matches for the name 'f' it would select that
only match instead of checking the arguments.
@vermeeren vermeeren self-requested a review January 20, 2021 23:31
@vermeeren vermeeren self-assigned this Jan 20, 2021
@vermeeren vermeeren added code Source code enhancement Improvements, additions (also cosmetics) labels Jan 20, 2021
Copy link
Collaborator

@vermeeren vermeeren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jakobandersen All good, thanks a lot also for the detailed information in the PR itself.

@michaeljones michaeljones merged commit 52a00aa into breathe-doc:master Jan 21, 2021
michaeljones pushed a commit that referenced this pull request Jan 21, 2021
@jakobandersen jakobandersen deleted the function_fixes branch January 29, 2021 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code Source code enhancement Improvements, additions (also cosmetics)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

(C++) Errors when parsing friend functions in a class
3 participants