ronn 0.6.6 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/CHANGES +34 -0
  2. data/INSTALLING +18 -0
  3. data/README.md +43 -69
  4. data/Rakefile +9 -10
  5. data/bin/ronn +66 -49
  6. data/config.ru +1 -1
  7. data/lib/ronn.rb +35 -9
  8. data/lib/ronn/document.rb +239 -135
  9. data/lib/ronn/index.rb +183 -0
  10. data/lib/ronn/roff.rb +48 -28
  11. data/lib/ronn/template.rb +22 -8
  12. data/lib/ronn/template/dark.css +1 -4
  13. data/lib/ronn/template/default.html +0 -2
  14. data/lib/ronn/template/man.css +12 -12
  15. data/lib/ronn/utils.rb +8 -0
  16. data/man/index.html +78 -0
  17. data/man/index.txt +15 -0
  18. data/man/{ronn.5 → ronn-format.7} +26 -30
  19. data/man/{ronn.5.ronn → ronn-format.7.ronn} +39 -39
  20. data/man/ronn.1 +47 -15
  21. data/man/ronn.1.ronn +53 -23
  22. data/ronn.gemspec +14 -8
  23. data/test/angle_bracket_syntax.html +4 -2
  24. data/test/basic_document.html +4 -2
  25. data/test/custom_title_document.html +1 -2
  26. data/test/definition_list_syntax.html +4 -2
  27. data/test/dots_at_line_start_test.roff +10 -0
  28. data/test/dots_at_line_start_test.ronn +4 -0
  29. data/test/entity_encoding_test.html +24 -2
  30. data/test/entity_encoding_test.roff +41 -1
  31. data/test/entity_encoding_test.ronn +17 -0
  32. data/test/index.txt +8 -0
  33. data/test/markdown_syntax.html +5 -3
  34. data/test/markdown_syntax.roff +4 -4
  35. data/test/middle_paragraph.html +4 -2
  36. data/test/missing_spaces.roff +3 -0
  37. data/test/section_reference_links.html +4 -2
  38. data/test/{ronn_test.rb → test_ronn.rb} +18 -5
  39. data/test/{document_test.rb → test_ronn_document.rb} +59 -8
  40. data/test/test_ronn_index.rb +73 -0
  41. data/test/titleless_document.html +7 -2
  42. data/test/titleless_document.ronn +3 -2
  43. data/test/underline_spacing_test.roff +5 -0
  44. metadata +30 -14
  45. data/man/ronn.7 +0 -168
  46. data/man/ronn.7.ronn +0 -120
data/CHANGES CHANGED
@@ -1,6 +1,40 @@
1
1
  Ronn CHANGES
2
2
  ============
3
3
 
4
+ Version 0.7.0 (2010 June 21)
5
+ ----------------------------
6
+
7
+ * HTML: Manual references (like 'grep(1)', 'ls(1)', etc.) are now hyperlinked
8
+ based on a set of name -> URL mappings defined in an index.txt file. The index
9
+ may also define links to things that aren't manuals for use in markdown
10
+ reference-style links. See the ronn(1) manual on LINK INDEXES for more
11
+ inforation: <http://rtomayko.github.com/ronn/ronn.1.html#LINK-INDEXES>
12
+ (rtomayko)
13
+
14
+ * ROFF: Fixed a bug where multiple dot characters (.) at the beginning of a
15
+ line were not being escaped properly and were not displayed when viewed
16
+ in the terminal. (rtomayko)
17
+
18
+ * ROFF: Non-breaking space characters (&nbsp;) can now be used to control line
19
+ wrap in roff output. (rtomayko)
20
+
21
+ * ROFF: Named HTML entities like &bull;, &trade;, &copy;, and &mdash; are now
22
+ converted to their roff escaped equivalents. (rtomayko)
23
+
24
+ * An undocumented --markdown format option argument has been added to ronn(1).
25
+ When given, ronn generates a <name>.<section>.markdown file with the
26
+ post-processed markdown text. This is mostly useful for debugging but may be
27
+ useful for converting ronn-format to 100% compatible markdown text.
28
+ (rtomayko)
29
+
30
+ * The ronn(5) manpage is now known as ronn-format(7) (section 5 is limited
31
+ to configuration files and stuff like that historically). The old ronn(7)
32
+ manpage, which was really just the README, has been removed.
33
+ (rtomayko)
34
+
35
+ * Performance improvements. Fixed a few cases where HTML was being reparsed
36
+ needlessly, tuned dom selectors, ... (rtomayko)
37
+
4
38
  Version 0.6.6 (2010 June 13)
5
39
  ----------------------------
6
40
 
@@ -0,0 +1,18 @@
1
+ Ronn is currently distributed mainly as a gem package. Install with rubygems:
2
+
3
+ $ gem install ronn
4
+ $ ronn --help
5
+
6
+ Tarballs available at: <http://github.com/rtomayko/ronn/downloads>
7
+
8
+ $ curl -L http://github.com/rtomayko/ronn/downloads/0.6.6 | tar xvzf -
9
+ $ cd rtomayko-r*
10
+ $ ruby setup.rb
11
+
12
+ The hpricot, mustache, and rdiscount packages are required.
13
+
14
+ Hacking? Clone the git repository and put ronn/bin on your PATH:
15
+
16
+ $ git clone git://github.com/rtomayko/ronn.git
17
+ $ PATH=$(pwd)/ronn/bin:$PATH
18
+ $ ronn --help
data/README.md CHANGED
@@ -1,46 +1,27 @@
1
- ronn -- the opposite of roff
2
- ============================
1
+ # Ronn
3
2
 
4
- ## DESCRIPTION
5
-
6
- Ronn is a text format and toolchain for creating UNIX manpages. It converts
7
- markdown to standard UNIX roff manpages and formatted HTML manuals for the web.
3
+ Ronn builds manuals. It converts simple, human readable textfiles to roff for
4
+ terminal display, and also to HTML for the web.
8
5
 
9
6
  The source format includes all of Markdown but has a more rigid structure and
10
- includes extensions that provide features commonly found in manpages (definition
11
- lists, link notation, etc.). The ronn(5) manual page defines the format in
7
+ syntax extensions for features commonly found in manpages (definition lists,
8
+ link notation, etc.). The ronn-format(7) manual page defines the format in
12
9
  detail.
13
10
 
14
- ## DOCUMENTATION
15
-
16
- The `.ronn` files located under the `man/` directory show off a wide range of
17
- ronn capabilities and are the source of Ronn's own documentation. The source
18
- files and generated HTML / roff output files are available at:
11
+ The `*.ronn` files found in the [`man/`][1] directory show off a wide range of
12
+ ronn capabilities:
19
13
 
20
- * [ronn(1)](http://rtomayko.github.com/ronn/ronn.1) -
21
- convert markdown files to manpages.<br>
14
+ * [ronn(1)](http://rtomayko.github.com/ronn/ronn.1) command -
22
15
  [source file](http://github.com/rtomayko/ronn/blob/master/man/ronn.1.ronn),
23
16
  [roff output](http://github.com/rtomayko/ronn/blob/master/man/ronn.1)
24
17
 
25
- * [ronn(5)](http://rtomayko.github.com/ronn/ronn.5) -
26
- markdown-based text format for authoring manpages<br>
27
- [source file](http://github.com/rtomayko/ronn/blob/master/man/ronn.5.ronn),
28
- [roff output](http://github.com/rtomayko/ronn/blob/master/man/ronn.5)
29
-
30
- ## INSTALL
31
-
32
- Install with Rubygems:
33
-
34
- $ [sudo] gem install ronn
35
- $ ronn --help
18
+ * [ronn-format(7)](http://rtomayko.github.com/ronn/ronn-format.7) -
19
+ [source file](http://github.com/rtomayko/ronn/blob/master/man/ronn-format.7.ronn),
20
+ [roff output](http://github.com/rtomayko/ronn/blob/master/man/ronn-format.7)
36
21
 
37
- Or, clone the git repository:
22
+ [1]: http://github.com/rtomayko/ronn/tree/master/man
38
23
 
39
- $ git clone git://github.com/rtomayko/ronn.git
40
- $ PATH=ronn/bin:$PATH
41
- $ ronn --help
42
-
43
- ## BASIC USAGE
24
+ ## Examples
44
25
 
45
26
  Build roff and HTML output files for one or more input files:
46
27
 
@@ -48,10 +29,6 @@ Build roff and HTML output files for one or more input files:
48
29
  roff: man/ronn.5
49
30
  html: man/ronn.5.html
50
31
 
51
- View a roff manpage with man(1):
52
-
53
- $ man man/ronn.5
54
-
55
32
  Generate only a standalone HTML version of one or more files:
56
33
 
57
34
  $ ronn --html man/markdown.5.ronn
@@ -65,56 +42,53 @@ View a ronn file as if it were a manpage without building intermediate files:
65
42
 
66
43
  $ ronn --man man/markdown.5.ronn
67
44
 
45
+ View roff output with man(1):
46
+
47
+ $ man man/ronn.5
48
+
68
49
  The [ronn(1)](http://rtomayko.github.com/ronn/ronn.1) manual page includes
69
50
  comprehensive documentation on `ronn` command line options.
70
51
 
71
- ## ABOUT
52
+ ## Background
72
53
 
73
- Some people say UNIX manual pages are a poor and outdated style of
74
- documentation. I disagree:
54
+ Some think UNIX manual pages are a poor and outdated form of documentation. I
55
+ disagree:
75
56
 
76
- - Man pages follow a well defined structure that's immediately familiar. This
77
- provides developers with a useful starting point when documenting new tools,
78
- libraries, and formats.
57
+ - Manpages follow a well defined structure that's immediately familiar. This
58
+ gives developers a starting point when documenting new tools, libraries, and
59
+ formats.
79
60
 
80
- - Man pages get to the point. Because they're written in an inverted style, with
61
+ - Manpages get to the point. Because they're written in an inverted style, with
81
62
  a SYNOPSIS section followed by additional detail, prose and references to
82
- other sources of information, man pages provide the best of both cheat sheet
63
+ other sources of information, manpages provide the best of both cheat sheet
83
64
  and reference style documentation.
84
65
 
85
- - Man pages have extremely -- unbelievably -- limited text formatting
86
- capabilities. You get a couple of headings, lists, bold, underline and no
87
- more. This is a feature.
66
+ - Historically, manpages use an extremely -- unbelievably -- limited set of
67
+ text formatting capabilities. You get a couple of headings, lists, bold,
68
+ underline and no more. This is a feature.
88
69
 
89
- - Although two levels of section hierarchy are technically supported, most man
90
- pages use only a single level. Unwieldy document hierarchies complicate
91
- otherwise good documentation. Feynman covered all of physics -- heavenly
92
- bodies through QED -- with only two levels of document hierarchy (_The Feynman
93
- Lectures on Physics_, 1970).
94
-
95
- - Man pages have a simple referencing syntax; e.g., sh(1), fork(2), markdown(7).
96
- HTML versions can use this to generate links between pages.
70
+ - Although two levels of section hierarchy are technically supported, most
71
+ manpages use only a single level. Unwieldy document hierarchies complicate
72
+ otherwise good documentation. Remember that Feynman covered all of physics
73
+ -- heavenly bodies through QED -- with only two levels of document hierarchy
74
+ (_The Feynman Lectures on Physics_, 1970).
97
75
 
98
- - The classical terminal man page display is typographically well thought out.
76
+ - The classical terminal manpage display is typographically well thought out.
99
77
  Big bold section headings, justified monospace text, nicely indented
100
78
  paragraphs, intelligently aligned definition lists, and an informational
101
79
  header and footer.
102
80
 
81
+ - Manpages have a simple referencing syntax; e.g., sh(1), fork(2), markdown(7).
82
+ HTML versions can use this to generate links between pages.
83
+
103
84
  Unfortunately, figuring out how to create a manpage is a fairly tedious process.
104
- The roff/man macro languages are highly extensible, fractured between multiple
105
- dialects, and include a bunch of device specific stuff irrelevant to modern
106
- publishing tools.
85
+ The roff/mandoc/mdoc macro languages are highly extensible, fractured between
86
+ multiple dialects, and include a bunch of device specific stuff irrelevant to
87
+ modern publishing tools.
107
88
 
108
- Ronn aims to address many of the issues with manpage creation while preserving
109
- the things that makes manpages a great form of documentation.
89
+ Ronn aims
110
90
 
111
- ## COPYING
91
+ ## Copying
112
92
 
113
- Ronn is Copyright (C) 2009 [Ryan Tomayko](http://tomayko.com/about)<br>
93
+ Ronn is Copyright (C) 2010 [Ryan Tomayko](http://tomayko.com/about)<br>
114
94
  See the file COPYING for information of licensing and distribution.
115
-
116
- ## SEE ALSO
117
-
118
- [ronn(1)](http://rtomayko.github.com/ronn/ronn.1),
119
- [ronn(5)](http://rtomayko.github.com/ronn/ronn.5),
120
- markdown(5)
data/Rakefile CHANGED
@@ -19,7 +19,7 @@ end
19
19
  desc 'Run tests'
20
20
  task :test => :environment do
21
21
  $LOAD_PATH.unshift "#{ROOTDIR}/test"
22
- Dir['test/*_test.rb'].each { |f| require(f) }
22
+ Dir['test/test_*.rb'].each { |f| require(f) }
23
23
  end
24
24
 
25
25
  desc 'Start the server'
@@ -45,9 +45,9 @@ end
45
45
  desc 'Build the manual'
46
46
  task :man => :environment do
47
47
  require 'ronn'
48
- ENV['RONN_MANUAL'] = "Ronn #{Ronn::VERSION}"
49
- ENV['RONN_ORGANIZATION'] = Ronn::REV
50
- sh "ronn -w -s toc man/*.ronn"
48
+ ENV['RONN_MANUAL'] = "Ronn Manual"
49
+ ENV['RONN_ORGANIZATION'] = "Ronn #{Ronn::revision}"
50
+ sh "ronn -w -s toc -r5 --markdown man/*.ronn"
51
51
  end
52
52
 
53
53
  desc 'Publish to github pages'
@@ -57,17 +57,16 @@ task :pages => :man do
57
57
  verbose(false) {
58
58
  rm_rf 'pages'
59
59
  push_url = `git remote show origin`.grep(/Push.*URL/).first[/git@.*/]
60
- rev = `git rev-parse origin/gh-pages`
61
60
  sh "
62
61
  set -e
63
62
  git fetch -q origin
63
+ rev=$(git rev-parse origin/gh-pages)
64
64
  git clone -q -b gh-pages . pages
65
65
  cd pages
66
- git reset --hard #{rev}
66
+ git reset --hard $rev
67
67
  rm -f ronn*.html index.html
68
- cp -rp ../man/ronn*.html ./
69
- cp -p ronn.7.html index.html
70
- git add -u ronn*.html index.html
68
+ cp -rp ../man/ronn*.html ../man/index.txt ../man/index.html ./
69
+ git add -u ronn*.html index.html index.txt
71
70
  git commit -m 'rebuild manual'
72
71
  git push #{push_url} gh-pages
73
72
  ", :verbose => false
@@ -78,7 +77,7 @@ end
78
77
 
79
78
  # Rev Ronn::VERSION
80
79
  task :rev do
81
- rev = `git describe --tags`.chomp
80
+ rev = ENV['REV'] || `git describe --tags`.chomp
82
81
  data = File.read('lib/ronn.rb')
83
82
  data.gsub!(/^( *)REV *=.*/, "\\1REV = '#{rev}'")
84
83
  File.open('lib/ronn.rb', 'wb') { |fd| fd.write(data) }
data/bin/ronn CHANGED
@@ -1,29 +1,31 @@
1
1
  #!/usr/bin/env ruby
2
2
  #/ Usage: ronn <options> <file>...
3
- #/ ronn -m|--man <file> ...
3
+ #/ ronn -m|--man <file>
4
4
  #/ ronn -S|--server <file> ...
5
5
  #/ ronn --pipe [<file>...]
6
6
  #/ Convert ronn source <file>s to roff or HTML manpage. In the first synopsis form,
7
7
  #/ build HTML and roff output files based on the input file names.
8
8
  #/
9
- #/ Mode options alter the default file generating behavior:
9
+ #/ Mode options alter the default behavior of generating files:
10
10
  #/ --pipe write to standard output instead of generating files
11
11
  #/ -m, --man show manual like with man(1)
12
12
  #/ -S, --server serve <file>s at http://localhost:1207/
13
13
  #/
14
- #/ Format options control which files are generated:
14
+ #/ Format options control which files / formats are generated:
15
15
  #/ -r, --roff generate roff output
16
16
  #/ -5, --html generate entire HTML page with layout
17
17
  #/ -f, --fragment generate HTML fragment
18
+ #/ --markdown generate post-processed markdown output
18
19
  #/
19
20
  #/ Document attributes:
20
- #/ --date=DATE published date in YYYY-MM-DD format (bottom-center)
21
- #/ --manual=NAME name of the manual (top-center)
22
- #/ --organization=NAME publishing group or individual (bottom-left)
21
+ #/ --date=<date> published date in YYYY-MM-DD format (bottom-center)
22
+ #/ --manual=<name> name of the manual (top-center)
23
+ #/ --organization=<name> publishing group or individual (bottom-left)
23
24
  #/
24
25
  #/ Misc options:
25
26
  #/ -w, --warnings show troff warnings on stderr
26
27
  #/ -W disable previously enabled troff warnings
28
+ #/ --version show ronn version and exit
27
29
  #/ --help show this help message
28
30
  #/
29
31
  #/ A <file> named example.1.ronn generates example.1.html (HTML manpage)
@@ -38,14 +40,38 @@ def usage
38
40
  join("\n")
39
41
  end
40
42
 
43
+ ##
44
+ # Libraries and LOAD_PATH shenanigans
45
+
46
+ begin
47
+ require 'rdiscount'
48
+ require 'hpricot'
49
+ require 'ronn'
50
+ rescue LoadError => boom
51
+ if boom.to_s =~ /ronn/
52
+ libdir = File.expand_path("../../lib", __FILE__).sub(%r|^#{Dir.pwd}/|, './')
53
+ if File.directory?(libdir) && !$:.include?(libdir)
54
+ warn "warn: #{boom}. adding #{libdir} to RUBYLIB ..."
55
+ $:.unshift libdir
56
+ retry
57
+ end
58
+ elsif !defined?(Gem)
59
+ warn "warn: #{boom}. loading rubygems ..."
60
+ require 'rubygems'
61
+ retry
62
+ end
63
+ abort boom.to_s
64
+ end
65
+
41
66
  ##
42
67
  # Argument defaults
43
68
 
44
- build = true
45
- view = false
46
- server = false
69
+ build = true
70
+ view = false
71
+ server = false
47
72
  formats = nil
48
73
  options = {}
74
+ write_index = false
49
75
  styles = %w[man]
50
76
  groff = "groff -Wall -mtty-char -mandoc -Tascii"
51
77
  pager = ENV['MANPAGER'] || ENV['PAGER'] || 'more'
@@ -68,13 +94,13 @@ ARGV.options do |argv|
68
94
  argv.on("-b", "--build") { build = true; server = false }
69
95
  argv.on("-m", "--man") { build = server = false; view = true }
70
96
  argv.on("-S", "--server") { build = view = false; server = true }
71
- argv.on("-w", "--warnings") { groff += ' -ww' }
72
- argv.on("-W") { groff += ' -Ww' }
97
+ argv.on("-i", "--index") { write_index = true }
73
98
 
74
99
  # format options
75
100
  argv.on("-r", "--roff") { (formats ||= []) << 'roff' }
76
101
  argv.on("-5", "--html") { (formats ||= []) << 'html' }
77
102
  argv.on("-f", "--fragment") { (formats ||= []) << 'html_fragment' }
103
+ argv.on("--markdown") { (formats ||= []) << 'markdown' }
78
104
 
79
105
  # html output options
80
106
  argv.on("-s", "--style=V") { |val| styles += val.split(/[, \n]+/) }
@@ -84,6 +110,19 @@ ARGV.options do |argv|
84
110
  argv.on("--#{attribute}=VALUE") { |val| options[attribute] = val }
85
111
  end
86
112
 
113
+ # misc
114
+ argv.on("-w", "--warnings") { groff += ' -ww' }
115
+ argv.on("-W") { groff += ' -Ww' }
116
+ argv.on("-v", "--version") do
117
+ require 'ronn'
118
+ if Ronn.release?
119
+ printf "Ronn v%s\n", Ronn::VERSION
120
+ else
121
+ printf "Ronn v%s (%s)\n", Ronn::VERSION, Ronn::REV
122
+ end
123
+ printf "http://github.com/rtomayko/ronn/tree/%s\n", Ronn.revision
124
+ exit 0
125
+ end
87
126
  argv.on_tail("--help") { usage ; exit 0 }
88
127
  argv.parse!
89
128
  end
@@ -107,41 +146,9 @@ end
107
146
  formats ||= []
108
147
  formats.delete('html') if formats.include?('html_fragment')
109
148
 
110
- # turn the --date arg into a real date object
111
149
  options['date'] &&= Date.strptime(options['date'], '%Y-%m-%d')
112
-
113
- # pass the styles option
114
150
  options['styles'] = styles
115
151
 
116
- ##
117
- # Libraries and LOAD_PATH shenanigans
118
-
119
- begin
120
- require 'hpricot'
121
- require 'rdiscount'
122
- rescue LoadError
123
- if !defined?(Gem)
124
- warn "warn: #{$!.to_s}. trying again with rubygems."
125
- require 'rubygems'
126
- retry
127
- end
128
- end
129
-
130
- # load ronn libs, setting up the load path if something fails and
131
- # we're in a development environment.
132
- begin
133
- require 'ronn'
134
- rescue LoadError
135
- raise if $!.to_s !~ /ronn/
136
- libdir = File.expand_path("../../lib", __FILE__).sub(/^#{Dir.pwd}/, '.')
137
- if !$:.include?(libdir)
138
- warn "warn: #{$!.to_s}. trying again with #{libdir} on load path."
139
- $:.unshift libdir
140
- retry
141
- end
142
- raise
143
- end
144
-
145
152
  ##
146
153
  # Server
147
154
 
@@ -156,9 +163,8 @@ end
156
163
 
157
164
  pid = nil
158
165
  wr = STDOUT
159
- ARGV.each do |file|
160
- doc = Ronn.new(file, options) { file == '-' ? STDIN.read : File.read(file) }
161
-
166
+ documents = ARGV.map { |file| Ronn::Document.new(file, options) }
167
+ documents.each do |doc|
162
168
  # setup the man pipeline if the --man option was specified
163
169
  if view && !build
164
170
  rd, wr = IO.pipe
@@ -177,9 +183,9 @@ ARGV.each do |file|
177
183
  path = doc.path_for(format)
178
184
  case format
179
185
  when 'html'
180
- warn "%5s: %-48s%15s" % [format, path, '+' + doc.styles.join(',')]
181
- when 'roff', 'html_fragment'
182
- warn "%5s: %-48s" % [format, path]
186
+ warn "%9s: %-43s%15s" % [format, path, '+' + doc.styles.join(',')]
187
+ when 'roff', 'html_fragment', 'markdown'
188
+ warn "%9s: %-43s" % [format, path]
183
189
  end
184
190
 
185
191
  output = doc.convert(format)
@@ -204,3 +210,14 @@ ARGV.each do |file|
204
210
  Process.wait
205
211
  end
206
212
  end
213
+
214
+ # Write index.txt files
215
+
216
+ if write_index
217
+ indexes = documents.map { |doc| doc.index }.uniq
218
+ indexes.each do |index|
219
+ File.open(index.path, 'wb') do |fd|
220
+ fd.puts(index.to_text)
221
+ end
222
+ end
223
+ end