man-db: Support mdoc-formatted man pages.

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

Change-Id: I02dc99d73dceecdb077315805025efad9a650e91
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
This commit is contained in:
Sergey Trofimov 2025-04-09 14:46:41 +02:00 committed by Ludovic Courtès
parent 80cda80489
commit c705d6e035
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -227,10 +227,13 @@ for it."
;; man 7 groff groff_mdoc groff_man
;; look for metadata in macro invocations (lines starting with .)
(match (and (string-prefix? "." line) (man-macro-tokenize line))
((".TH" name (= string->number section) _ ...)
;; "Title Header" or "Document title"
(((or ".TH" ".Dt") name (= string->number section) _ ...)
(loop name section synopsis kind))
;; "Section Header"
((".SH" (or "NAME" "\"NAME\""))
(loop name section (read-synopsis port) kind))
;; include source
((".so" link)
(match (and=> (resolve link)
(cut man-page->entry <> resolve))