|
1 | 1 | #!/usr/bin/env python3 |
| 2 | +""" |
| 3 | +Python script to generate a man page for the command `fastfetch`. |
| 4 | +The man content will be printed to stdout so you will need to |
| 5 | +pipe it to a file if you want to save it. |
| 6 | +The command options will be generated using a JSON file. |
| 7 | +For the format of the JSON file, see https://github.com/fastfetch-cli/fastfetch/blob/dev/src/data/help.json |
| 8 | +""" |
| 9 | + |
2 | 10 | from json import load |
3 | 11 | from datetime import date |
4 | 12 |
|
5 | | - |
6 | 13 | ###### Parameters ###### |
7 | 14 |
|
8 | | -# path to the help.json file |
| 15 | +# path to the JSON option file |
9 | 16 | pathToHelpFile = "../src/data/help.json" |
10 | 17 | # man page section |
11 | 18 | manSection = 1 |
|
18 | 25 |
|
19 | 26 |
|
20 | 27 | # text displayed in the "NAME" section |
21 | | -nameSection = "fastfetch - a neofetch-like tool for fetching system \ |
| 28 | +nameSection = "\ |
| 29 | +fastfetch - a neofetch-like tool for fetching system \ |
22 | 30 | information and displaying them in a pretty way" |
23 | 31 |
|
24 | 32 | # text displayed in the "DESCRIPTION" section |
25 | | -descriptionSection = "A maintained, feature-rich and performance \ |
| 33 | +descriptionSection = "\ |
| 34 | +A maintained, feature-rich and performance \ |
26 | 35 | oriented, neofetch like system information tool." |
27 | 36 |
|
| 37 | +# text displayed at the beginning of the "OPTIONS" section |
| 38 | +optionSection = "\ |
| 39 | +Parsing is not case sensitive. E.g. \\fB--lib-PCI\\fR \ |
| 40 | +is equal to \\fB--Lib-Pci\\fR. \ |
| 41 | + \n\n\ |
| 42 | +If a value is between square brakets, it is optional. \ |
| 43 | +An optional boolean value defaults to true if not \ |
| 44 | +specified. \ |
| 45 | + \n\n\ |
| 46 | +More detailed help messages for each options can be \ |
| 47 | +printed with \\fB-h <option_without_dash_prefix>\\fR. \ |
| 48 | + \n\n\ |
| 49 | +All options can be made permanent with command \ |
| 50 | +\\fBfastfetch <options> --gen-config\\fR. \ |
| 51 | +" |
| 52 | + |
28 | 53 | # text displayed in the "BUGS" section |
29 | | -bugSection = "Please report bugs to : https://github.com/fastfetch-cli/fastfetch/issues" |
| 54 | +bugSection = "Please report bugs to : \ |
| 55 | +https://github.com/fastfetch-cli/fastfetch/issues" |
30 | 56 |
|
31 | 57 |
|
32 | 58 | ###### Text Decorations Tags ###### |
|
45 | 71 |
|
46 | 72 | ### optional arguments tags ### |
47 | 73 |
|
48 | | -# if an optional argument is displayed as [?optArg] (with "optArg" underlined), this value should be f"[?{startUnderline}" |
| 74 | +# if an optional argument is displayed as [?optArg] (with "optArg" underlined) |
| 75 | +# this value should be f"[?{startUnderline}" |
49 | 76 | startOptionalArgument = f"[{startItalic}?" |
50 | | -# if an optional argument is displayed as [?optArg] (with "optArg underlined"), this value should be f"{endUnderline}]" |
| 77 | +# if an optional argument is displayed as [?optArg] (with "optArg underlined") |
| 78 | +# this value should be f"{endUnderline}]" |
51 | 79 | endOptionalArgument = f"{endItalic}]" |
52 | 80 |
|
53 | | -# mandatory arguments tags |
54 | | -startMandatoryArgument = "" |
55 | | -endMandatoryArgument = "" |
| 81 | +### mandatory arguments tags ### |
| 82 | +startMandatoryArgument = f"{startUnderline}" |
| 83 | +endMandatoryArgument = f"{endUnderline}" |
56 | 84 |
|
57 | 85 | def generateManPage(): |
58 | 86 |
|
@@ -98,6 +126,8 @@ def generateManPage(): |
98 | 126 | ###### Options ###### |
99 | 127 |
|
100 | 128 | print(".SH OPTIONS") |
| 129 | + print(optionSection) |
| 130 | + print() |
101 | 131 |
|
102 | 132 | # loop through every options sections |
103 | 133 | for key, value in helpFileData.items(): |
@@ -140,7 +170,10 @@ def generateManPage(): |
140 | 170 | # description |
141 | 171 | print(f"\n {option['desc']} \n") |
142 | 172 |
|
| 173 | + ###### Bugs ###### |
143 | 174 |
|
| 175 | + print(".SH BUGS") |
| 176 | + print(bugSection) |
144 | 177 |
|
145 | 178 |
|
146 | 179 |
|
|
0 commit comments