fsfe / reuse-tool

reuse is a tool for compliance with the REUSE recommendations.
https://reuse.software
399 stars 148 forks source link

Add comment style for Unix manual pages #942

Closed lpechacek closed 6 months ago

lpechacek commented 6 months ago

I'm not sure if this feature fits the tool roadmap but I believe that Unix manual page/roff format should be supported. Thanks in advance for the time spent with evaluation of this enhancement.

As an illustration, my shot at the implementation:

From a955ba3c66817015a8944d4138096dcc85ee3b3e Mon Sep 17 00:00:00 2001
From: Libor Pechacek <lpechacek@gmx.com>
Date: Mon, 1 Apr 2024 13:16:02 +0200
Subject: [PATCH 2/2] Add support for Unix manual pages (`.man`)

---
 src/reuse/comment.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/reuse/comment.py b/src/reuse/comment.py
index aa6b63f3ed55..c85c7e13f2a7 100644
--- a/src/reuse/comment.py
+++ b/src/reuse/comment.py
@@ -533,6 +533,15 @@ class UncommentableCommentStyle(EmptyCommentStyle):
     """

+class UnixManCommentStyle(CommentStyle):
+    """UNIX manual page comment style."""
+
+    SHORTHAND = "man"
+
+    SINGLE_LINE = ".\\\""
+    INDENT_AFTER_SINGLE = " "
+
+
 class VelocityCommentStyle(CommentStyle):
     """Apache Velocity Template Language comment style."""

@@ -675,6 +684,7 @@ EXTENSION_COMMENT_STYLE_MAP = {
     ".lsp": LispCommentStyle,
     ".lua": HaskellCommentStyle,
     ".m4": M4CommentStyle,
+    ".man": UnixManCommentStyle,
     ".markdown": HtmlCommentStyle,
     ".md": HtmlCommentStyle,
     ".mjs": CCommentStyle,
-- 
2.44.0