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 12 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,4 @@ Contributors
- Emil Velikov <[email protected]>
- Linnea Gräf <[email protected]>
- Raphael Schlarb <[email protected]>
- Kiko Fernandez-Reyes <[email protected]>
3 changes: 3 additions & 0 deletions changelog.d/added/erlang-elixir-gleam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Added comment support for Erlang (`.erl` and `.hrl`), Erlang's leex and yecc
lexer and parser generators (`.xrl` and `.yrl`), Elixir (`.ex` and `.exs`),
and Gleam (`.gleam`). (#1117)
21 changes: 19 additions & 2 deletions src/reuse/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# SPDX-FileCopyrightText: 2024 Rivos Inc.
# SPDX-FileCopyrightText: 2024 Anthony Loiseau <[email protected]>
# SPDX-FileCopyrightText: 2025 Raphael Schlarb <[email protected]>
# SPDX-FileCopyrightText: 2025 Kiko Fernandez-Reyes <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -357,6 +358,7 @@ class CppSingleCommentStyle(CommentStyle):

SINGLE_LINE = "//"
INDENT_AFTER_SINGLE = " "
SHEBANGS = ["#!"] # Gleam


class EmptyCommentStyle(CommentStyle):
Expand Down Expand Up @@ -393,6 +395,16 @@ class ModernFortranCommentStyle(CommentStyle):
INDENT_AFTER_SINGLE = " "


class ErlangCommentStyle(CommentStyle):
"""Erlang comment style."""

SHORTHAND = "erlang"

SINGLE_LINE = "%"
INDENT_AFTER_SINGLE = " "
SHEBANGS = ["#!"]


class FtlCommentStyle(CommentStyle):
"""FreeMarker Template Language comment style."""

Expand Down Expand Up @@ -633,7 +645,9 @@ class XQueryCommentStyle(CommentStyle):
".dts": CppCommentStyle,
".dtsi": CppCommentStyle,
".el": LispCommentStyle,
".erl": TexCommentStyle,
".erl": ErlangCommentStyle,
".escript": ErlangCommentStyle,
".es": ErlangCommentStyle,
".ex": PythonCommentStyle,
".exs": PythonCommentStyle,
".f": FortranCommentStyle,
Expand All @@ -654,6 +668,7 @@ class XQueryCommentStyle(CommentStyle):
".fsx": CppCommentStyle,
".ftl": FtlCommentStyle,
".gemspec": PythonCommentStyle,
".gleam": CppSingleCommentStyle,
".go": CppCommentStyle,
".gperf": CppCommentStyle,
".gradle": CppCommentStyle,
Expand All @@ -668,7 +683,7 @@ class XQueryCommentStyle(CommentStyle):
".hh": CppCommentStyle,
".hjson": CppCommentStyle,
".hpp": CppCommentStyle,
".hrl": TexCommentStyle,
".hrl": ErlangCommentStyle,
".hs": HaskellCommentStyle,
".html": HtmlCommentStyle,
".hx": CppCommentStyle,
Expand Down Expand Up @@ -826,11 +841,13 @@ class XQueryCommentStyle(CommentStyle):
".xqm": XQueryCommentStyle,
".xqy": XQueryCommentStyle,
".xquery": XQueryCommentStyle,
".xrl": ErlangCommentStyle,
".xsd": HtmlCommentStyle,
".xsh": PythonCommentStyle,
".xsl": HtmlCommentStyle,
".yaml": PythonCommentStyle,
".yml": PythonCommentStyle,
".yrl": ErlangCommentStyle,
".zig": CppSingleCommentStyle,
".zsh": PythonCommentStyle,
}
Expand Down