hatc...page(3)
β¨ NAME β¨
hatch-argparse-manpage β bestie, it's a Hatch build hook plugin that generates manual pages for you. Like, it just does it. Automatically. Iconic behavior honestly π
πΈ SYNOPSIS πΈ
okay so first things first, you're gonna go tweak your pyproject.toml like this:
[build-system]
requires = ["hatchling", "hatch-argparse-manpage"]
build-backend = "hatchling.build"
[tool.hatch.build.hooks.argparse-manpage]
manpages = ["MANPAGE-BUILD-CONFIGURATION", ...]
include-url = BOOLEAN
force-command-line = BOOLEAN
that's it that's the whole vibe β¨
π¦ DESCRIPTION π¦
So hatch-argparse-manpage gives you a build hook plugin for Hatch that automatically generates a manual page from an ArgumentParser object. It does this using the Python program argparse-manpage. No cap, it's literally just that π«Ά
π Directory layout π
Heads up bestie, this plugin has rules about where your generated man pages live:
- The directories storing the generated man pages have to be within the project's base directory.
- They cannot be equal to the project's base directory. Not the same thing, periodt.
So like, say your project is named myproject and you've got a src layout of src/myproject β a perfectly acceptable directory to stash a man page in would be man π
π Required key value π
manpagesβ an array of strings that specifies the build configuration for the man pages you want generated. You gotta use the format thatargparse-manpagerequires. That's the whole thing, iykyk.
β Optional key values β
include-urlβ a Boolean that says whether to show the project URL in the generated man page. The default istrue. See below, bestie πforce-command-lineβ a Boolean that says whether to invokeargparse-manpagefrom the command line, or by calling it as a Python object. The default isfalse. See below again π
π§ Project URLs π§
If a URL isn't specified in the man page's build configuration, this plugin goes and extracts it from the [project.urls] section of your project's pyproject.toml, in this order:
- If a homepage URL is specified, then it is used. Done. Case closed.
- If not, if only one URL is specified, it is used.
argparse-manpage uses a project URL to generate a man section that explains where to download the program the page is being built for. And if you're like "girl I do not want that" β see above to suppress inclusion of the URL in the man page π
π Argparse-manpage invocation π
By default, this plugin calls argparse-manpage's Python code directly. But if that generates an exception, this plugin will attempt to call argparse-manpage as a command line program instead. It's giving "plan b energy" honestly. See above if you wanna override this behaviour using the optional key force-command-line β¨
π Cleaning output files π
This plugin includes logic to remove the files it outputs, using hatch's clean hook. And it's not just individual files β any output directories it created will also be removed, as long as those directories don't contain files created by something other than this plugin. Like, it's not gonna delete your whole life, just its own mess π§Ή
π₯ EXAMPLES π₯
Generate three manpages:
[tool.hatch.build.hooks.argparse-manpage]
manpages = [
"man/foo.1:object=parser:pyfile=bin/foo.py",
"man/bar.1:function=get_parser:pyfile=bin/bar",
"man/baz.1:function=get_parser:pyfile=bin/bar:prog=baz",
]
Suppress the inclusion of the project URL:
[tool.hatch.build.hooks.argparse-manpage]
include-url = false
manpages = [
"man/foo.1:object=parser:pyfile=bin/foo.py",
]
Force invoking argparse-manpage via the command line:
[tool.hatch.build.hooks.argparse-manpage]
force-command-line = true
manpages = [
"man/foo.1:object=parser:pyfile=bin/foo.py",
]
π HISTORY π
Okay so story time π
This plugin is not an official project of argparse-manpage. Nope. Instead, it acts as a wrapper around it, making it available to Hatch users. And because of that, if argparse-manpage changes in ways incompatible with this plugin, this plugin may not function as expected. That's just the tea π΅
This plugin has been tested against argparse-manpage version 4.5. π
The code to parse the pyproject.toml config in this plugin overlaps with the code in argparse-manpage, but it differs in that it is rewritten to conform to contemporary Python stylistic conventions, as well as the specific needs of this plugin. A glow-up, basically β¨
π SEE ALSO π
argparse-manpage
π AUTHOR π
Damon Lynch damonlynch@gmail.com
π COPYRIGHT π
Copyright 2024 Damon Lynch.
and that's the whole page bestie π«Ά this was hatc...page(3) β section 3 of the manuals, mwah, go generate some gorgeous man pages πβ¨π
π¦ where this page comes from
- ubuntu resolute: python3-hatch-argparse-manpage 1.0.1-0ubuntu1 Β· GPL-3.0-or-later
- ubuntu stonking: python3-hatch-argparse-manpage 1.0.1-0ubuntu1 Β· GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms