-
Notifications
You must be signed in to change notification settings - Fork 2
/
devhelp-indexer.rb
executable file
·36 lines (29 loc) · 1002 Bytes
/
devhelp-indexer.rb
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
#!/usr/bin/env ruby
require './common'
dir = ARGV[0] || raise("Need base dir! (e.g. /usr/share/gtk-doc/html)")
Dir.chdir(dir)
#indexes = Dir['**/*.devhelp2']
indexes = IO.popen("find . -follow -name '*.devhelp2'","r") {|f| f.readlines.map {|l| l.chomp}}
def unq(quoted)
quoted.gsub(""",'"').gsub("'","'").gsub("&","&")
end
indexes.each do |path|
# REXML is really slow. Just use good-old regexps
kwlines = IO.readlines(path).grep(/<keyword/)
dirpath = File.dirname(File.expand_path(path))
kwlines.each do |l|
unless l =~ /<keyword\s+type="(.*?)"\s+name="(.*?)"\s+link="(.*?)"\s*\/>/
STDERR.puts "strange line: #{l}"
next
end
type, name, link = $1, $2, $3
type, name, link = unq(type), unq(name), unq(link)
name = name.chomp("()").strip
if type == "enum" && name[0,5] == "enum "
name = name[5..-1]
end
next if type.empty?
print_cdb_entry "#{name}:#{type}", "file:///#{dirpath}/#{link}\0devhelp:#{name}"
end
end
puts