public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [gentoo-commits] proj/portage-utils:master commit in: man/
@ 2018-04-01 13:47 99% Fabian Groffen
  0 siblings, 0 replies; 1+ results
From: Fabian Groffen @ 2018-04-01 13:47 UTC (permalink / raw
  To: gentoo-commits

commit:     684a8118721c28690b74fbdc3e74b351e799ffd8
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Apr  1 12:39:17 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Apr  1 12:39:17 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=684a8118

man/mkman: add header, allow argument description override

 man/mkman.py | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/man/mkman.py b/man/mkman.py
index 0751b92..8444311 100755
--- a/man/mkman.py
+++ b/man/mkman.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
 """Generate man pages for the q applets"""
@@ -14,6 +14,7 @@ import os
 import re
 import subprocess
 import sys
+import yaml
 
 
 MKMAN_DIR = os.path.realpath(os.path.join(__file__, '..'))
@@ -33,7 +34,8 @@ COMMON_AUTHORS = [
     'Ned Ludd <solar@gentoo.org>',
     'Mike Frysinger <vapier@gentoo.org>',
 ]
-TEMPLATE = r""".TH %(applet)s "1" "%(date)s" "Gentoo Foundation" "%(applet)s"
+TEMPLATE = r""".\" generated by mkman.py, please do NOT edit!
+.TH %(applet)s "1" "%(date)s" "Gentoo Foundation" "%(applet)s"
 .SH NAME
 %(applet)s \- %(short_desc)s
 .SH SYNOPSIS
@@ -47,7 +49,8 @@ TEMPLATE = r""".TH %(applet)s "1" "%(date)s" "Gentoo Foundation" "%(applet)s"
 .SH "REPORTING BUGS"
 Please report bugs via http://bugs.gentoo.org/
 .br
-Product: Portage Development; Component: Tools
+Product: Portage Development; Component: Tools, Assignee:
+portage-utils@gentoo.org
 .SH AUTHORS
 .nf
 %(authors)s
@@ -74,7 +77,15 @@ def MkMan(applets, applet, output):
     description = ''
     desc_file = os.path.join(FRAGS_DIR, '%s.desc' % applet)
     if os.path.exists(desc_file):
-        description = open(desc_file).read().rstrip()
+        fh = open(desc_file)
+        description = fh.read().rstrip()
+        fh.close()
+
+    optdescs = []
+    desc_file = os.path.join(FRAGS_DIR, '%s.optdesc.yaml' % applet)
+    if os.path.exists(desc_file):
+        with open(desc_file) as fh:
+            optdescs = yaml.load(fh)
 
     # Extract all the options
     options = []
@@ -89,6 +100,11 @@ def MkMan(applets, applet, output):
                 flags += [option[0].rstrip(',')]
                 option.pop(0)
 
+            optdesc = None
+            for x in flags:
+                if x.lstrip('-') in optdescs:
+                    optdesc = optdescs[x.lstrip('-')].strip()
+
             if option[0] in ('<arg>', '[arg]'):
                 flags = [r'\fB%s\fR \fI%s\fR' % (x, option[0]) for x in flags]
                 option.pop(0)
@@ -98,10 +114,13 @@ def MkMan(applets, applet, output):
             assert option[0] == '*', 'help line for %s is broken: %r' % (applet, option)
             option.pop(0)
 
+            if not optdesc:
+                optdesc = ' '.join(option).rstrip('.') + '.'
+
             options += [
                 '.TP',
                 ', '.join(flags).replace('-', r'\-'),
-                ' '.join(option),
+                optdesc,
             ]
         break
 


^ permalink raw reply related	[relevance 99%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2018-04-01 13:47 99% [gentoo-commits] proj/portage-utils:master commit in: man/ Fabian Groffen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox