crystal-lang / crystal_lib

Automatic binding generator for native libraries in Crystal
138 stars 30 forks source link

Add comments extraction support #61

Closed olbat closed 5 years ago

olbat commented 5 years ago

This change introduces a new option to import C doctrings comments at parsing time. It also introduce a new "import_docstrings" parameter to import C doctrings as Crystal comments when generating a lib.

This parameter can take two values: "brief" to extract the brief part of doctrings or "full" to extract the whole docstring 1,2.

A bunch of changes have been made to the core lib to make it possible:

olbat commented 5 years ago

Note: tests are working fine but I didn't manage to get it working with a real example yet, I'm waiting for your feedbacks on the idea of this PR before investigating further.

Also, this change depends on crystal-lang/clang.cr#7.

olbat commented 5 years ago

(I think that the failed CI job should just be restarted for it to pass)

zph commented 5 years ago

I was able to try out this branch and it was able to extract some of the comments from my header file 👍. It doesn't get all of them but that might be due to multiple valid comment formats in the example I tried.

olbat commented 5 years ago

@zph so far I could only parse Doxygen comments but I think there might be an option somewhere to make it possible to parse every type of comments because there are some tests for that in LLVM sources.

olbat commented 5 years ago

Is it ready to be merged, are still some stuffs to be fixed/improved?