[bug#77387,2/2] man-db: Support mdoc-formatted man pages.

Message ID 43b006e62f2034b3acdd611e72029c9664922618.1743349817.git.sarg@sarg.org.ru
State New
Headers
Series man-db: Better parsing of man macros. |

Commit Message

Sergey Trofimov March 30, 2025, 2:32 p.m. UTC
  * guix/man-db.scm (man-page->entry): Extract man name and section from
.Dt macro.

Change-Id: I02dc99d73dceecdb077315805025efad9a650e91
---
 guix/man-db.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Ludovic Courtès April 1, 2025, 12:08 p.m. UTC | #1
Sergey Trofimov <sarg@sarg.org.ru> skribis:

> * guix/man-db.scm (man-page->entry): Extract man name and section from
> .Dt macro.
>
> Change-Id: I02dc99d73dceecdb077315805025efad9a650e91

[...]

>                    (match (if (string-prefix? "." line) (man-macro-tokenize line) #f)
> -                    ((".TH" name (= string->number section) _ ...)
> +                    (((or ".TH" ".Dt") name (= string->number section) _ ...)

Likewise, please add a short comment above the clause explaining that
‘.Dt’ is produced by ‘mandoc’ (did I get that right?).

Ludo’.
  

Patch

diff --git a/guix/man-db.scm b/guix/man-db.scm
index 44c01ac298..44668a3ebf 100644
--- a/guix/man-db.scm
+++ b/guix/man-db.scm
@@ -224,7 +224,7 @@  (define* (man-page->entry file #:optional (resolve identity))
                   (mandb-entry file name (or section 0) (or synopsis "")
                                kind)
                   (match (if (string-prefix? "." line) (man-macro-tokenize line) #f)
-                    ((".TH" name (= string->number section) _ ...)
+                    (((or ".TH" ".Dt") name (= string->number section) _ ...)
                      (loop name section synopsis kind))
                     ((".SH" (or "NAME" "\"NAME\""))
                      (loop name section (read-synopsis port) kind))