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

Improve generated comments #535

Closed
dcharkes opened this issue Jun 25, 2020 · 3 comments
Closed

Improve generated comments #535

dcharkes opened this issue Jun 25, 2020 · 3 comments

Comments

@dcharkes
Copy link
Collaborator

Sometimes, our generated comments are very long lines (above 80 chars).

/**
 * A cursor representing some element in the abstract syntax tree for
 * a translation unit.

->

/// A cursor representing some element in the abstract syntax tree for a translation unit.

Is there a way to get the original word wrapping from the comments? Or does clang_Cursor_getBriefCommentText remove the word wrapping altogether?

If it removes the word wrapping altogether, can we manually word wrap before we reach 80 chars?

Something like string.split(" ") and then join till below 76 characters (80 - '/// '.length) again.

Sidenote: maybe we should also support using clang_Cursor_getRawCommentText if people want the full C/C++ comments verbatim (only replacing the comment type with ///).

@dcharkes
Copy link
Collaborator Author

Another side note: We should also investigate why clang does not see comments on sqlite3.h. (Possibly because of the slightly strange comment syntax /*\n** the comment\n*/.)

@mannprerak2
Copy link
Contributor

mannprerak2 commented Jun 25, 2020

Is there a way to get the original word wrapping from the comments? Or does clang_Cursor_getBriefCommentText remove the word wrapping altogether?

The clang_Cursor_getBriefCommentText method returns the first paragraph only, while replacing any new lines with a 'space'. Which means we need to wrap the comment ourselves.

Another side note: We should also investigate why clang does not see comments on sqlite3.h. (Possibly because of the slightly strange comment syntax /*\n** the comment\n*/.)

The correct syntax for a doc comment is

/**
* Some comment string
* Another comment string
*/

The doc comment must start with a /** if clang_Cursor_getBriefCommentText is to return it.

maybe we should also support using clang_Cursor_getRawCommentText if people want the full C/C++ comments verbatim (only replacing the comment type with ///).

We can provide an option for them to get the Raw comment. And replace these - /**,*,*/ with this - ///

We currently have an option to turn off comments

extract-comments: true/false

We can replace it with

comments: 'brief'/'full'/'none'

And use brief as default

@mannprerak2
Copy link
Contributor

Closed by PR dart-archive/ffigen#16

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants