Created
January 13, 2012 22:02
-
-
Save jvoorhis/1608944 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
=begin lit | |
# Introducing Lit | |
Lit allows developers to embed Markdown in their comments, and extracts | |
it for them to produce human friendly documentation. | |
=end | |
require 'rubygems' | |
require 'rdiscount' | |
=begin lit | |
Lit comments begin with =begin lit | |
=end | |
BEGIN_LIT = /=begin lit/ | |
=begin lit | |
and end with \=end | |
=end | |
END_LIT = /=end/ | |
SKIP = /=(begin|end)/ | |
path = ARGV[0] | |
src = File.open(path) | |
doc = [] | |
while src.gets | |
if ($_ =~ BEGIN_LIT) .. ($_ =~ END_LIT) | |
doc << $_ unless $_ =~ SKIP | |
end | |
end | |
mkd = RDiscount.new(doc * "\n") | |
puts mkd.to_html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment