Giter Site home page Giter Site logo

nagesh4193 / argparse-manpage Goto Github PK

View Code? Open in Web Editor NEW

This project forked from praiskup/argparse-manpage

0.0 0.0 0.0 89 KB

Automatically build man-pages for your Python project

License: Apache License 2.0

Python 85.14% Shell 2.10% Makefile 3.12% Smarty 9.65%

argparse-manpage's Introduction

Automatically build manpage from argparse

This repository contains a command for setup.py to build a manpage for your project.

The initial code was developed for CrunchyFrog, a database query tool for Gnome. The frog is now retired and RunSQLRun is it's successor. Then, the build_manpage command was developed in andialbrecht and edited slightly in gabrielegiammatteo. There's even an old blog post about this command.

Since some useful work has been done in python pull request, the code from the PR has been used here too (with a belief that upstream merges this, some day). Then, some more flexibility has been added.

The build_manpages command for setup.py is on it's own way (right here). The old usage from build_manpage is still supported, documented in old documentation.

Usage

Download ./build_manpages directory and place it somewhere where Python can find it. E.g. by:

git submodule add --name build_manpages https://github.com/praiskup/build_manpages
git submodule update --init

In your setup.py add:

[...]
from build_manpages import build_manpages, get_build_py_cmd, get_install_cmd
from setuptools.command.build_py import build_py
from setuptools.command.install import install

setup(
  [...]
  cmdclass={
      'build_manpages': build_manpages,
      # Re-define build_py and install commands so the manual pages
      # are automatically re-generated and installed (optional)
      'build_py': get_build_py_cmd(build_py),
      'install': get_install_cmd(install),
  }
)

In your setup.cfg add:

[build_manpages]
manpages =
    man/foo.1:object=parser:pyfile=bin/foo.py
    man/bar.1:function=get_parser:pyfile=bin/bar

where each line means one manual page to be generated. The format of the lines is colon separated set of arguments/options. The first argument determines the filename of the generated manual page. Then follows a list of options of format option=value; and are about "how to get the particular argparse object".

Supported values are:

  • pyfile - what python file the argparse object resides in
  • object - the name of arparse object in "pyfile" to import
  • function - the name of function in pyfile to call to get the argparse object

Then run setup.py build_manpages to build a manpages for your project. Also, if you used get_build_py helper, setup.py build then transitively builds the manual pages.

Command-line usage

You can also use argparse-manpage command on a command-line. Example:

argparse-manpage --pyfile ./pythonfile --function get_parser --author me --author-email [email protected] --project-name myproject --url https://pagure.io/myproject > cool-manpage.1

This reads ./pythonfile and executes function get_parser from it. The function should be programmed to return an ArgumentParser instance which is then used together with the other info supplied on the command-line to generate the man page.

See argparse-manpage --help for full info.

License

This work is released under the terms of the Apache License v2.0. See LICENSE for details.

argparse-manpage's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.