SDB Talk:Zypper manual

Jump to: navigation, search

I produced this HTML with:

gzip -d /usr/share/man/man8/zypper.8.gz
groff -t -mandoc -Thtml /usr/share/man/man8/zypper.8 > zypper.html

and used regex replace to get rid of some invalid content for the wiki.

Ravas (talk) 05:42, 12 February 2018 (UTC)

The command could be simplified quite a bit using:

   man -p t -Thtml zypper > zypper.html

The -p t replicates the -t option in groff; the rest of the command run by @Ravas is handled by man internally.

What I actually ran is this, which definitely isn't a simpler command. That will make sense later:

{
rpm -qf $( man --where zypper ) --queryformat '<h1>zypper %{version}</h1>\n'
man -p t -Thtml zypper
} | sed -e '
  2,/^<hr/d
  s/&minus;/-/g
  \|</body>|,$d
  s|&rsquo;\(.*\)'\''|<i>\1</i>|g
  \|<a name="[^"]*"></a>|d
' > /tmp/zypper.html

The rpm command uses man to print the path to the man page, then print the name and version of the RPM. That gives the "zypper 1.2.3" line at the top of the page. By wrapping it in braces, that output is prepended to the HTML output generated by man, so they can both be piped into sed. It could've used %{name} in this case, but I want the man page name, not the package name.

The sed does several things. The most important, IMHO is to replace the minus entity with actual hyphens. This is because the − (in some browsers) renders as something other than the hyphen a user can easily copy-paste into a command line. The other things are to:

* remove from the second line to the first "hr" tag, as that's the html intro which is useless in the wiki
* remove the </body> and </html> at the end
* replace the right quote / left quote markers with italic tags (this will fail if those cross multiple lines, but I haven't seen that yet)
* delete the lines with empty anchors groff puts in

It still needs a removal to get the anchors at the top. I'll edit the command to do that in a moment.

Ideally, these wiki'd man pages should all be auto-generated by CI and should require no further edits. That's why I used zypper instead of %{name} in the rpm queryformat; the three zypper instances in the command could be replaced with "$man_page_name" in some automated command. :)

This still leaves the issue of the ru link and the category tag. I just left them alone at the bottom for now. I think for proper automation there would simply need to be a wiki comment section marker at the beginning and end of the auto-generated content.

--Dannysauer (talk) 18:18, 10 April 2020 (UTC)

I appreciate the efforts in creating this page, but wonder if it's still needed given https://manpages.opensuse.org/Tumbleweed/zypper/zypper.8.en.html providing an up to date manpage with automagic formatting ? -- crameleon 07 August 2023