[flashrom] [PATCH] Pimp the manpage to create nicer hyperlinks and HTML output.

Stefan Tauner stefan.tauner at alumni.tuwien.ac.at
Mon Jan 11 20:40:44 CET 2016


Also, add a target to the makefile to build a flashrom.8.html with groff.
To fix some formatting issues this adds some indention commands as well.

FIXME: svn:ignore for the html
Signed-off-by: Stefan Tauner <stefan.tauner at alumni.tuwien.ac.at>
---
 Makefile        |   8 +++-
 flashrom.8.tmpl | 126 ++++++++++++++++++++++++++++++++++++++------------------
 2 files changed, 92 insertions(+), 42 deletions(-)

On Mon, 11 Jan 2016 14:08:20 +0100
Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net> wrote:

> IIRC you said on IRC that you have a sed version of this. Is this patch
> obsolete?

Even better... I first diagnosed the problem wrongly. The actual problem
was that apparently the BSD groffs could not call FKGRF correctly.
Since this was only added to avoid duplicate code it is not a big issue
to simply duplicate the function as in this patch.

diff --git a/Makefile b/Makefile
index de8464d..072395f 100644
--- a/Makefile
+++ b/Makefile
@@ -810,7 +810,7 @@ TAROPTIONS = $(shell LC_ALL=C tar --version|grep -q GNU && echo "--owner=root --
 # This includes all frontends and libflashrom.
 # We don't use EXEC_SUFFIX here because we want to clean everything.
 clean:
-	rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a *.o *.d $(PROGRAM).8 $(BUILD_DETAILS_FILE)
+	rm -f $(PROGRAM) $(PROGRAM).exe libflashrom.a *.o *.d $(PROGRAM).8 $(PROGRAM).8.html $(BUILD_DETAILS_FILE)
 	@+$(MAKE) -C util/ich_descriptors_tool/ clean
 
 distclean: clean
@@ -1069,8 +1069,12 @@ endif
 	@$(DIFF) -q .features.tmp .features >/dev/null 2>&1 && rm .features.tmp || mv .features.tmp .features
 	@rm -f .featuretest.c .featuretest$(EXEC_SUFFIX)
 
+$(PROGRAM).8.html: $(PROGRAM).8
+	@groff -mandoc -Thtml $< >$@
+
 $(PROGRAM).8: $(PROGRAM).8.tmpl
-	@sed -e '1 s#".*".*#"$(shell ./util/getrevision.sh -d $(PROGRAM).8.tmpl 2>/dev/null)" "$(VERSION)"#' <$< >$@
+	@# Add the man page change date and version to the man page
+	@sed -e 's#.TH FLASHROM 8 ".*".*#.TH FLASHROM 8 "$(shell ./util/getrevision.sh -d $(PROGRAM).8.tmpl 2>/dev/null)" "$(VERSION)"#' <$< >$@
 
 install: $(PROGRAM)$(EXEC_SUFFIX) $(PROGRAM).8
 	mkdir -p $(DESTDIR)$(PREFIX)/sbin
diff --git a/flashrom.8.tmpl b/flashrom.8.tmpl
index 26ea6e9..3501a4c 100644
--- a/flashrom.8.tmpl
+++ b/flashrom.8.tmpl
@@ -1,3 +1,43 @@
+.\" Load the www device when using groff; provide a fallback for groff's MTO macro that formats email addresses.
+.ie \n[.g] \
+.  mso www.tmac
+.el \
+.  de MTO \\$2 \(la\\$1 \(ra\\$3
+.  .
+.\" Create wrappers for .MTO and .URL that print only text on systems w/o groff or if not outputting to a HTML
+.\" device. To that end we need to distinguish HTML output on groff from other configurations first.
+.nr groffhtml 0
+.if \n[.g] \
+.  if "\*[.T]"html" \
+.    nr groffhtml 1
+.\" For code reuse it would be nice to have a single wrapper that gets its target macro as parameter.
+.\" However, this did not work out with NetBSD's and OpenBSD's groff...
+.de URLB
+.  ie (\n[groffhtml]==1) \{\
+.    URL \\$@
+.  \}
+.  el \{\
+.    ie "\\$2"" \{\
+.      BR "\\$1" "\\$3"
+.    \}
+.    el \{\
+.      RB "\\$2 \(la" "\\$1" "\(ra\\$3"
+.    \}
+.  \}
+..
+.de MTOB
+.  ie (\n[groffhtml]==1) \{\
+.    MTO \\$@
+.  \}
+.  el \{\
+.    ie "\\$2"" \{\
+.      BR "\\$1" "\\$3"
+.    \}
+.    el \{\
+.      RB "\\$2 \(la" "\\$1" "\(ra\\$3"
+.    \}
+.  \}
+..
 .TH FLASHROM 8 "" ""
 .SH NAME
 flashrom \- detect, read, write, verify and erase flash chips
@@ -160,9 +200,8 @@ if you have proper means to recover from failure!
 Same as
 .BR \-\-list\-supported ,
 but outputs the supported hardware in MediaWiki syntax, so that it can be
-easily pasted into the wiki page at
-.nh
-.BR http://www.flashrom.org/ .
+easily pasted into the
+.URLB https://www.flashrom.org/Supported_hardware "supported hardware wiki page" .
 Please note that MediaWiki output is not compiled in by default.
 .TP
 .B "\-p, \-\-programmer <name>[:parameter[,parameter[,parameter]]]"
@@ -452,9 +491,9 @@ unusable (see also the
 .B BUGS
 section). The embedded controller (EC) in these
 machines often interacts badly with flashing.
-.nh
-.B http://www.flashrom.org/Laptops
-has more information. For example the EC firmware sometimes resides on the same
+More information is
+.URLB http://www.flashrom.org/Laptops "in the wiki" .
+For example the EC firmware sometimes resides on the same
 flash chip as the host firmware. While flashrom tries to change the contents of
 that memory the EC might need to fetch new instructions or data from it and
 could stop working correctly. Probing for and reading from the chip may also
@@ -480,10 +519,9 @@ like above. In this case you can use
 to tell flashrom (at your own risk) that it is not running on a laptop.
 .SS
 .BR "dummy " programmer
-The dummy programmer operates on a buffer in memory only. It provides a safe
-and fast way to test various aspects of flashrom and is mainly used in
-development and while debugging.
-.sp
+.IP
+The dummy programmer operates on a buffer in memory only. It provides a safe and fast way to test various
+aspects of flashrom and is mainly used in development and while debugging.
 It is able to emulate some chips to a certain degree (basic
 identify/read/erase/write operations work).
 .sp
@@ -599,6 +637,7 @@ is an 8-bit hexadecimal value.
 .BR "nic3com" , " nicrealtek" , " nicnatsemi" , " nicintel", " nicintel_eeprom"\
 , " nicintel_spi" , " gfxnvidia" , " ogp_spi" , " drkaiser" , " satasii"\
 , " satamv" , " atahpt", " atavia " and " it8212 " programmers
+.IP
 These programmers have an option to specify the PCI address of the card
 your want to use, which must be specified if more than one card supported
 by the selected programmer is installed in your system. The syntax is
@@ -619,6 +658,7 @@ Example:
 .B "flashrom \-p nic3com:pci=05:04.0"
 .SS
 .BR "atavia " programmer
+.IP
 Due to the mysterious address handling of the VIA VT6421A controller the user can specify an offset with the
 .sp
 .B "  flashrom \-p atavia:offset=addr"
@@ -627,10 +667,10 @@ syntax where
 .B addr
 will be interpreted as usual (leading 0x (0) for hexadecimal (octal) values, or else decimal).
 For more information please see
-.nh
-.B http://flashrom.org/VT6421A
+.URLB http://flashrom.org/VT6421A "its wiki page" .
 .SS
 .BR "nicintel_eeprom " programmer
+.IP
 This is the first programmer module in flashrom that does not provide access to NOR flash chips but EEPROMs
 mounted on gigabit Ethernet cards based on Intel's 82580 NIC. Because EEPROMs normally do not announce their
 size nor allow to be identified, the controller relies on correct size values written to predefined addresses
@@ -639,6 +679,7 @@ EEPROM/card is detected. Intel specifies following EEPROMs to be compatible: Atm
 M95128, M95256 and OnSemi (Catalyst) CAT25CS128.
 .SS
 .BR "ft2232_spi " programmer
+.IP
 An optional parameter specifies the controller
 type and channel/interface/port it should support. For that you have to use the
 .sp
@@ -682,6 +723,7 @@ parameter with the
 syntax.
 .SS
 .BR "serprog " programmer
+.IP
 A mandatory parameter specifies either a serial device (and baud rate) or an IP/port combination for
 communicating with the programmer.
 The device/baud combination has to start with
@@ -711,6 +753,7 @@ More information about serprog is available in
 in the source distribution.
 .SS
 .BR "buspirate_spi " programmer
+.IP
 A required
 .B dev
 parameter specifies the Bus Pirate device node and an optional
@@ -735,12 +778,13 @@ where
 .B state
 can be
 .BR on " or " off .
-More information about the Bus Pirate pull-up resistors and their purpose is available at
-.nh
-.BR "http://dangerousprototypes.com/docs/Practical_guide_to_Bus_Pirate_pull-up_resistors " .
+More information about the Bus Pirate pull-up resistors and their purpose is available
+.URLB "http://dangerousprototypes.com/docs/Practical_guide_to_Bus_Pirate_pull-up_resistors" \
+"in a guide by dangerousprototypes" .
 Only the external supply voltage (Vpu) is supported as of this writing.
 .SS
 .BR "pickit2_spi " programmer
+.IP
 An optional
 .B voltage
 parameter specifies the voltage the PICkit2 should use. The default unit is Volt if no unit is specified.
@@ -769,6 +813,7 @@ can be
 (in Hz). The default is a frequency of 1 MHz.
 .SS
 .BR "dediprog " programmer
+.IP
 An optional
 .B voltage
 parameter specifies the voltage the Dediprog should use. The default unit is
@@ -819,6 +864,7 @@ can be
 to select target chip 1 or 2 respectively. The default is target chip 1.
 .SS
 .BR "rayer_spi " programmer
+.IP
 The default I/O base address used for the parallel port is 0x378 and you can use
 the optional
 .B iobase
@@ -844,19 +890,16 @@ can be
 STK200/300, " wiggler " for the Macraigor Wiggler, or " xilinx " for the Xilinx Parallel Cable III (DLC 5)."
 .sp
 More information about the RayeR hardware is available at
-.nh
-.BR "http://rayer.ic.cz/elektro/spipgm.htm " .
+.URLB "http://rayer.g6.cz/elektro/spipgm.htm" "RayeR's website" .
 The Altera ByteBlasterMV datasheet can be obtained from
-.nh
-.BR "http://www.altera.co.jp/literature/ds/dsbytemv.pdf " .
+.URLB "http://www.altera.co.jp/literature/ds/dsbytemv.pdf" Altera .
 For more information about the Macraigor Wiggler see
-.nh
-.BR "http://www.macraigor.com/wiggler.htm " .
+.URLB "http://www.macraigor.com/wiggler.htm" "their company homepage" .
 The schematic of the Xilinx DLC 5 was published in
-.nh
-.BR "http://www.xilinx.com/support/documentation/user_guides/xtp029.pdf " .
+.URLB "http://www.xilinx.com/support/documentation/user_guides/xtp029.pdf" "a Xilinx user guide" .
 .SS
 .BR "pony_spi " programmer
+.IP
 The serial port (like /dev/ttyS0, /dev/ttyUSB0 on Linux or COM3 on windows) is
 specified using the mandatory
 .B dev
@@ -867,8 +910,7 @@ named "serbang". The optional
 parameter accepts the values "si_prog" (default) or "serbang".
 .sp
 Information about the SI-Prog adapter can be found at
-.nh
-.BR "http://www.lancos.com/siprogsch.html " .
+.URLB "http://www.lancos.com/siprogsch.html" "its website" .
 .sp
 An example call to flashrom is
 .sp
@@ -878,6 +920,7 @@ Please note that while USB-to-serial adapters work under certain circumstances,
 this slows down operation considerably.
 .SS
 .BR "ogp_spi " programmer
+.IP
 The flash ROM chip to access must be specified with the
 .B rom
 parameter.
@@ -907,6 +950,7 @@ More information about the hardware is available at
 .BR http://wiki.opengraphics.org .
 .SS
 .BR "linux_spi " programmer
+.IP
 You have to specify the SPI controller to use with the
 .sp
 .B "  flashrom \-p linux_spi:dev=/dev/spidevX.Y"
@@ -925,6 +969,7 @@ Example that sets the frequency to 8 MHz:
 Please note that the linux_spi driver only works on Linux.
 .SS
 .BR "mstarddc_spi " programmer
+.IP
 The Display Data Channel (DDC) is an I2C bus present on VGA and DVI connectors, that allows exchanging
 informations between a computer and attached displays. Its most common uses are getting display capabilities
 through EDID (at I2C address 0x50) and sending commands to the display using the DDC/CI protocol (at address
@@ -1024,7 +1069,7 @@ needs TCP access to the network or userspace access to a serial port.
 .B buspirate_spi
 needs userspace access to a serial port.
 .sp
-.BR dediprog ", " ft2232_spi " and " usbblaster_spi and " pickit2_spi
+.BR dediprog ", " ft2232_spi ", " usbblaster_spi " and " pickit2_spi
 need access to the USB device via libusb.
 .sp
 .B dummy
@@ -1034,7 +1079,7 @@ needs no access permissions at all.
 .BR gfxnvidia ", " drkaiser ", " satasii ", " satamv ", " atahpt" and " atavia
 have to be run as superuser/root, and need additional raw access permission.
 .sp
-.BR serprog ", " buspirate_spi ", " dediprog ", " usbblaster_spi " and " ft2232_spi and " pickit2_spi
+.BR serprog ", " buspirate_spi ", " dediprog ", " usbblaster_spi ", " ft2232_spi " and " pickit2_spi
 can be run as normal user on most operating systems if appropriate device
 permissions are set.
 .sp
@@ -1047,23 +1092,22 @@ in
 .B "/etc/rc.securelevel"
 and rebooting, or rebooting into single user mode.
 .SH BUGS
-Please report any bugs to the flashrom mailing list at
-.B "<flashrom at flashrom.org>"
+Please report any bugs to the
+.MTOB "flashrom at flashrom.org" "flashrom mailing list" .
 .sp
 We recommend to subscribe first at
-.sp
-.B "  http://www.flashrom.org/mailman/listinfo/flashrom"
+.URLB "http://www.flashrom.org/mailman/listinfo/flashrom" "" .
 .sp
 Many of the developers communicate via the
 .B "#flashrom"
 IRC channel on
 .BR chat.freenode.net .
+If you don't have an IRC client, you can use the
+.URLB http://webchat.freenode.net/?channels=flashrom "freenode webchat" .
 You are welcome to join and ask questions, send us bug and success reports there
 too. Please provide a way to contact you later (e.g.\& a mail address) and be
-patient if there is no immediate reaction. Also, we provide a pastebin service
-at
-.nh
-.B http://paste.flashrom.org
+patient if there is no immediate reaction. Also, we provide a
+.URLB http://paste.flashrom.org "pastebin service"
 that is very useful when you want to share logs etc.\& without spamming the
 channel.
 .SS
@@ -1078,8 +1122,8 @@ paragraph in the
 .B internal programmer
 subsection of the
 .B PROGRAMMER-SPECIFIC INFORMATION
-section and the information in our wiki at
-.BR "http://www.flashrom.org/Laptops " .
+section and the information
+.URLB "http://www.flashrom.org/Laptops" "in our wiki" .
 .SS
 One-time programmable (OTP) memory and unique IDs
 .sp
@@ -1174,8 +1218,10 @@ Yinghai Lu
 .br
 some others, please see the flashrom svn changelog for details.
 .br
-All still active authors can be reached via email at <flashrom at flashrom.org>.
+All still active authors can be reached via
+.MTOB "flashrom at flashrom.org" "the mailing list" .
 .PP
-This manual page was written by Uwe Hermann <uwe at hermann-uwe.de>,
-Carl-Daniel Hailfinger and others.
+This manual page was written by
+.MTOB "uwe at hermann-uwe.de" "Uwe Hermann" ,
+Carl-Daniel Hailfinger, Stefan Tauner and others.
 It is licensed under the terms of the GNU GPL (version 2 or later).
-- 
Kind regards, Stefan Tauner





More information about the flashrom mailing list