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

feat(BEAM): Add support for Erlang, Elixir, and Gleam comments #1117

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

kikofernandez
Copy link

Adds support for comments for the most used BEAM languages:

  • Erlang

  • Elixir

  • Gleam

  • Added a change log entry in changelog.d/<directory>/.

  • Added self to copyright blurb of touched files.

  • Added self to AUTHORS.rst.

  • My changes do not contradict
    the current specification.

  • I agree to license my contribution under the licenses indicated in the
    changed files.

@kikofernandez kikofernandez changed the title Feature/erlang elixir gleam comment feat(BEAM): Add support for Erlang, Elixir, and Gleam comments Dec 20, 2024
@kikofernandez
Copy link
Author

Thanks @maennchen for reminding me of Erlang's lexer and parser generators, which are now included in the PR :)

SHEBANGS = ["#!"]


class ElixirCommentStyle(CommentStyle):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks identical to PythonCommentStyle. Do you see any differences or do you think they styles will diverge in the future?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not see any differences, but I thought that maybe one does not want to conflate comment styles for different languages, in case in a few years one comment style changes a bit, while the other should not.

Happy to be wrong and I can fix to use Python style, if you think this is more maintainable 😃

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean I'm just getting back into the codebase, but from what I can see, many languages use the same code style definition and it wouldn't be an issue to add another one should they diverge in the future.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, can you confirm that I understand that the preference is to follow PythonCommentStyle?
Just to confirm that I understood correctly that I should modify this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's what I prefer, but let's wait with changes until we have the confirmation that I'm not just missing something.

@@ -400,6 +421,16 @@ class FtlCommentStyle(CommentStyle):
MULTI_LINE = MultiLineSegments("<#--", "", "-->")


class GleamCommentStyle(CommentStyle):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think CppCommentStyle will serve the same purpose here, won't it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure it would work, as Gleam does not have multiline as CPP

-- copy-pasted CppCommentStyle snippet
MULTI_LINE = MultiLineSegments("/*", "*", "*/")

and the CppCommentStyle also uses some php SHEBANG which I do not think work on Gleam

-- copy-pasted CppCommentStyle snippet
SHEBANGS = [
        "#!",  #  V-Lang
        "<?php",  # PHP
    ]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm not completely off, using CppCommentStyle would only cause a problem if there was a chance for something that looks like a multiline comment in Gleam, but isn't one. The same should also be true for the shebang. @carmenbianca can you confirm?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be honest, I do not think it is an issue in Gleam, but I have not written much Gleam myself.
I mention this as to separate concerns :)
Please let me know what the preferred way would be :)

@kikofernandez kikofernandez force-pushed the feature/erlang-elixir-gleam-comment branch from 977d112 to e034c08 Compare February 3, 2025 20:53
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.

2 participants