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 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,4 @@ Contributors
- Skyler Grey <[email protected]>
- Emil Velikov <[email protected]>
- Linnea Gräf <[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)
43 changes: 39 additions & 4 deletions src/reuse/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# SPDX-FileCopyrightText: 2023 Shun Sakai <[email protected]>
# SPDX-FileCopyrightText: 2024 Rivos Inc.
# SPDX-FileCopyrightText: 2024 Anthony Loiseau <[email protected]>
# SPDX-FileCopyrightText: 2024 Kiko Fernandez-Reyes <[email protected]>
#
# SPDX-License-Identifier: GPL-3.0-or-later

Expand Down Expand Up @@ -392,6 +393,26 @@ class ModernFortranCommentStyle(CommentStyle):
INDENT_AFTER_SINGLE = " "


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

SHORTHAND = "erlang"

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


class ElixirCommentStyle(CommentStyle):
"""Elixir comment style."""

SHORTHAND = "elixir"

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


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

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


class GleamCommentStyle(CommentStyle):
"""Gleam comment style."""

SHORTHAND = "gleam"

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


class HandlebarsCommentStyle(CommentStyle):
"""Handlebars comment style."""

Expand Down Expand Up @@ -632,9 +663,10 @@ class XQueryCommentStyle(CommentStyle):
".dts": CppCommentStyle,
".dtsi": CppCommentStyle,
".el": LispCommentStyle,
".erl": TexCommentStyle,
".ex": PythonCommentStyle,
".exs": PythonCommentStyle,
".erl": ErlangCommentStyle,
".escript": ErlangCommentStyle,
".ex": ElixirCommentStyle,
".exs": ElixirCommentStyle,
".f": FortranCommentStyle,
".fsproj": HtmlCommentStyle,
".f03": ModernFortranCommentStyle,
Expand All @@ -653,6 +685,7 @@ class XQueryCommentStyle(CommentStyle):
".fsx": CppCommentStyle,
".ftl": FtlCommentStyle,
".gemspec": PythonCommentStyle,
".gleam": GleamCommentStyle,
".go": CppCommentStyle,
".gradle": CppCommentStyle,
".graphql": PythonCommentStyle,
Expand All @@ -666,7 +699,7 @@ class XQueryCommentStyle(CommentStyle):
".hh": CppCommentStyle,
".hjson": CppCommentStyle,
".hpp": CppCommentStyle,
".hrl": TexCommentStyle,
".hrl": ErlangCommentStyle,
".hs": HaskellCommentStyle,
".html": HtmlCommentStyle,
".hx": CppCommentStyle,
Expand Down Expand Up @@ -824,11 +857,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