-
Notifications
You must be signed in to change notification settings - Fork 10
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
autostruct/autounion/autoenum directives can't reference typedefs of anonymous structs/unions/enums #201
Comments
Presumably this only affects clang 15 and earlier, as clang 16 and later have the right name in |
Hmmm 🤔 Wouldn't the real reason be that we're documenting it as a struct and not a type? This kind of goes back to what I was saying in #190. I'm not sure what you're thinking of doing about it, but I don't like the idea of yet another workaround. I'd rather go back to the original behaviour (consistent) and later think of allowing a shortcut and documenting the typedef (as a type) if the documentation applies do an anonymous struct/whatever that is defined inline with the typedef. That still sounds to me like the real solution. Edit: Never mind. While I still stand by the above generally, this issue is not exactly about what I was thinking of when I read the title... |
Well, I don't think so. We've been documenting Indeed, there's no bug with Clang 16+ because it gets the name from |
I'm not sure yet if this is the right fix, but this does fix the issue:
|
Yup, I got there eventually ahah. Not that I think you should be able to reference such things with |
Hmm, it's not really obvious to me either. It's rather telling of how that part of the code still lacks in intuitiveness :/ |
I maintain that it would be odd to document struct members for autotype, even if it works. And it might be seen as a bug in Sphinx and get fixed later. If one wants to document the type separately, they should be defined separately:
|
I think this would be helped by passing the cursors (or abstractions of the cursors) to docstring. |
Indeed! |
Clang 15 and earlier have None for the cursor.spelling of typedefs of anonymous structs/unions/enums. Clang 16 and later return the name of the typedef. We address this in decl_name to get the Docstring right across Clang versions, but the name filtering in Docstring._match() uses name. This results in us being unable to reference typedefs of anonymous entities with Clang 15 and earlier. Fix it up by returning decl_name as name from Doccursor if cursor.spelling is None. In the long run, we should unify on just name. The decl_name was always a workaround when we did the fixups in parser.py. With Doccursor, we should be able to further clean that up, but for the time being, close the known issue with the minimal fix. It's probably theoretical, but in the case *both* name and decl_name were None, we'd end up in infinite recursion if decl_name used self.name instead of self._cc.spelling. It's a bit of a wart, but should also cleaned up later. Fixes #201
Clang 15 and earlier have None for the cursor.spelling of typedefs of anonymous structs/unions/enums. Clang 16 and later return the name of the typedef. We address this in decl_name to get the Docstring right across Clang versions, but the name filtering in Docstring._match() uses name. This results in us being unable to reference typedefs of anonymous entities with Clang 15 and earlier. Fix it up by returning decl_name as name from Doccursor if cursor.spelling is None. In the long run, we should unify on just name. The decl_name was always a workaround when we did the fixups in parser.py. With Doccursor, we should be able to further clean that up, but for the time being, close the known issue with the minimal fix. It's probably theoretical, but in the case *both* name and decl_name were None, we'd end up in infinite recursion if decl_name used self.name instead of self._cc.spelling. It's a bit of a wart, but should also be cleaned up later. Fixes #201
The fixed up name is passed as
decl_name
to docstring, but the matching usesname
, always failing to match.The text was updated successfully, but these errors were encountered: