1 |
commit: 684a8118721c28690b74fbdc3e74b351e799ffd8 |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Apr 1 12:39:17 2018 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Apr 1 12:39:17 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=684a8118 |
7 |
|
8 |
man/mkman: add header, allow argument description override |
9 |
|
10 |
man/mkman.py | 29 ++++++++++++++++++++++++----- |
11 |
1 file changed, 24 insertions(+), 5 deletions(-) |
12 |
|
13 |
diff --git a/man/mkman.py b/man/mkman.py |
14 |
index 0751b92..8444311 100755 |
15 |
--- a/man/mkman.py |
16 |
+++ b/man/mkman.py |
17 |
@@ -1,4 +1,4 @@ |
18 |
-#!/usr/bin/python |
19 |
+#!/usr/bin/env python |
20 |
# -*- coding: utf-8 -*- |
21 |
|
22 |
"""Generate man pages for the q applets""" |
23 |
@@ -14,6 +14,7 @@ import os |
24 |
import re |
25 |
import subprocess |
26 |
import sys |
27 |
+import yaml |
28 |
|
29 |
|
30 |
MKMAN_DIR = os.path.realpath(os.path.join(__file__, '..')) |
31 |
@@ -33,7 +34,8 @@ COMMON_AUTHORS = [ |
32 |
'Ned Ludd <solar@g.o>', |
33 |
'Mike Frysinger <vapier@g.o>', |
34 |
] |
35 |
-TEMPLATE = r""".TH %(applet)s "1" "%(date)s" "Gentoo Foundation" "%(applet)s" |
36 |
+TEMPLATE = r""".\" generated by mkman.py, please do NOT edit! |
37 |
+.TH %(applet)s "1" "%(date)s" "Gentoo Foundation" "%(applet)s" |
38 |
.SH NAME |
39 |
%(applet)s \- %(short_desc)s |
40 |
.SH SYNOPSIS |
41 |
@@ -47,7 +49,8 @@ TEMPLATE = r""".TH %(applet)s "1" "%(date)s" "Gentoo Foundation" "%(applet)s" |
42 |
.SH "REPORTING BUGS" |
43 |
Please report bugs via http://bugs.gentoo.org/ |
44 |
.br |
45 |
-Product: Portage Development; Component: Tools |
46 |
+Product: Portage Development; Component: Tools, Assignee: |
47 |
+portage-utils@g.o |
48 |
.SH AUTHORS |
49 |
.nf |
50 |
%(authors)s |
51 |
@@ -74,7 +77,15 @@ def MkMan(applets, applet, output): |
52 |
description = '' |
53 |
desc_file = os.path.join(FRAGS_DIR, '%s.desc' % applet) |
54 |
if os.path.exists(desc_file): |
55 |
- description = open(desc_file).read().rstrip() |
56 |
+ fh = open(desc_file) |
57 |
+ description = fh.read().rstrip() |
58 |
+ fh.close() |
59 |
+ |
60 |
+ optdescs = [] |
61 |
+ desc_file = os.path.join(FRAGS_DIR, '%s.optdesc.yaml' % applet) |
62 |
+ if os.path.exists(desc_file): |
63 |
+ with open(desc_file) as fh: |
64 |
+ optdescs = yaml.load(fh) |
65 |
|
66 |
# Extract all the options |
67 |
options = [] |
68 |
@@ -89,6 +100,11 @@ def MkMan(applets, applet, output): |
69 |
flags += [option[0].rstrip(',')] |
70 |
option.pop(0) |
71 |
|
72 |
+ optdesc = None |
73 |
+ for x in flags: |
74 |
+ if x.lstrip('-') in optdescs: |
75 |
+ optdesc = optdescs[x.lstrip('-')].strip() |
76 |
+ |
77 |
if option[0] in ('<arg>', '[arg]'): |
78 |
flags = [r'\fB%s\fR \fI%s\fR' % (x, option[0]) for x in flags] |
79 |
option.pop(0) |
80 |
@@ -98,10 +114,13 @@ def MkMan(applets, applet, output): |
81 |
assert option[0] == '*', 'help line for %s is broken: %r' % (applet, option) |
82 |
option.pop(0) |
83 |
|
84 |
+ if not optdesc: |
85 |
+ optdesc = ' '.join(option).rstrip('.') + '.' |
86 |
+ |
87 |
options += [ |
88 |
'.TP', |
89 |
', '.join(flags).replace('-', r'\-'), |
90 |
- ' '.join(option), |
91 |
+ optdesc, |
92 |
] |
93 |
break |