binman 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/HISTORY.markdown +25 -0
- data/README.markdown +6 -1
- data/bin/binman +71 -64
- data/binman.gemspec +4 -0
- data/lib/binman.rb +20 -5
- data/lib/binman/renderer.rb +3 -0
- data/lib/binman/version.rb +1 -1
- data/man/man1/binman.1 +15 -12
- metadata +3 -3
data/HISTORY.markdown
CHANGED
@@ -1,3 +1,28 @@
|
|
1
|
+
------------------------------------------------------------------------------
|
2
|
+
Version 0.1.1 (2011-10-13)
|
3
|
+
------------------------------------------------------------------------------
|
4
|
+
|
5
|
+
New features:
|
6
|
+
|
7
|
+
* `BinMan.read()` now supports embedded document (=begin/=end) comments also.
|
8
|
+
See binman(1) for the new, complete description of leading comment headers.
|
9
|
+
|
10
|
+
Bug fixes:
|
11
|
+
|
12
|
+
* Ignore encoding comment line after shebang line.
|
13
|
+
|
14
|
+
* roff: fix first paragraphs inside list items.
|
15
|
+
|
16
|
+
Housekeeping:
|
17
|
+
|
18
|
+
* gemspec: build man page files before building gem.
|
19
|
+
|
20
|
+
* binman: raise error and suggest --help option.
|
21
|
+
|
22
|
+
* README: add link to example of binman markdown.
|
23
|
+
|
24
|
+
* README: add obligatory screenshot! >:-)
|
25
|
+
|
1
26
|
------------------------------------------------------------------------------
|
2
27
|
Version 0.0.1 (2011-10-12)
|
3
28
|
------------------------------------------------------------------------------
|
data/README.markdown
CHANGED
@@ -4,8 +4,13 @@ binman - UNIX man pages for Ruby bin/ scripts
|
|
4
4
|
[binman] produces UNIX man pages for your Ruby `bin/` scripts using
|
5
5
|
markdown(7), roff(7), [Redcarpet2] for conversion thereof, and man(1).
|
6
6
|
|
7
|
+

|
8
|
+
|
9
|
+
Here is [an example bin/ script][binman-bin] to help get you started!
|
10
|
+
|
7
11
|
[binman]: https://github.com/sunaku/binman
|
8
12
|
[binman-api]: http://rdoc.info/github/sunaku/binman
|
13
|
+
[binman-bin]: https://raw.github.com/sunaku/binman/master/bin/binman
|
9
14
|
[Redcarpet2]: https://github.com/tanoku/redcarpet
|
10
15
|
|
11
16
|
------------------------------------------------------------------------------
|
@@ -16,7 +21,7 @@ Features
|
|
16
21
|
|
17
22
|
* Individual extraction, conversion, and display commands.
|
18
23
|
|
19
|
-
* Implemented in
|
24
|
+
* Implemented in roughly 100 lines of pure Ruby code! :-)
|
20
25
|
|
21
26
|
------------------------------------------------------------------------------
|
22
27
|
Prerequisites
|
data/bin/binman
CHANGED
@@ -1,67 +1,74 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
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
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
2
|
+
# encoding: utf-8
|
3
|
+
=begin
|
4
|
+
|
5
|
+
BINMAN 1 "2011-10-13" "0.1.1" "Ruby User Manuals"
|
6
|
+
=================================================
|
7
|
+
|
8
|
+
NAME
|
9
|
+
----
|
10
|
+
|
11
|
+
binman - UNIX man pages for Ruby `bin/` scripts
|
12
|
+
|
13
|
+
SYNOPSIS
|
14
|
+
--------
|
15
|
+
|
16
|
+
`binman` [*OPTION*]... *COMMAND*
|
17
|
+
|
18
|
+
DESCRIPTION
|
19
|
+
-----------
|
20
|
+
|
21
|
+
[binman] produces UNIX man pages for your Ruby `bin/` scripts. It can extract
|
22
|
+
their leading comment headers (defined below), convert them from markdown(7)
|
23
|
+
into roff(7) using [Redcarpet2], and display them using man(1).
|
24
|
+
|
25
|
+
### Leading Comment Headers
|
26
|
+
|
27
|
+
1. A contiguous sequence of single-line comments starting at the
|
28
|
+
beginning of the file (after shebang and encoding comments plus
|
29
|
+
optional blank lines) and ending at the first single blank line.
|
30
|
+
|
31
|
+
2. First embedded document delimited by `=begin` and `=end` lines.
|
32
|
+
|
33
|
+
### Markdown Processing Extensions
|
34
|
+
|
35
|
+
Although your leading comment headers are written in markdown(7), `binman`
|
36
|
+
introduces the following additional conventions to simplify common tasks:
|
37
|
+
|
38
|
+
1. Paragraphs beginning with bold/italic and followed by at least
|
39
|
+
one two-space indented line are considered to be definitions.
|
40
|
+
The first line of such a paragraph is the term being defined and
|
41
|
+
the subsequent two-space indented lines are the definition body.
|
42
|
+
|
43
|
+
OPTIONS
|
44
|
+
-------
|
45
|
+
|
46
|
+
`-h`, `--help`
|
47
|
+
Display this help manual using man(1).
|
48
|
+
|
49
|
+
COMMANDS
|
50
|
+
--------
|
51
|
+
|
52
|
+
`read` [*FILE*]
|
53
|
+
Print the leading comment header extracted from the given *FILE* or stdin.
|
54
|
+
|
55
|
+
`dump` [*FILE*]
|
56
|
+
Print the roff(7) conversion of the leading comment header extracted from
|
57
|
+
the given *FILE* or stdin.
|
58
|
+
|
59
|
+
`show` [*FILE*]
|
60
|
+
Use man(1) to display the roff(7) conversion of the leading comment header
|
61
|
+
extracted from the given *FILE* or stdin.
|
62
|
+
|
63
|
+
SEE ALSO
|
64
|
+
--------
|
65
|
+
|
66
|
+
man(1), roff(7), markdown(7)
|
67
|
+
|
68
|
+
[binman]: https://github.com/sunaku/binman
|
69
|
+
[Redcarpet2]: https://github.com/tanoku/redcarpet
|
70
|
+
|
71
|
+
=end =========================================================================
|
65
72
|
|
66
73
|
require 'binman'
|
67
74
|
BinMan.help
|
@@ -73,5 +80,5 @@ case command
|
|
73
80
|
when 'read' then puts BinMan.read(file)
|
74
81
|
when 'dump' then puts BinMan.dump(BinMan.read(file))
|
75
82
|
when 'show' then BinMan.show(file)
|
76
|
-
else
|
83
|
+
else raise ArgumentError, 'bad command; try --help'
|
77
84
|
end
|
data/binman.gemspec
CHANGED
data/lib/binman.rb
CHANGED
@@ -4,11 +4,16 @@ module BinMan
|
|
4
4
|
extend self
|
5
5
|
|
6
6
|
##
|
7
|
-
# Returns content of leading comment header (
|
8
|
-
#
|
9
|
-
# single blank line) from given source (IO, file name, or string).
|
7
|
+
# Returns content of leading comment header (which can be one of the
|
8
|
+
# following two choices) from given source (IO, file name, or string).
|
10
9
|
#
|
11
|
-
#
|
10
|
+
# (1) A contiguous sequence of single-line comments starting at the
|
11
|
+
# beginning of the file (after shebang and encoding comments plus
|
12
|
+
# optional blank lines) and ending at the first single blank line.
|
13
|
+
#
|
14
|
+
# (2) First embedded document delimited by `=begin` and `=end` lines.
|
15
|
+
#
|
16
|
+
# Comment markers and shebang/encoding comments are omitted from result.
|
12
17
|
#
|
13
18
|
def read source=nil
|
14
19
|
source = source.read if source.respond_to? :read
|
@@ -19,7 +24,17 @@ module BinMan
|
|
19
24
|
source = File.read(source) if File.exist? source
|
20
25
|
|
21
26
|
string = source.to_s
|
22
|
-
|
27
|
+
|
28
|
+
# strip shebang and encoding comments
|
29
|
+
[/\A#!.+$/, /\A#.*coding:.+$/].each do |comment|
|
30
|
+
string = $'.lstrip if string =~ comment
|
31
|
+
end
|
32
|
+
|
33
|
+
if string =~ /\A#/
|
34
|
+
string.split(/^\s*$/, 2).first.gsub(/^# ?/, '')
|
35
|
+
else
|
36
|
+
string[/^=begin\b.*?$(.*?)^=end\b.*?$/m, 1]
|
37
|
+
end.strip
|
23
38
|
end
|
24
39
|
|
25
40
|
##
|
data/lib/binman/renderer.rb
CHANGED
@@ -29,6 +29,9 @@ module BinMan
|
|
29
29
|
# squeeze blank lines to prevent double-spaced output
|
30
30
|
gsub(/^\n/, '').
|
31
31
|
|
32
|
+
# first paragraphs inside list items
|
33
|
+
gsub(/^(\.IP.*)\n\.PP/, '\1').
|
34
|
+
|
32
35
|
# paragraphs beginning with bold/italic and followed by
|
33
36
|
# at least one definition-indented line are definitions
|
34
37
|
gsub(/^\.PP(?=\n\\f.+\n#{DEFINITION_INDENT}\S)/, '.TP').
|
data/lib/binman/version.rb
CHANGED
data/man/man1/binman.1
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
.TH BINMAN 1 "2011-
|
1
|
+
.TH BINMAN 1 "2011-10-13" "0.1.1" "Ruby User Manuals"
|
2
2
|
.SH NAME
|
3
3
|
.PP
|
4
4
|
binman \- UNIX man pages for Ruby \fBbin/\fP scripts
|
@@ -7,18 +7,21 @@ binman \- UNIX man pages for Ruby \fBbin/\fP scripts
|
|
7
7
|
\fBbinman\fP [\fIOPTION\fP]... \fICOMMAND\fP
|
8
8
|
.SH DESCRIPTION
|
9
9
|
.PP
|
10
|
-
\fBbinman\fP \fIhttps://github.com/sunaku/binman\fP produces UNIX man pages for your Ruby \fBbin/\fP scripts
|
11
|
-
their leading comment
|
12
|
-
|
13
|
-
|
14
|
-
.BR markdown (7)
|
15
|
-
to
|
10
|
+
\fBbinman\fP \fIhttps://github.com/sunaku/binman\fP produces UNIX man pages for your Ruby \fBbin/\fP scripts. It can extract
|
11
|
+
their leading comment headers (defined below), convert them from
|
12
|
+
.BR markdown (7)
|
13
|
+
into
|
16
14
|
.BR roff (7)
|
17
|
-
using \fBRedcarpet2\fP \fIhttps://github.com/tanoku/redcarpet\fP
|
18
|
-
display using
|
15
|
+
using \fBRedcarpet2\fP \fIhttps://github.com/tanoku/redcarpet\fP, and display them using
|
19
16
|
.BR man (1).
|
20
|
-
.
|
21
|
-
|
17
|
+
.SS Leading Comment Headers
|
18
|
+
.nr step 0 1
|
19
|
+
.IP \n+[step]
|
20
|
+
A contiguous sequence of single-line comments starting at the
|
21
|
+
beginning of the file (after shebang and encoding comments plus
|
22
|
+
optional blank lines) and ending at the first single blank line.
|
23
|
+
.IP \n+[step]
|
24
|
+
First embedded document delimited by \fB=begin\fP and \fB=end\fP lines.
|
22
25
|
.SS Markdown Processing Extensions
|
23
26
|
.PP
|
24
27
|
Although your leading comment headers are written in
|
@@ -34,7 +37,7 @@ the subsequent two-space indented lines are the definition body.
|
|
34
37
|
.SH OPTIONS
|
35
38
|
.TP
|
36
39
|
\fB-h\fP, \fB--help\fP
|
37
|
-
Display this manual
|
40
|
+
Display this help manual using
|
38
41
|
.BR man (1).
|
39
42
|
.SH COMMANDS
|
40
43
|
.TP
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: binman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-10-13 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: redcarpet
|
16
|
-
requirement: &
|
16
|
+
requirement: &19851600 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 2.0.0b5
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *19851600
|
25
25
|
description: ''
|
26
26
|
email:
|
27
27
|
- sunaku@gmail.com
|