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

Support for doc comments in icrate generation #435

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

simlay
Copy link
Collaborator

@simlay simlay commented Apr 11, 2023

I'm not sure there's an issue for this but saw the TODO and felt like doing it. My biggest complaint is that the generated doc strings have various type annotations meant for something like sphinx. It makes them just kinda gross.

Also, some of the comments don't work great with some of the macros.

@@ -0,0 +1,126 @@
//! Utilities for manipulating C/C++ comments.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I copied this file straight out of bindgen and then modified it for some of the extra gross objective-c comments.

Copy link
Owner

Choose a reason for hiding this comment

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

Could you leave attribution in the file? I think that should alleviate most licensing issues (they have a different license than us), but IANAL.

Copy link
Owner

@madsmtm madsmtm left a comment

Choose a reason for hiding this comment

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

Oh, I remember trying this before I discovered the "-fretain-comments-from-system-headers" flag, and then never got back to it, but this is really nice!

My biggest complaint is that the generated doc strings have various type annotations meant for something like sphinx. It makes them just kinda gross.

Yeah, I can see a few options for resolving that:

  1. Entity::get_parsed_comment, if it handles those tags? If not, maybe it's possible to turn on a clang feature flag to handle that?
  2. Shell out to some sort of external sphinx parser.
  3. Investigate how Xcode handles them normally, maybe use their implementation (if it's open-source, probably difficult otherwise)

But it's still better than nothing.

Also, some of the comments don't work great with some of the macros.

Yeah, typed_enum, typed_extensible_enum and extern_static need a $(#[$m:meta])* in their definition, should be fairly simple (see icrate/src/macros.rs).

@@ -447,12 +455,14 @@ impl Stmt {
designated_initializers,
derives: data.map(|data| data.derives.clone()).unwrap_or_default(),
ownership: data.map(|data| data.ownership.clone()).unwrap_or_default(),
comment: comment.clone(),
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think it makes sense to duplicate the comment on the class to the Methods and ProtocolImpl. Sure, impl MyClass and impl MyProtocol for MyClass won't have any comments associated with them if we don't clone it, but I think that's better.

Same goes for ProtocolImpl in categories.

@@ -0,0 +1,126 @@
//! Utilities for manipulating C/C++ comments.
Copy link
Owner

Choose a reason for hiding this comment

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

Could you leave attribution in the file? I think that should alleviate most licensing issues (they have a different license than us), but IANAL.

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.

2 participants