git: 40cd8602b5 - main - Make links to drivers man in hardware.adoc

Vladlen Popolitov <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.doc
Message-ID <[email protected]>
The branch main has been updated by vladlen:

URL: https://cgit.FreeBSD.org/doc/commit/?id=40cd8602b5b10ade0308b11e294094b852022267

commit 40cd8602b5b10ade0308b11e294094b852022267
Author:     Vladlen Popolitov <[email protected]>
AuthorDate: 2026-04-28 05:42:22 +0000
Commit:     Vladlen Popolitov <[email protected]>
CommitDate: 2026-04-28 05:42:22 +0000

    Make links to drivers man in hardware.adoc
    
    Reviewed by: carlavilla, mhorne
    Approved by: carlavilla
    Differential Revision: https://reviews.freebsd.org/D56646
    PR: 283060
---
 website/tools/hardware-notes-processor.rb | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/website/tools/hardware-notes-processor.rb b/website/tools/hardware-notes-processor.rb
index 9fc8b20d0f..9532b54180 100644
--- a/website/tools/hardware-notes-processor.rb
+++ b/website/tools/hardware-notes-processor.rb
@@ -26,9 +26,36 @@ File.foreach(hardwareNotesPath).with_index do |line|
     manualPage = line.gsub("&hwlist.", "").gsub(";", "").gsub("\n", "")
 
     if(File.exist?("tmp/share/man/man4/" + manualPage + ".4"))
-      cmd = "mandoc -Tmarkdown tmp/share/man/man4/" + manualPage + ".4 | sed -n '/# HARDWARE/,/#/{/#/!p;}' "
+      cmd = "mandoc -Tmarkdown tmp/share/man/man4/" + manualPage + ".4 | sed -n '/^# HARDWARE/,/^# /{ /^# /d; p; }'"
       mandocOut, err, s = Open3::capture3(cmd)
       if s.success?
+        #replace \_ to _ in drivers name and description
+        mandocOut.gsub!(/\\_/, '_')
+
+        # extract Nm (real driver name)
+        nm_cmd = "grep -m1 '^\\.Nm' tmp/share/man/man4/#{manualPage}.4"
+        nmOut, err2, s2 = Open3.capture3(nm_cmd)
+
+        if s2.success?
+
+          nm = nmOut.split[1]
+
+          if nm && !nm.empty?
+            driverName = File.basename(manualPage)
+
+            if nm != driverName
+              # f.e man ar40xx has driver name ar40xx_switch
+              man_link = "link:https://man.freebsd.org/cgi/man.cgi?query=#{driverName}&amp;apropos=&amp;&sektion=4&amp;format=html[#{nm}]"
+            else
+              man_link = "man:#{driverName}[4]"
+            end
+            # replace only first occurrence, preserving markdown formatting
+            mandocOut.sub!(/[*_]*#{nm}[*_]*/) do
+              man_link
+            end
+          end
+        end
+
         hardwareNotesContent << mandocOut
       end
     else
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.