binman 0.0.1 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
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
+ ![Obligatory Screen-shot of binman(1) in action!](http://ompldr.org/vYXNlNg)
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 less than 100 lines of pure Ruby code! :-)
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
- # BINMAN 1 "2011-10-12" "0.0.1" "Ruby User Manuals"
4
- # =================================================
5
- #
6
- # NAME
7
- # ----
8
- #
9
- # binman - UNIX man pages for Ruby `bin/` scripts
10
- #
11
- # SYNOPSIS
12
- # --------
13
- #
14
- # `binman` [*OPTION*]... *COMMAND*
15
- #
16
- # DESCRIPTION
17
- # -----------
18
- #
19
- # [binman] produces UNIX man pages for your Ruby `bin/` scripts by extracting
20
- # their leading comment header (a contiguous sequence of single-line comments
21
- # starting at beginning of file and ending at first single blank line) and
22
- # then converting them from markdown(7) to roff(7) using [Redcarpet2] for
23
- # display using man(1).
24
- #
25
- # See for more information and resources.
26
- #
27
- # ### Markdown Processing Extensions
28
- #
29
- # Although your leading comment headers are written in markdown(7), `binman`
30
- # introduces the following additional conventions to simplify common tasks:
31
- #
32
- # 1. Paragraphs beginning with bold/italic and followed by at least
33
- # one two-space indented line are considered to be definitions.
34
- # The first line of such a paragraph is the term being defined and
35
- # the subsequent two-space indented lines are the definition body.
36
- #
37
- # OPTIONS
38
- # -------
39
- #
40
- # `-h`, `--help`
41
- # Display this manual page using man(1).
42
- #
43
- # COMMANDS
44
- # --------
45
- #
46
- # `read` [*FILE*]
47
- # Print the leading comment header extracted from the given *FILE* or stdin.
48
- #
49
- # `dump` [*FILE*]
50
- # Print the roff(7) conversion of the leading comment header extracted from
51
- # the given *FILE* or stdin.
52
- #
53
- # `show` [*FILE*]
54
- # Use man(1) to display the roff(7) conversion of the leading comment header
55
- # extracted from the given *FILE* or stdin.
56
- #
57
- # SEE ALSO
58
- # --------
59
- #
60
- # man(1), roff(7), markdown(7)
61
- #
62
- # [binman]: https://github.com/sunaku/binman
63
- # [Redcarpet2]: https://github.com/tanoku/redcarpet
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 warn "binman: unknown command: #{command}"; exit!
83
+ else raise ArgumentError, 'bad command; try --help'
77
84
  end
data/binman.gemspec CHANGED
@@ -2,6 +2,10 @@
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
3
  require "binman/version"
4
4
 
5
+ # pre-build man page files
6
+ require 'binman/rake_tasks'
7
+ Rake::Task[:binman].invoke
8
+
5
9
  Gem::Specification.new do |s|
6
10
  s.name = "binman"
7
11
  s.version = BinMan::VERSION
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 (a contiguous sequence of
8
- # single-line comments starting at beginning of file and ending at first
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
- # Comment markers and shebang line (if any) are removed from result.
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
- string.split(/^\s*$/, 2).first.sub(/\A#!.+$/, '').gsub(/^# ?/, '').strip
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
  ##
@@ -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').
@@ -1,3 +1,3 @@
1
1
  module BinMan
2
- VERSION = "0.0.1"
2
+ VERSION = "0.1.1"
3
3
  end
data/man/man1/binman.1 CHANGED
@@ -1,4 +1,4 @@
1
- .TH BINMAN 1 "2011-01-12" "0.0.1" "Ruby User Manuals"
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 by extracting
11
- their leading comment header (a contiguous sequence of single-line comments
12
- starting at beginning of file and ending at first single blank line) and
13
- then converting them from
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 for
18
- display using
15
+ using \fBRedcarpet2\fP \fIhttps://github.com/tanoku/redcarpet\fP, and display them using
19
16
  .BR man (1).
20
- .PP
21
- See for more information and resources.
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 page using
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.0.1
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: &14739920 !ruby/object:Gem::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: *14739920
24
+ version_requirements: *19851600
25
25
  description: ''
26
26
  email:
27
27
  - sunaku@gmail.com