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

Add comments extraction support #61

Merged
merged 3 commits into from
Sep 18, 2019

Conversation

olbat
Copy link
Contributor

@olbat olbat commented Jul 14, 2019

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:

  • an Option enum has been added to CrystalLib::Parser
  • an @options attribute has been added to CrystalLib::Parser
  • a @doc attribute has been added to CrystalLib::AST nodes

@olbat
Copy link
Contributor Author

olbat commented Jul 14, 2019

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
Copy link
Contributor Author

olbat commented Jul 17, 2019

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

@zph
Copy link

zph commented Jul 25, 2019

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.

src/crystal_lib/lib_transformer.cr Show resolved Hide resolved
src/crystal_lib/parser.cr Outdated Show resolved Hide resolved
src/crystal_lib/parser.cr Show resolved Hide resolved
src/crystal_lib/parser.cr Outdated Show resolved Hide resolved
@olbat olbat force-pushed the add-comments-extraction-support branch 2 times, most recently from f3f63b2 to 8ae1e2d Compare July 25, 2019 17:47
@olbat
Copy link
Contributor Author

olbat commented Jul 25, 2019

@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 olbat force-pushed the add-comments-extraction-support branch 3 times, most recently from 035ff65 to 1e7d91a Compare July 29, 2019 20:32
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.
(see http://www.doxygen.nl/manual/docblocks.html
 https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html)

A bunch of changes have been made to the core lib to make it possible:
- an Option enum has been added to CrystalLib::Parser
- an @options attribute has been added to CrystalLib::Parser
- a @doc attribute has been added to CrystalLib::AST nodes
@olbat olbat force-pushed the add-comments-extraction-support branch from 1e7d91a to 60cb5fe Compare July 29, 2019 20:59
@olbat
Copy link
Contributor Author

olbat commented Aug 12, 2019

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

@RX14 RX14 merged commit 8542199 into crystal-lang:master Sep 18, 2019
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.

4 participants