ronn-ng 0.7.4 → 0.8.0.SNAPSHOT
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +12 -3
- data/Gemfile +2 -0
- data/INSTALLING.md +100 -0
- data/README.md +19 -1
- data/Rakefile +39 -49
- data/bin/ronn +93 -75
- data/completion/bash/ronn +32 -0
- data/completion/zsh/_ronn +24 -0
- data/config.ru +3 -3
- data/lib/ronn/document.rb +127 -106
- data/lib/ronn/index.rb +8 -9
- data/lib/ronn/roff.rb +153 -76
- data/lib/ronn/server.rb +19 -22
- data/lib/ronn/template.rb +27 -26
- data/lib/ronn/utils.rb +9 -7
- data/lib/ronn.rb +5 -3
- data/man/ronn-format.7 +6 -62
- data/man/ronn.1 +21 -123
- data/man/ronn.1.ronn +8 -0
- data/ronn-ng.gemspec +38 -13
- data/test/angle_bracket_syntax.html +4 -5
- data/test/backticks.html +14 -0
- data/test/backticks.ronn +10 -0
- data/test/basic_document.html +3 -4
- data/test/basic_document.ronn +2 -2
- data/test/circumflexes.ronn +1 -0
- data/test/code_blocks.7.ronn +41 -0
- data/test/contest.rb +56 -54
- data/test/custom_title_document.html +2 -2
- data/test/definition_list_syntax.html +13 -9
- data/test/definition_list_syntax.roff +2 -9
- data/test/definition_list_syntax.ronn +2 -2
- data/test/dots_at_line_start_test.roff +12 -3
- data/test/dots_at_line_start_test.ronn +8 -0
- data/test/ellipses.roff +7 -0
- data/test/ellipses.ronn +7 -0
- data/test/entity_encoding_test.html +13 -14
- data/test/entity_encoding_test.roff +1 -22
- data/test/entity_encoding_test.ronn +1 -1
- data/test/markdown_syntax.html +4 -5
- data/test/markdown_syntax.roff +1 -561
- data/test/middle_paragraph.html +2 -3
- data/test/middle_paragraph.roff +1 -5
- data/test/middle_paragraph.ronn +1 -1
- data/test/missing_spaces.roff +0 -2
- data/test/nested_list.ronn +19 -0
- data/test/nested_list_with_code.html +15 -0
- data/test/nested_list_with_code.roff +11 -0
- data/test/nested_list_with_code.ronn +6 -0
- data/test/page.with.periods.in.name.5.ronn +4 -0
- data/test/pre_block_with_quotes.roff +0 -5
- data/test/section_reference_links.html +2 -3
- data/test/section_reference_links.roff +1 -4
- data/test/section_reference_links.ronn +1 -1
- data/test/tables.ronn +24 -0
- data/test/test_ronn.rb +49 -35
- data/test/test_ronn_document.rb +81 -81
- data/test/test_ronn_index.rb +11 -11
- data/test/titleless_document.html +0 -1
- data/test/underline_spacing_test.roff +0 -8
- metadata +140 -22
- data/INSTALLING +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a366030fa8806e15ab35f18956531bdb60164d10b90b9880886f9eebc6c006c6
|
4
|
+
data.tar.gz: 570e2299757078078f61e102b639e9a81d5fe9a814d5f70edcb06a6497de7a67
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba780963d9c7cf2cce152e9a48cac83640912b60511788c1fc5cd955d186624f9099511c611df6b2db27425afd128d8071be9488fb1d149dd30dc0776ffd9ed5
|
7
|
+
data.tar.gz: d2e9538576d55227277327b514ef9ea96f56151dfcfadddcce12a8e050782628f9ed568f81ef85f8cbd848647ea43444750799fa69ca14aef6290ada149f7daa
|
data/CHANGES
CHANGED
@@ -1,11 +1,20 @@
|
|
1
1
|
Ronn-NG CHANGES
|
2
2
|
===============
|
3
3
|
|
4
|
-
Version 0.
|
5
|
-
|
4
|
+
Version 0.8.0 (???? ??? ??)
|
5
|
+
---------------------------
|
6
6
|
|
7
|
-
*
|
7
|
+
* Added tables support. (apjanke)
|
8
|
+
* Lint & Rubocop fixes. (apjanke)
|
9
|
+
* Added --output-dir option. (apjanke)
|
10
|
+
* Support file names with periods in the name section. (apjanke)
|
11
|
+
* Migrated from Hpricot to Nokogiri. (apjanke)
|
12
|
+
|
13
|
+
Version 0.7.4 (2018 Dec 22)
|
14
|
+
---------------------------
|
8
15
|
|
16
|
+
* Forked Ronn-NG from original Ronn. (apjanke)
|
17
|
+
* Minor bug fixes: #4, #5 (apjanke)
|
9
18
|
|
10
19
|
Original Ronn CHANGES
|
11
20
|
=====================
|
data/Gemfile
ADDED
data/INSTALLING.md
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
Ronn-NG Installation
|
2
|
+
====================
|
3
|
+
|
4
|
+
## Installation Process
|
5
|
+
|
6
|
+
### From a Package Manager
|
7
|
+
|
8
|
+
The best way to install Ronn-NG is with a package manager. This is currently
|
9
|
+
only supported on macOS, with [Homebrew](http://brew.sh). To install with `brew`:
|
10
|
+
|
11
|
+
```
|
12
|
+
brew tap apjanke/ronn-ng
|
13
|
+
brew install --HEAD ronn-ng
|
14
|
+
```
|
15
|
+
|
16
|
+
### From RubyGems
|
17
|
+
|
18
|
+
Ronn-NG is distributed as a gem package, which can be used if you don't have
|
19
|
+
a supported package manager. Install with rubygems:
|
20
|
+
|
21
|
+
```
|
22
|
+
gem install ronn-ng
|
23
|
+
ronn --help
|
24
|
+
```
|
25
|
+
|
26
|
+
Ronn-NG includes completion definitions for bash and zsh, but these are not
|
27
|
+
installed into the system locations as part of the gem. You will need to figure
|
28
|
+
out how to install those into your system to make them available in your shell.
|
29
|
+
|
30
|
+
A decent way to do this is probably to add symlinks to your system shell
|
31
|
+
completion directories pointing at the files in the installed gem.
|
32
|
+
|
33
|
+
In Zsh, you can do something like this:
|
34
|
+
|
35
|
+
```
|
36
|
+
ronn_dist_dir=$(dirname $(dirname $(gem which ronn-ng)))
|
37
|
+
ronn_zsh_dir="$ronn_dist_dir/completion/zsh"
|
38
|
+
ln -s "$ronn_zsh_dir/_ronn" /usr/local/share/zsh/site-functions
|
39
|
+
```
|
40
|
+
|
41
|
+
In Bash, something like this:
|
42
|
+
|
43
|
+
```
|
44
|
+
ronn_dist_dir=$(dirname $(dirname $(gem which ronn-ng)))
|
45
|
+
ronn_bash_dir="$ronn_dist_dir/completion/bash"
|
46
|
+
ln -s "$ronn_bash_dir/ronn" /usr/local/etc/bash_completion.d
|
47
|
+
```
|
48
|
+
|
49
|
+
You will need to redo these steps each time you upgrade `ronn-ng` or install
|
50
|
+
it into a different Ruby environment. Sorry for the inconvenience; this seems
|
51
|
+
to be a limitation of the `gem` installation mechanism.
|
52
|
+
|
53
|
+
If that `gem which` stuff doesn't work for you, you can `gem install gem-path`
|
54
|
+
and use `gem path ronn-ng` instead.
|
55
|
+
|
56
|
+
|
57
|
+
## Building from Source
|
58
|
+
|
59
|
+
Hacking? Install Ronn-NG from source.
|
60
|
+
|
61
|
+
Clone the git repository and put ronn/bin on your PATH:
|
62
|
+
|
63
|
+
```
|
64
|
+
git clone git://github.com/apjanke/ronn-ng
|
65
|
+
PATH=$(pwd)/ronn-ng/bin:$PATH
|
66
|
+
```
|
67
|
+
|
68
|
+
The following gems are required for ronn-ng development:
|
69
|
+
* nokogiri
|
70
|
+
* mustache
|
71
|
+
* rdiscount
|
72
|
+
* rubocop
|
73
|
+
* sinatra
|
74
|
+
* rack
|
75
|
+
* rake
|
76
|
+
* test-unit
|
77
|
+
|
78
|
+
```
|
79
|
+
gem install nokogiri mustache rdiscount rubocop sinatra rack rake test-unit
|
80
|
+
```
|
81
|
+
|
82
|
+
Or install them with bundler using the project's gem definition:
|
83
|
+
|
84
|
+
```
|
85
|
+
bundle install --with development
|
86
|
+
```
|
87
|
+
|
88
|
+
Then you should be able to make changes directly to your cloned repo and have
|
89
|
+
them be reflected in your active `ronn` command.
|
90
|
+
|
91
|
+
## Legacy Versions
|
92
|
+
|
93
|
+
Historical Ronn tarballs available at [the original Ronn repo](http://github.com/rtomayko/ronn/downloads).
|
94
|
+
|
95
|
+
```
|
96
|
+
curl -L http://github.com/rtomayko/ronn/downloads/0.6.6 | tar xvzf -
|
97
|
+
cd rtomayko-r*
|
98
|
+
ruby setup.rb
|
99
|
+
```
|
100
|
+
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Ronn
|
1
|
+
# Ronn-NG
|
2
2
|
|
3
3
|
Ronn-NG is a new, currently-maintained fork of the defunct [original Ronn
|
4
4
|
project](https://github.com/rtomayko/ronn).
|
@@ -26,6 +26,17 @@ ronn capabilities:
|
|
26
26
|
|
27
27
|
As an alternative, you might want to check out [pandoc](http://johnmacfarlane.net/pandoc/) which can also convert markdown into roff manual pages.
|
28
28
|
|
29
|
+
## Installation
|
30
|
+
|
31
|
+
Install with Homebrew on macOS:
|
32
|
+
|
33
|
+
```
|
34
|
+
brew tap apjanke/ronn-ng
|
35
|
+
brew install ronn-ng
|
36
|
+
```
|
37
|
+
|
38
|
+
See [INSTALLING.md][] for details on other systems and installation methods.
|
39
|
+
|
29
40
|
## Examples
|
30
41
|
|
31
42
|
Build roff and HTML output files for one or more input files:
|
@@ -91,6 +102,9 @@ The roff/mandoc/mdoc macro languages are highly extensible, fractured between
|
|
91
102
|
multiple dialects, and include a bunch of device specific stuff irrelevant to
|
92
103
|
modern publishing tools.
|
93
104
|
|
105
|
+
## Requirements
|
106
|
+
|
107
|
+
Ruby 2.3 or newer.
|
94
108
|
|
95
109
|
## Project Management
|
96
110
|
|
@@ -111,3 +125,7 @@ New Ronn-NG material is Copyright (c) 2018 [Andrew Janke](https://apjanke.net)
|
|
111
125
|
and other contributors.
|
112
126
|
|
113
127
|
See the file LICENSE.txt for information of licensing and distribution.
|
128
|
+
|
129
|
+
## Build Status
|
130
|
+
|
131
|
+
![Travis build status](https://travis-ci.com/apjanke/ronn-ng.svg?branch=master)
|
data/Rakefile
CHANGED
@@ -1,41 +1,31 @@
|
|
1
1
|
require 'rake/clean'
|
2
2
|
require 'date'
|
3
3
|
|
4
|
-
task :
|
4
|
+
task default: :test
|
5
5
|
|
6
|
-
ROOTDIR = File.expand_path(
|
7
|
-
LIBDIR
|
8
|
-
BINDIR
|
6
|
+
ROOTDIR = File.expand_path(__dir__).sub(/#{Dir.pwd}(?=\/)/, '.')
|
7
|
+
LIBDIR = "#{ROOTDIR}/lib".freeze
|
8
|
+
BINDIR = "#{ROOTDIR}/bin".freeze
|
9
9
|
|
10
10
|
task :environment do
|
11
|
-
$LOAD_PATH.unshift ROOTDIR
|
12
|
-
$LOAD_PATH.unshift LIBDIR
|
13
|
-
require_library '
|
11
|
+
$LOAD_PATH.unshift ROOTDIR unless $LOAD_PATH.include?(ROOTDIR)
|
12
|
+
$LOAD_PATH.unshift LIBDIR unless $LOAD_PATH.include?(LIBDIR)
|
13
|
+
require_library 'nokogiri'
|
14
14
|
require_library 'rdiscount'
|
15
15
|
ENV['RUBYLIB'] = $LOAD_PATH.join(':')
|
16
16
|
ENV['PATH'] = "#{BINDIR}:#{ENV['PATH']}"
|
17
17
|
end
|
18
18
|
|
19
19
|
desc 'Run tests'
|
20
|
-
task :
|
20
|
+
task test: :environment do
|
21
21
|
$LOAD_PATH.unshift "#{ROOTDIR}/test"
|
22
22
|
Dir['test/test_*.rb'].each { |f| require(f) }
|
23
23
|
end
|
24
24
|
|
25
25
|
desc 'Start the server'
|
26
|
-
task :
|
26
|
+
task server: :environment do
|
27
27
|
if system('type shotgun >/dev/null 2>&1')
|
28
|
-
exec
|
29
|
-
else
|
30
|
-
require 'ronn/server'
|
31
|
-
Ronn::Server.run('man/*.ronn')
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
desc 'Start the server'
|
36
|
-
task :server => :environment do
|
37
|
-
if system('type shotgun >/dev/null 2>&1')
|
38
|
-
exec "shotgun config.ru"
|
28
|
+
exec 'shotgun config.ru'
|
39
29
|
else
|
40
30
|
require 'ronn/server'
|
41
31
|
Ronn::Server.run('man/*.ronn')
|
@@ -43,18 +33,18 @@ task :server => :environment do
|
|
43
33
|
end
|
44
34
|
|
45
35
|
desc 'Build the manual'
|
46
|
-
task :
|
36
|
+
task man: :environment do
|
47
37
|
require 'ronn'
|
48
|
-
ENV['RONN_MANUAL']
|
49
|
-
ENV['RONN_ORGANIZATION'] = "Ronn #{Ronn
|
50
|
-
sh
|
38
|
+
ENV['RONN_MANUAL'] = 'Ronn Manual'
|
39
|
+
ENV['RONN_ORGANIZATION'] = "Ronn-NG #{Ronn.revision}"
|
40
|
+
sh 'ronn -w -s toc -r5 --markdown man/*.ronn'
|
51
41
|
end
|
52
42
|
|
53
|
-
desc 'Publish to
|
54
|
-
task :
|
43
|
+
desc 'Publish to GitHub pages'
|
44
|
+
task pages: :man do
|
55
45
|
puts '----------------------------------------------'
|
56
46
|
puts 'Rebuilding pages ...'
|
57
|
-
verbose(false)
|
47
|
+
verbose(false) do
|
58
48
|
rm_rf 'pages'
|
59
49
|
push_url = `git remote show origin`.grep(/Push.*URL/).first[/git@.*/]
|
60
50
|
sh "
|
@@ -69,8 +59,8 @@ task :pages => :man do
|
|
69
59
|
git add -u ronn*.html index.html index.txt
|
70
60
|
git commit -m 'rebuild manual'
|
71
61
|
git push #{push_url} gh-pages
|
72
|
-
", :
|
73
|
-
|
62
|
+
", verbose: false
|
63
|
+
end
|
74
64
|
end
|
75
65
|
|
76
66
|
# PACKAGING ============================================================
|
@@ -86,29 +76,29 @@ task :rev do
|
|
86
76
|
end
|
87
77
|
|
88
78
|
require 'rubygems'
|
89
|
-
|
79
|
+
@spec = eval(File.read('ronn-ng.gemspec'))
|
90
80
|
|
91
|
-
def package(ext='')
|
92
|
-
"pkg/ronn-#{
|
81
|
+
def package(ext = '')
|
82
|
+
"pkg/ronn-ng-#{@spec.version}" + ext
|
93
83
|
end
|
94
84
|
|
95
85
|
desc 'Build packages'
|
96
|
-
task :
|
86
|
+
task package: %w[.gem .tar.gz].map { |ext| package(ext) }
|
97
87
|
|
98
88
|
desc 'Build and install as local gem'
|
99
|
-
task :
|
89
|
+
task install: package('.gem') do
|
100
90
|
sh "gem install #{package('.gem')}"
|
101
91
|
end
|
102
92
|
|
103
93
|
directory 'pkg/'
|
104
94
|
CLOBBER.include('pkg')
|
105
95
|
|
106
|
-
file package('.gem') => %w[pkg/ ronn-ng.gemspec] +
|
107
|
-
sh
|
96
|
+
file package('.gem') => %w[pkg/ ronn-ng.gemspec] + @spec.files do |f|
|
97
|
+
sh 'gem build ronn-ng.gemspec'
|
108
98
|
mv File.basename(f.name), f.name
|
109
99
|
end
|
110
100
|
|
111
|
-
file package('.tar.gz') => %w[pkg/] +
|
101
|
+
file package('.tar.gz') => %w[pkg/] + @spec.files do |f|
|
112
102
|
sh <<-SH
|
113
103
|
git archive --prefix=ronn-#{source_version}/ --format=tar HEAD |
|
114
104
|
gzip > #{f.name}
|
@@ -119,24 +109,24 @@ def source_version
|
|
119
109
|
@source_version ||= `ruby -Ilib -rronn -e 'puts Ronn::VERSION'`.chomp
|
120
110
|
end
|
121
111
|
|
122
|
-
file 'ronn-ng.gemspec' => FileList['{lib,test,bin}/**','Rakefile'] do |f|
|
112
|
+
file 'ronn-ng.gemspec' => FileList['{lib,test,bin}/**', 'Rakefile'] do |f|
|
123
113
|
# read spec file and split out manifest section
|
124
114
|
spec = File.read(f.name)
|
125
|
-
head,
|
115
|
+
head, _manifest, tail = spec.split(" # = MANIFEST =\n")
|
126
116
|
# replace version and date
|
127
117
|
head.sub!(/\.version = '.*'/, ".version = '#{source_version}'")
|
128
|
-
head.sub!(/\.date = '.*'/, ".date = '#{Date.today
|
118
|
+
head.sub!(/\.date = '.*'/, ".date = '#{Date.today}'")
|
129
119
|
# determine file list from git ls-files
|
130
|
-
files = `git ls-files
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
120
|
+
files = `git ls-files`
|
121
|
+
.split("\n")
|
122
|
+
.sort
|
123
|
+
.reject { |file| file =~ /^\./ }
|
124
|
+
.reject { |file| file =~ /^doc/ }
|
125
|
+
.map { |file| " #{file}" }
|
126
|
+
.join("\n")
|
137
127
|
# piece file back together and write...
|
138
128
|
manifest = " s.files = %w[\n#{files}\n ]\n"
|
139
|
-
spec = [head,manifest,tail].join(" # = MANIFEST =\n")
|
129
|
+
spec = [head, manifest, tail].join(" # = MANIFEST =\n")
|
140
130
|
File.open(f.name, 'w') { |io| io.write(spec) }
|
141
131
|
puts "updated #{f.name}"
|
142
132
|
end
|
@@ -146,7 +136,7 @@ end
|
|
146
136
|
def require_library(name)
|
147
137
|
require name
|
148
138
|
rescue LoadError => boom
|
149
|
-
|
139
|
+
unless defined?(Gem)
|
150
140
|
warn "warn: #{boom}. trying again with rubygems."
|
151
141
|
require 'rubygems'
|
152
142
|
retry
|
data/bin/ronn
CHANGED
@@ -1,43 +1,45 @@
|
|
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
|
-
|
2
|
+
# / Usage: ronn <options> <file>...
|
3
|
+
# / ronn -m|--man <file>
|
4
|
+
# / ronn -S|--server <file> ...
|
5
|
+
# / ronn --pipe [<file>...]
|
6
|
+
# / Convert ronn source <file>s to roff or HTML manpage. In the first synopsis form,
|
7
|
+
# / build HTML and roff output files based on the input file names.
|
8
|
+
# /
|
9
|
+
# / Mode options alter the default behavior of generating files:
|
10
|
+
# / --pipe write to standard output instead of generating files
|
11
|
+
# / -m, --man show manual like with man(1)
|
12
|
+
# / -S, --server serve <file>s at http://localhost:1207/
|
13
|
+
# / --port <port> run server at specified port instead of 1207
|
14
|
+
# / -o, --output-dir <dir> write generated files to specified directory
|
15
|
+
# /
|
16
|
+
# / Format options control which files / formats are generated:
|
17
|
+
# / -r, --roff generate roff output
|
18
|
+
# / -5, --html generate entire HTML page with layout
|
19
|
+
# / -f, --fragment generate HTML fragment
|
20
|
+
# / --markdown generate post-processed markdown output
|
21
|
+
# /
|
22
|
+
# / Document attributes:
|
23
|
+
# / --date=<date> published date in YYYY-MM-DD format (bottom-center)
|
24
|
+
# / --manual=<name> name of the manual (top-center)
|
25
|
+
# / --organization=<name> publishing group or individual (bottom-left)
|
26
|
+
# /
|
27
|
+
# / Misc options:
|
28
|
+
# / -w, --warnings show troff warnings on stderr
|
29
|
+
# / -W disable previously enabled troff warnings
|
30
|
+
# / --version show ronn version and exit
|
31
|
+
# / --help show this help message
|
32
|
+
# /
|
33
|
+
# / A <file> named example.1.ronn generates example.1.html (HTML manpage)
|
34
|
+
# / and example.1 (roff manpage) by default.
|
33
35
|
require 'date'
|
34
36
|
require 'optparse'
|
35
37
|
|
36
38
|
def usage
|
37
|
-
puts File.readlines(__FILE__)
|
38
|
-
|
39
|
-
|
40
|
-
|
39
|
+
puts File.readlines(__FILE__)
|
40
|
+
.grep(/^# \/.*/)
|
41
|
+
.map { |line| line.chomp[4..-1] }
|
42
|
+
.join("\n")
|
41
43
|
end
|
42
44
|
|
43
45
|
##
|
@@ -45,14 +47,14 @@ end
|
|
45
47
|
|
46
48
|
begin
|
47
49
|
require 'rdiscount'
|
48
|
-
require '
|
50
|
+
require 'nokogiri'
|
49
51
|
require 'ronn'
|
50
52
|
rescue LoadError => boom
|
51
53
|
if boom.to_s =~ /ronn/
|
52
|
-
libdir = File.expand_path(
|
53
|
-
if File.directory?(libdir) &&
|
54
|
-
warn "warn: #{boom}. adding #{libdir} to RUBYLIB ..."
|
55
|
-
|
54
|
+
libdir = File.expand_path('../lib', __dir__).sub(%r{^#{Dir.pwd}/}, './')
|
55
|
+
if File.directory?(libdir) && !$LOAD_PATH.include?(libdir)
|
56
|
+
# warn "warn: #{boom}. adding #{libdir} to RUBYLIB ..."
|
57
|
+
$LOAD_PATH.unshift libdir
|
56
58
|
retry
|
57
59
|
end
|
58
60
|
elsif !defined?(Gem)
|
@@ -69,19 +71,22 @@ end
|
|
69
71
|
build = true
|
70
72
|
view = false
|
71
73
|
server = false
|
74
|
+
port_arg = nil
|
72
75
|
formats = nil
|
73
76
|
options = {}
|
74
77
|
write_index = false
|
75
78
|
styles = %w[man]
|
76
|
-
groff =
|
77
|
-
pager = ENV['MANPAGER'] || ENV['PAGER'] || 'more'
|
79
|
+
groff = 'groff -Wall -mtty-char -mandoc -Tascii -t'
|
80
|
+
pager = ENV['MANPAGER'] || ENV['PAGER'] || 'more -is'
|
81
|
+
output_dir = nil
|
78
82
|
|
79
83
|
##
|
80
84
|
# Environment variables
|
81
85
|
|
82
86
|
%w[manual organization date].each do |attribute|
|
83
87
|
value = ENV["RONN_#{attribute.upcase}"]
|
84
|
-
next if value.nil?
|
88
|
+
next if value.nil? || value.empty?
|
89
|
+
|
85
90
|
options[attribute] = value
|
86
91
|
end
|
87
92
|
|
@@ -90,20 +95,23 @@ end
|
|
90
95
|
|
91
96
|
ARGV.options do |argv|
|
92
97
|
# modes
|
93
|
-
argv.on(
|
94
|
-
argv.on(
|
95
|
-
argv.on(
|
96
|
-
argv.on(
|
97
|
-
argv.on(
|
98
|
+
argv.on('--pipe') { build = server = false }
|
99
|
+
argv.on('-b', '--build') { build = true; server = false }
|
100
|
+
argv.on('-m', '--man') { build = server = false; view = true }
|
101
|
+
argv.on('-S', '--server') { build = view = false; server = true }
|
102
|
+
argv.on('-i', '--index') { write_index = true }
|
103
|
+
argv.on('-o', '--output-dir=V') { |val| output_dir = val }
|
104
|
+
argv.on('--port=V') { |val| port_arg = val }
|
98
105
|
|
99
106
|
# format options
|
100
|
-
argv.on(
|
101
|
-
argv.on(
|
102
|
-
argv.on(
|
103
|
-
argv.on(
|
107
|
+
argv.on('-r', '--roff') { (formats ||= []) << 'roff' }
|
108
|
+
argv.on('-5', '--html') { (formats ||= []) << 'html' }
|
109
|
+
argv.on('-f', '--fragment') { (formats ||= []) << 'html_fragment' }
|
110
|
+
argv.on('--markdown') { (formats ||= []) << 'markdown' }
|
111
|
+
argv.on('--yaml') { (formats ||= []) << 'yaml' }
|
104
112
|
|
105
113
|
# html output options
|
106
|
-
argv.on(
|
114
|
+
argv.on('-s', '--style=V') { |val| styles += val.split(/[, \n]+/) }
|
107
115
|
|
108
116
|
# manual attribute options
|
109
117
|
%w[name section manual organization date].each do |attribute|
|
@@ -111,36 +119,35 @@ ARGV.options do |argv|
|
|
111
119
|
end
|
112
120
|
|
113
121
|
# misc
|
114
|
-
argv.on(
|
115
|
-
argv.on(
|
116
|
-
argv.on(
|
122
|
+
argv.on('-w', '--warnings') { groff += ' -ww' }
|
123
|
+
argv.on('-W') { groff += ' -Ww' }
|
124
|
+
argv.on('-v', '--version') do
|
117
125
|
require 'ronn'
|
118
126
|
if Ronn.release?
|
119
|
-
printf "Ronn v%s\n", Ronn::VERSION
|
127
|
+
printf "Ronn-NG v%s\n", Ronn::VERSION
|
120
128
|
else
|
121
|
-
printf "Ronn v%s (%s)\n", Ronn::VERSION, Ronn::REV
|
129
|
+
printf "Ronn-NG v%s (%s)\n", Ronn::VERSION, Ronn::REV
|
122
130
|
end
|
123
|
-
printf "http://github.com/
|
131
|
+
printf "http://github.com/apjanke/ronn-ng/tree/%s\n", Ronn.revision
|
124
132
|
exit 0
|
125
133
|
end
|
126
|
-
argv.on_tail(
|
134
|
+
argv.on_tail('--help') { usage; exit 0 }
|
127
135
|
argv.parse!
|
128
136
|
end
|
129
137
|
|
130
138
|
##
|
131
139
|
# Modes, Formats, Options
|
132
140
|
|
133
|
-
|
134
|
-
when ARGV.empty? && $stdin.tty?
|
141
|
+
if ARGV.empty? && $stdin.tty?
|
135
142
|
usage
|
136
143
|
exit 2
|
137
|
-
|
144
|
+
elsif ARGV.empty? && !server
|
138
145
|
ARGV.push '-'
|
139
146
|
build = false
|
140
147
|
formats ||= %w[roff]
|
141
|
-
|
148
|
+
elsif view
|
142
149
|
formats ||= %w[roff]
|
143
|
-
|
150
|
+
elsif build
|
144
151
|
formats ||= %w[roff html]
|
145
152
|
end
|
146
153
|
formats ||= []
|
@@ -148,6 +155,16 @@ formats.delete('html') if formats.include?('html_fragment')
|
|
148
155
|
|
149
156
|
options['date'] &&= Date.strptime(options['date'], '%Y-%m-%d')
|
150
157
|
options['styles'] = styles
|
158
|
+
options['outdir'] = output_dir
|
159
|
+
|
160
|
+
unless port_arg.nil?
|
161
|
+
begin
|
162
|
+
options['port'] = Integer(port_arg)
|
163
|
+
rescue ArgumentError
|
164
|
+
warn "Error: invalid port number: '#{port_arg}'"
|
165
|
+
exit 1
|
166
|
+
end
|
167
|
+
end
|
151
168
|
|
152
169
|
##
|
153
170
|
# Server
|
@@ -168,7 +185,8 @@ documents.each do |doc|
|
|
168
185
|
# setup the man pipeline if the --man option was specified
|
169
186
|
if view && !build
|
170
187
|
rd, wr = IO.pipe
|
171
|
-
|
188
|
+
pid = fork
|
189
|
+
if pid
|
172
190
|
rd.close
|
173
191
|
else
|
174
192
|
wr.close
|
@@ -178,20 +196,20 @@ documents.each do |doc|
|
|
178
196
|
end
|
179
197
|
|
180
198
|
# write output for each format
|
181
|
-
formats.each do |
|
199
|
+
formats.each do |fmt|
|
182
200
|
if build
|
183
|
-
path = doc.path_for(
|
184
|
-
case
|
201
|
+
path = doc.path_for(fmt)
|
202
|
+
case fmt
|
185
203
|
when 'html'
|
186
|
-
warn
|
204
|
+
warn format('%9s: %-43s%15s', fmt, path, '+' + doc.styles.join(','))
|
187
205
|
when 'roff', 'html_fragment', 'markdown'
|
188
|
-
warn
|
206
|
+
warn format('%9s: %-43s', fmt, path)
|
189
207
|
end
|
190
208
|
|
191
|
-
output = doc.convert(
|
209
|
+
output = doc.convert(fmt)
|
192
210
|
File.open(path, 'wb') { |f| f.puts(output) }
|
193
211
|
|
194
|
-
if
|
212
|
+
if fmt == 'roff'
|
195
213
|
if view
|
196
214
|
system "man #{path}"
|
197
215
|
else
|
@@ -199,7 +217,7 @@ documents.each do |doc|
|
|
199
217
|
end
|
200
218
|
end
|
201
219
|
else
|
202
|
-
output = doc.convert(
|
220
|
+
output = doc.convert(fmt)
|
203
221
|
wr.puts(output)
|
204
222
|
end
|
205
223
|
end
|
@@ -214,7 +232,7 @@ end
|
|
214
232
|
# Write index.txt files
|
215
233
|
|
216
234
|
if write_index
|
217
|
-
indexes = documents.map
|
235
|
+
indexes = documents.map(&:index).uniq
|
218
236
|
indexes.each do |index|
|
219
237
|
File.open(index.path, 'wb') do |fd|
|
220
238
|
fd.puts(index.to_text)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Bash completion script for ronn(1) from Ronn-NG
|
2
|
+
|
3
|
+
_ronn()
|
4
|
+
{
|
5
|
+
local cur prev words cword
|
6
|
+
_init_completion -n = || return
|
7
|
+
|
8
|
+
COMREPLY=()
|
9
|
+
cur=${COMP_WORDS[COMP_CWORD]}
|
10
|
+
|
11
|
+
case "$prev" in
|
12
|
+
--help|--version|-!(-*)'?')
|
13
|
+
return
|
14
|
+
;;
|
15
|
+
-o|--output-dir|-!(-*)e)
|
16
|
+
_filedir -d
|
17
|
+
return
|
18
|
+
;;
|
19
|
+
esac
|
20
|
+
|
21
|
+
if [[ "$cur" == -* ]]; then
|
22
|
+
COMREPLY=( $( compgen -W '--pipe -m --man -S --server --port -o --output-dir -r --roff -5 --html -f --fragment --markdown --date --manual --organization -w --warnings -W --version --help'))
|
23
|
+
return
|
24
|
+
fi
|
25
|
+
|
26
|
+
_filedir
|
27
|
+
|
28
|
+
return 0
|
29
|
+
} &&
|
30
|
+
complete -F _ronn ronn
|
31
|
+
|
32
|
+
# ex: filetype=sh
|