diff --git a/src/reuse/_comment.py b/src/reuse/_comment.py index 1a034499e..b833f6ee7 100644 --- a/src/reuse/_comment.py +++ b/src/reuse/_comment.py @@ -273,6 +273,14 @@ class BibTexCommentStyle(CommentStyle): MULTI_LINE = ("@Comment{", "", "}") +class BladeCommentStyle(CommentStyle): + """Laravel Blade Template comment style.""" + + _shorthand = "blade" + + MULTI_LINE = ("{{--", "", "--}}") + + class CCommentStyle(CommentStyle): """C comment style.""" @@ -646,6 +654,15 @@ class VimCommentStyle(CommentStyle): k.lower(): v for k, v in EXTENSION_COMMENT_STYLE_MAP.items() } +#: A map of (common) double file extensions against comment types. +EXTENSIONS_COMMENT_STYLE_MAP = { + ".blade.php": BladeCommentStyle, +} + +EXTENSIONS_COMMENT_STYLE_MAP_LOWERCASE = { + k.lower(): v for k, v in EXTENSIONS_COMMENT_STYLE_MAP.items() +} + FILENAME_COMMENT_STYLE_MAP = { ".bashrc": PythonCommentStyle, ".coveragerc": PythonCommentStyle, diff --git a/src/reuse/header.py b/src/reuse/header.py index 78e463d40..6e776018b 100644 --- a/src/reuse/header.py +++ b/src/reuse/header.py @@ -35,6 +35,7 @@ from . import SpdxInfo from ._comment import ( EXTENSION_COMMENT_STYLE_MAP_LOWERCASE, + EXTENSIONS_COMMENT_STYLE_MAP_LOWERCASE, FILENAME_COMMENT_STYLE_MAP_LOWERCASE, NAME_STYLE_MAP, CCommentStyle, @@ -330,6 +331,9 @@ def find_and_replace_header( def _get_comment_style(path: Path) -> Optional[CommentStyle]: """Return value of CommentStyle detected for *path* or None.""" style = FILENAME_COMMENT_STYLE_MAP_LOWERCASE.get(path.name.lower()) + if style is None: + suffixes_lower = "".join(path.suffixes).lower() + style = EXTENSIONS_COMMENT_STYLE_MAP_LOWERCASE.get(suffixes_lower) if style is None: style = EXTENSION_COMMENT_STYLE_MAP_LOWERCASE.get(path.suffix.lower()) return style