File: generate_man.py

package info (click to toggle)
python-pipx 1.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,776 kB
  • sloc: python: 9,653; makefile: 17; sh: 7
file content (44 lines) | stat: -rwxr-xr-x 1,037 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python3

import os.path
import sys
import textwrap
from typing import cast

from build_manpages.manpage import Manpage  # type: ignore[import-not-found]

from pipx.main import get_command_parser


def main():
    sys.argv[0] = "pipx"
    parser, _ = get_command_parser()
    parser.man_short_description = cast("str", parser.description).splitlines()[1]  # type: ignore[attr-defined]

    manpage = Manpage(parser)
    body = str(manpage)

    # Avoid hardcoding build paths in manpages (and improve readability)
    body = body.replace(os.path.expanduser("~").replace("-", "\\-"), "~")

    # Add a credit section
    body += textwrap.dedent(
        """
        .SH AUTHORS
        .IR pipx (1)
        was written by Chad Smith and contributors.
        The project can be found online at
        .UR https://pipx.pypa.io
        .UE
        .SH SEE ALSO
        .IR pip (1),
        .IR virtualenv (1)
        """
    )

    with open("pipx.1", "w") as f:
        f.write(body)


if __name__ == "__main__":
    main()