Skip to content

Commit

Permalink
Add support for Zig and fix Hare comment style
Browse files Browse the repository at this point in the history
Zig supports C99 single line comments, but not C multi-line comments.

Fix the comment style for Hare by using ZigCommentStyle, instead of
CCommentStyle.

I avoided adding support for zon (Zig Object Notation) files used by
the Zig package manager, since it is still in its early stages.

Closes #837
Closes #888

Signed-off-by: Carmen Bianca BAKKER <carmenbianca@fsfe.org>
  • Loading branch information
perillo authored and carmenbianca committed Jan 16, 2024
1 parent c540f46 commit 4e8e0c5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ CLI command and its behaviour. There are no guarantees of stability for the
- ShellCheck configuration (`.shellcheckrc`) (#862)
- Pylint in-project configuration (`pylintrc`) (#862)
- Lisp schemes (`.sld`, `.sls`, `.sps`) (#875)
- Added comment styles:
- `csingle` for Zig (`.zig`) and Hare (`.ha`) (#889)
- Display recommendations for steps to fix found issues during a lint. (#698)
- Add support for Pijul VCS. Pijul support is not added to the Docker image.
(#858)
Expand Down
18 changes: 14 additions & 4 deletions src/reuse/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,15 @@ class XQueryCommentStyle(CommentStyle):
INDENT_BEFORE_END = " "


class CSingleCommentStyle(CommentStyle):
"""C single-only comment style."""

SHORTHAND = "csingle"

SINGLE_LINE = "//"
INDENT_AFTER_SINGLE = " "


#: A map of (common) file extensions against comment types.
EXTENSION_COMMENT_STYLE_MAP = {
".adb": HaskellCommentStyle,
Expand Down Expand Up @@ -600,7 +609,7 @@ class XQueryCommentStyle(CommentStyle):
".graphql": PythonCommentStyle,
".groovy": CCommentStyle,
".h": CCommentStyle,
".ha": CCommentStyle,
".ha": CSingleCommentStyle,
".hbs": HandlebarsCommentStyle,
".hcl": PythonCommentStyle,
".hh": CCommentStyle,
Expand Down Expand Up @@ -712,11 +721,11 @@ class XQueryCommentStyle(CommentStyle):
# SuperCollider synth definition (binary)
".scsyndef": UncommentableCommentStyle,
".sh": PythonCommentStyle,
".sld": LispCommentStyle, # Scheme Library Definition (R7RS)
".sls": LispCommentStyle, # Scheme Library Source (R6RS)
".sld": LispCommentStyle, # Scheme Library Definition (R7RS)
".sls": LispCommentStyle, # Scheme Library Source (R6RS)
".sml": MlCommentStyle,
".soy": CCommentStyle,
".sps": LispCommentStyle, # Scheme Program Source (R6RS)
".sps": LispCommentStyle, # Scheme Program Source (R6RS)
".sql": HaskellCommentStyle,
".sty": TexCommentStyle,
".svg": UncommentableCommentStyle,
Expand Down Expand Up @@ -756,6 +765,7 @@ class XQueryCommentStyle(CommentStyle):
".xsl": HtmlCommentStyle,
".yaml": PythonCommentStyle,
".yml": PythonCommentStyle,
".zig": CSingleCommentStyle,
".zsh": PythonCommentStyle,
}

Expand Down

0 comments on commit 4e8e0c5

Please sign in to comment.