Skip to content
This repository has been archived by the owner on Jan 28, 2024. It is now read-only.

Improved generated comments #16

Merged
merged 4 commits into from
Jun 30, 2020
Merged

Improved generated comments #16

merged 4 commits into from
Jun 30, 2020

Conversation

mannprerak2
Copy link
Contributor

@mannprerak2 mannprerak2 commented Jun 27, 2020

closes #16

  • Added comments option to config, Possible options are - {full, brief, none}
  • Extracting comments for enum values, struct members
  • Wrap brief comments (see clang_bindings.dart)
  • Removed comment markups from full comments (see libclang-example/generated_bindings.dart)

Comments can be configured from config with the following comment types:
- full - removes comment markup and trims lines.
- brief - wraps the comment to the given line width.
- none - no comments are added to bindings.
@mannprerak2
Copy link
Contributor Author

There's an issue with libclang's comment generation.
If an enum value has no comment, the comment of the enum value declaration above it is returned.
See this.
We can give an option to disable comment extraction for enum values.

@dcharkes
Copy link
Contributor

dcharkes commented Jun 29, 2020

If an enum value has no comment, the comment of the enum value declaration above it is returned.

Please open an issue on the clang issue tracker.

Possible workarounds:

  1. Assuming the AST-visitor visits the enum values in order, we can detect whether it's exactly the same comment? Assuming we can detect whether the comment is from the same source lines: If it's the same source position we can omit the duplicates.
  2. If we don't have the source positions, we cannot detect whether it's a literal duplicate comment in the source or not. We could make a setting whether to omit duplicate comments, and emit a warning. Or even make a setting whether to omit duplicates. But it feels very much like a clang workaround. (Unless it's intended clang behavior.)

If we're in case 2, maybe just leave it as is + open an issue here + link to the clang issue.

lib/src/header_parser/utils.dart Outdated Show resolved Hide resolved
lib/src/header_parser/utils.dart Outdated Show resolved Hide resolved
lib/src/header_parser/utils.dart Outdated Show resolved Hide resolved
@mannprerak2 mannprerak2 marked this pull request as draft June 29, 2020 16:20
If an enum value declaration has no comment attached to it, libclang
assigns it the comment of previous enum value declaration.
This is fixed by comparing the current comment's source range with
the previous one and removing the current one if its a duplicate.
@mannprerak2 mannprerak2 marked this pull request as ready for review June 29, 2020 17:17
@dcharkes dcharkes merged commit 8a13cb6 into dart-archive:master Jun 30, 2020
@mannprerak2 mannprerak2 deleted the improved_generated_comments branch June 30, 2020 09:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants