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

issue with const keyword #5

Closed
noname77 opened this issue Aug 31, 2021 · 9 comments
Closed

issue with const keyword #5

noname77 opened this issue Aug 31, 2021 · 9 comments

Comments

@noname77
Copy link

noname77 commented Aug 31, 2021

Hey, thanks for great work on adding c# support for breathe and sphinx!

I think I'm using latest versions of your fork of sphinx-csharp and breathe

% python -m pip freeze
[...]
breathe==4.30.0
Sphinx==4.1.2
sphinx-csharp==0.1.11
sphinx-rtd-theme==0.5.2
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
sphinxcontrib-versioning==2.2.1

and using latest doxygen installed with homebrew (im on mac)

% doxygen --version
1.9.2

My issue is that i have a class with a bunch of constants and it seems to fail to recognise those with the following warnings:

WARNING: Failed to find xref for: constbool, no objects found that end like this, searched in object types: ['class', 'struct', 'interface', 'function', 'var', 'event', 'enum']

WARNING: Failed to find xref for: conststring, no objects found that end like this, searched in object types: ['class', 'struct', 'interface', 'function', 'var', 'event', 'enum']

WARNING: Failed to find xref for: constint, no objects found that end like this, searched in object types: ['class', 'struct', 'interface', 'function', 'var', 'event', 'enum']

WARNING: Failed to find xref for: constfloat, no objects found that end like this, searched in object types: ['class', 'struct', 'interface', 'function', 'var', 'event', 'enum']

In my case its an child/internal static class, however the behaviour seems to be the same for any consts. static keyword is also added implicitly in the generated docs, however I think it might be also an artifact of breathe / doxygen.

I tried to do some quick debugging and it seems the signature passed to parse_variable_signature by breathe already has the keywords merged, i.e.

DEBUG: sig: static constint SomeInt   = 123
parsed var: (['static'], 'constint', 'constint', [], 'SomeInt', '123')

class definition:

namespace Namespace
{
    public class OuterClass
    {
        public static class InnerClass
        {
            public const int SomeInt = 123;
        }
    }
}

Doxygen output:

<?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.8.17">
  <compounddef id="class_namespace_1_1_outer_class_1_1_inner_class" kind="class" language="C#" prot="public">
    <compoundname>Namespace::OuterClass::InnerClass</compoundname>
      <sectiondef kind="public-static-attrib">
      <memberdef kind="variable" id="class_namespace_1_1_outer_class_1_1_inner_class_1a1256d6832064011e942341198ffdeabd" prot="public" static="yes" mutable="no">
        <type>const int</type>
        <definition>const int SomeInt</definition>
        <argsstring></argsstring>
        <name>SomeInt</name>
        <initializer>= 123</initializer>
        <briefdescription>
        </briefdescription>
        <detaileddescription>
        </detaileddescription>
        <inbodydescription>
        </inbodydescription>
        <location file="/<SomePath>/OuterClass.cs" line="xx" column="yy" bodyfile="/<SomePath>/OuterClass.cs" bodystart="zz" bodyend="ee"/>
      </memberdef>
  </compounddef>
</doxygen>

Doxygen html output:
image

Sphinx html output:
image

Any ideas how to get rid of the static keyword or at least split the constint into two keywords?
Or how to get the sphinx/breathe html output closer to that of doxygen?

breathe issue xref

Best,
Wiktor

@rogerbarton
Copy link
Owner

Firstly, I haven't looked at this code in a while.

sphinx-csharp should detect the const as a keyword. The doxygen output seems fine. My hunch is that breathe is somehow adding the static and assuming there is only one keyword.

I should really add some tests for the doxygen/breathe integration, will have a look at this...

@rogerbarton
Copy link
Owner

This issue is similar to #2, except that const is a vaild C# keyword.

@noname77
Copy link
Author

noname77 commented Aug 31, 2021

wow, thanks (and for the super quick response)!

btw, i also created an issue for breathe and added a ref here

@rogerbarton
Copy link
Owner

rogerbarton commented Aug 31, 2021

I used breathe>=4.19.2 last time in https://github.com/rogerbarton/vr-modeling/blob/master/docs/requirements.txt. There may be issues when you use breathe=4.30.0

@rogerbarton
Copy link
Owner

I think if you use git+https://github.com/rogerbarton/breathe.git@dev in your requirements.txt it should work for now.

@rogerbarton
Copy link
Owner

Can you try using pip install git+https://github.com/rogerbarton/breathe.git@dev and then running it again. I think rogerbarton/breathe@fc0d085 should have fixed the issue.

@noname77
Copy link
Author

noname77 commented Sep 2, 2021

Perfect, thanks for the quick fix! Works like a charm now :)

The constants are still listed under static attributes, however I think this is fine since they are indeed implicitly static.

image

@noname77 noname77 closed this as completed Sep 2, 2021
@rogerbarton
Copy link
Owner

Awesome glad it works, I will now create a merge request for the breathe repo...

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

No branches or pull requests

2 participants