praiskup / argparse-manpage

Automatically build man-pages for your Python project
Apache License 2.0
40 stars 21 forks source link

argparse-manpage should use value from project-name if prog parameter missing from parser #74

Closed EdwardBetts closed 1 year ago

EdwardBetts commented 1 year ago

Minimal example:

Here is parser.py:

import argparse

def get_parser():
    parser = argparse.ArgumentParser(description="description of command")
    parser.add_argument("arg1", help="help text for arg1", nargs="*")
    return parser

The parser has a "description" parameter, but no "prog" parameter.

This is what happens when I run argparse-manpage.

$ argparse-manpage --project-name foobar --pyfile parser.py --function get_parser
.TH argparse-manpage "1" Manual
.SH NAME
argparse-manpage
.SH SYNOPSIS
.B argparse-manpage
[-h] [arg1 ...]
.SH DESCRIPTION
description of command
.SH OPTIONS
.TP
\fBarg1\fR
help text for arg1

.SH AUTHORS
.B foobar
was written by <<UNSET \-\-author OPTION>> <<<UNSET \-\-author_email OPTION>>>.
.SH DISTRIBUTION
The latest version of foobar may be downloaded from
.UR <<UNSET \-\-url OPTION>>
.UE
$ 

In the man page output the name should be "foobar" as specified on the command line, not "argparse-manpage".

praiskup commented 1 year ago

Thank you for the well-formated issue!

Seems like you have some old version of argparse-manpage, can you please try the v4 with the --prog option? The --project-name is name of the project (e.g. GNU coreutils), while the --prog is the name of the program/script (e.g. ls, cp, timeout, or sleep).

EdwardBetts commented 1 year ago

Sorry, I should've checked for a new version. I'm using 1.2.2, which is the latest version in Debian unstable.

I'll try and get the version 4 into Debian unstable.

EdwardBetts commented 1 year ago

You're right this is fixed in newer versions.