-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathREADME-parser
More file actions
executable file
·42 lines (28 loc) · 811 Bytes
/
README-parser
File metadata and controls
executable file
·42 lines (28 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env ruby
require 'rubygems'
require 'epitools'
require 'json'
def parse_readme
sections = {}
for chunk in File.read("README.txt").lines.split_before(/=\[/)
if chunk.first =~ /=\[ (.+) \]=/
section = $1
end
script_pairs = \
chunk.
grep(/\|/).
map{|l| [$1,$2] if l =~ /(\S+)\s*\|\s*(.+)/}.
flatten
sections[section] = Hash[*script_pairs]
end
open("descs.json","wb"){|f| f.write sections.to_json }
end
def find_missing
sects = JSON.load open("descs.json")
described_scripts = sects.values.map(&:keys).flatten.sort
all_scripts = Dir["**/*"].select{|fn| File.file? fn }.sort
missing = all_scripts - described_scripts
sects["Undescribed"] = Hash[*missing.map{|m| [m,'']}.flatten]
pp sects
end
find_missing