#!/usr/bin/env ruby # encoding: utf-8 =begin BINMAN 1 "2012-02-02" "3.0.1" ============================= NAME ---- binman - UNIX man pages for Ruby `bin/` scripts SYNOPSIS -------- `binman` [*OPTION*]... *COMMAND* DESCRIPTION ----------- [binman] produces UNIX man pages for your Ruby `bin/` scripts. It can extract their leading comment headers (defined below), convert them from markdown(7) into roff(7) using [md2man], and display them using man(1). ### Leading Comment Headers A leading comment header can be one of the following two things: 1. A contiguous sequence of single-line comments starting at the beginning of the file (after shebang and encoding comments plus optional blank lines) and ending at the first single blank line. 2. First embedded document delimited by `=begin` and `=end` lines. ### Markdown Processing Divergence Although your leading comment headers are written in markdown(7), `binman conv` introduces the following additions to markdown(7) syntax via [md2man]: * There can be at most one top-level heading (H1). It is emitted as `.TH` in the roff(7) output, specifying the UNIX man page's header and footer. * Paragraphs whose lines are all uniformly indented by two spaces are considered to be "indented paragraphs". They are unindented accordingly before emission as `.IP` in the roff(7) output. * Paragraphs whose subsequent lines (all except the first) are uniformly indented by two spaces are considered to be a "tagged paragraphs". They are unindented accordingly before emission as `.TP` in the roff(7) output. ### Markdown Processing Extensions The following [Redcarpet2] extensions for markdown(7) are enabled: * tables * autolink * superscript * strikethrough * no_intra_emphasis * fenced_code_blocks OPTIONS ------- `-h`, `--help` Display this help manual using man(1). COMMANDS -------- `show` [*FILE*] Use man(1) to display the roff(7) conversion of the leading comment header extracted from the given *FILE* or STDIN. `load` [*FILE*] Print the leading comment header extracted from the given *FILE* or STDIN. `dump` [*FILE*] Print the roff(7) conversion of the leading comment header extracted from the given *FILE* or STDIN. `conv` [*FILE*] Print the roff(7) conversion of the markdown(7) document read from the given *FILE* or STDIN. SEE ALSO -------- man(1), roff(7), markdown(7) [binman]: https://github.com/sunaku/binman [md2man]: https://github.com/sunaku/md2man [Redcarpet2]: https://github.com/tanoku/redcarpet =end ========================================================================= require 'binman' BinMan.help command, source = ARGV source ||= STDIN case command when 'show' BinMan.show source when 'load', 'dump', 'conv' puts BinMan.send(command, source) else warn 'binman: bad command; try --help' exit! end