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

Carry comments through to target language (through AST) #65

Closed

Conversation

TomByrne
Copy link

@TomByrne TomByrne commented Sep 6, 2019

A more comprehensive representation of code comments in Haxe AST would make for much more readable output and facilitate people using Haxe as a source-to-source tool.

Using a compiler flag, comments could be included in the generated code (e.g. -Dcomments) .

This would replace the doc property that currently exists on BaseType, ClassField & Field.

Rendered doc

@skial skial mentioned this pull request Sep 6, 2019
1 task
@Simn
Copy link
Member

Simn commented Sep 11, 2019

I recommend splitting up this proposal into two parts:

  1. Retain documentation comments on types and fields.
  2. Retain in-code comments.

The reason is that 1. is several orders of magnitude easier to support. In most generators, it should come down to emitting an additional print at the right places (although determining these places might be a bit finicky).

I think we are unlikely to accept the second part because the benefit/complexity ratio is dubious.

@TomByrne
Copy link
Author

Sounds good.
If you don't think it'll ever be accepted, I'll just remove the section regarding comments in-code.
Any thoughts on enhancing the parsing of comments?

@RealyUniqueName
Copy link
Member

I think Haxe should handle asterisks correctly in docblocks.
If the first non-space char on all lines is asterisk, treat it as the beginning of a doc line.
Otherwise trim the shortest indentation level on each line.

@kLabz
Copy link

kLabz commented Sep 12, 2019

What about markdown lists? I wouldn't want them to be broken by this (and yes, my codebase would break with this).

I'm really not sure Haxe compiler should do anything with the content of the comments, and let macros/whatever parse them any way they want in userland.

@RealyUniqueName
Copy link
Member

What about markdown lists?

If the first non-space char on ALL lines is asterisk

Do you have non-java-style docblocks, which have markdown list as their only content?
IDEA and vscode both automatically insert java-style docblocks upon typing /**.
Also, I think the style of docblocks from Haxe's std lib is quite unique among C-like languages.

- Clarified changes to docblock parsing
- Generalised 'class' to 'type'
- Added simpler Doc typedef
@Simn
Copy link
Member

Simn commented Jun 19, 2020

We will implement support for retaining type and field comments in the output, see linked Haxe issue.

I'll close this PR because the actual proposal is a bit wider. It's unclear if in-code comments are feasible, but this can be discussed at a later point.

@Simn Simn closed this Jun 19, 2020
@skial skial mentioned this pull request Jun 19, 2020
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
5 participants