Skip to content

Commit

Permalink
実行引数をとるようにした
Browse files Browse the repository at this point in the history
  • Loading branch information
miyamae committed Jan 27, 2012
1 parent fa1cc1a commit 8622864
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
8 changes: 6 additions & 2 deletions tools/convert_html_encoding.rb
Expand Up @@ -4,8 +4,12 @@
require 'nkf'
require 'fileutils'

src_dir = '../1.9.2.euc'
dst_dir = '../1.9.2.utf8'
if ARGV.size != 2
$stderr.puts 'Usage: convert_html.rb [src_dir] [dst_dir]'
exit
end
src_dir = ARGV[0]
dst_dir = ARGV[1]

if FileTest.exist?(dst_dir)
puts dst_dir + ' already exist.'
Expand Down
17 changes: 14 additions & 3 deletions tools/make_index.rb
Expand Up @@ -9,17 +9,27 @@
require 'json'
require 'yaml'

html_dir = '../1.9.2'
$SCRIPT_PATH = File.expand_path(File.dirname(__FILE__))

if ARGV.empty?
$stderr.puts 'Usage: make_index.rb [html_dir]'
exit
end
html_dir = ARGV[0]
if !FileTest.exist?(html_dir) || !FileTest.directory?(html_dir)
$stderr.puts 'Not found: ' + html_dir
exit
end

id = 1
recs = []
items = YAML.load_file('default_index.yml')
items = YAML.load_file($SCRIPT_PATH + '/default_index.yml')

Find.find(html_dir) do |file|

if file !~ /\/(function|doc)\// && FileTest.file?(file) && File.extname(file) == '.html'
html = File.read(file)
item = {:path=>file.gsub(/^\.\.\/1\.9\.2/, ''), :key=>''}
item = {:path=>file.gsub(/^.*1\.[0-9]\.[0-9]/, ''), :key=>''}
id += 1

# method
Expand All @@ -34,6 +44,7 @@
item[:desc] = CGI.unescapeHTML($1.gsub(/<.*?>|"/, '').gsub(/\n/, ' '))
end


# class
if html =~ %r{<title>(class|module|object) (.*?)</title>}
item[:key] = CGI.unescapeHTML($2)
Expand Down

0 comments on commit 8622864

Please sign in to comment.