From 6622502c015bbf00f9bca22e4f01f9cbc3d1539b Mon Sep 17 00:00:00 2001
From: Brett Terpstra
Date: Wed, 21 Dec 2011 17:24:15 -0600
Subject: adding auto-documentation script
---
document_keybindings.rb | 126 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 126 insertions(+)
create mode 100755 document_keybindings.rb
diff --git a/document_keybindings.rb b/document_keybindings.rb
new file mode 100755
index 0000000..aa7ba8d
--- /dev/null
+++ b/document_keybindings.rb
@@ -0,0 +1,126 @@
+#!/usr/bin/ruby
+# encoding: utf-8
+
+require 'rubygems'
+
+infile = File.new('DefaultKeyBinding.dict','r')
+input = infile.read
+infile.close
+
+output = ''
+style =<
+
+STYLE
+
+intro =<\s*(.*)$/
+ note += " " + $1
+ elsif line =~ /^\s*\};\s*$/
+ level -= 1
+ if level == 1
+ subgroup_command = ''
+ subgroup_desc = ''
+ output += "|||||\n"
+ elsif level == 0
+ output += "[ #{group_desc} ]\n\n"
+ group_command = ''
+ group_desc = ''
+ end
+ next
+ elsif line =~ /^\s*\/\/\s*(.*)/
+ desc = $1
+ next
+ elsif line =~ /^\s*"([^"]+)"\s*=\s*\{.*?\/\/\s*(.*)/
+ level += 1
+ if level == 1
+ group_command = translate_command($1)
+ group_desc = $2
+ output += "\n|#{group_desc} (#{group_command})||||\n|:----:|:----:|:----:|:----|\n"
+ elsif level == 2
+ subgroup_command = translate_command($1)
+ subgroup_desc = $2
+ output += "|#{subgroup_desc} (#{subgroup_command})||| |\n"
+ else
+ prefix = $1
+ end
+ next
+ elsif line =~ /^\s*"([^"]+)"\s*=\s*\(/
+ command = translate_command($1)
+ if level == 0
+ toplevel.push("|#{command}|#{desc}|\n")
+ else
+ command = prefix + "," + command if prefix
+ note = "(#{note})" if note != ''
+ output += "|#{group_command} |#{subgroup_command} |#{command} |#{desc} #{note}|\n"
+ end
+ note = ''
+ end
+}
+topoutput = "|General Commands||\n|Key|Function|\n|:----:|:----|\n"
+toplevel.each {|line|
+ topoutput += line
+}
+topoutput += "[ General Commands ]\n\n"
+
+# output = style + topoutput + output
+output = topoutput + output
+
+htmlout = %x{echo #{e_sh output}|/usr/local/bin/multimarkdown}
+
+outfile = File.new('readme.md','w')
+outfile.puts intro
+outfile.puts htmlout
+outfile.close
\ No newline at end of file
--
cgit v1.2.3