Fork Let’s Split files
This commit is contained in:
parent
732a115b32
commit
aeade1b197
44 changed files with 25623 additions and 0 deletions
40
keyboards/nyquist/keymaps/hexwire/keymap_to_readme.rb
Executable file
40
keyboards/nyquist/keymaps/hexwire/keymap_to_readme.rb
Executable file
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
class KeymapConverter
|
||||
|
||||
def initialize(filename)
|
||||
@filename = filename
|
||||
@mode = :search
|
||||
end
|
||||
|
||||
def read_keymaps
|
||||
lines = IO.readlines(@filename)
|
||||
lines.each { |line| parse_line line[0..-2] }
|
||||
end
|
||||
|
||||
def parse_line(line)
|
||||
case @mode
|
||||
when :search
|
||||
if line =~ /COMPACT_KEYMAP/
|
||||
puts "### #{line}"
|
||||
puts "```"
|
||||
@mode = :parse
|
||||
end
|
||||
when :parse
|
||||
if line =~ /\)/
|
||||
@mode = :search
|
||||
puts "```\n\n"
|
||||
else
|
||||
line = line[4..-1]
|
||||
line.sub!(/(,)^-/m, "|")
|
||||
line.sub!(/( {4})/, " |")
|
||||
|
||||
puts line
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
converter = KeymapConverter.new('keymap.c')
|
||||
converter.read_keymaps
|
Loading…
Add table
Add a link
Reference in a new issue