Skip to content

Instantly share code, notes, and snippets.

@jvoorhis
Created January 13, 2012 22:02
Show Gist options
  • Save jvoorhis/1608944 to your computer and use it in GitHub Desktop.
Save jvoorhis/1608944 to your computer and use it in GitHub Desktop.
#!/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