Restructuring the repo

This commit is contained in:
Alexander Gehrke 2020-04-02 10:38:36 +02:00
parent 21e3cf65e6
commit 3d67598c27
45 changed files with 368 additions and 77 deletions

View file

@ -1,52 +0,0 @@
#!/usr/bin/env ruby
require 'dmenu'
JAVA_DOC_LOCATION = "/home/crater2150/manuals/scala-*"
USER_DOC_LOCATION = (ENV['XDG_DATA_HOME'] || ENV['HOME'] + '/.local') + '/scaladoc/*'
class DocIndex
attr_reader :items
def initialize(path)
@items = []
find_entries(path)
end
private
def gen_candidates(dir)
Dir.entries(dir).reject {|e| e == '.' ||
e == '..' ||
e == 'class-use' ||
e == 'src-html' ||
(e =~ /^[a-z].*\..*/ && e != 'package-summary.html')}
end
def find_entries(dir, path = [])
candidates = gen_candidates(dir)
candidates.each do |entry|
if entry == "package-summary.html"
@items << Dmenu::Item.new(path.join(?.), dir + ?/ + entry)
elsif entry.end_with? ".html"
@items << Dmenu::Item.new(
path.join(?.) + ?. + File.basename(entry, '.html'),
dir + ?/ + entry
)
elsif File.directory?(dir + ?/ + entry)
find_entries(dir + ?/ + entry, path + [entry])
end
end
end
end
scala_folder = Dir.glob(JAVA_DOC_LOCATION).last + "/api/scala-library/"
menu = Dmenu.new
menu.items = DocIndex.new(scala_folder).items
menu.case_insensitive = true
menu.prompt = "Javadoc:"
menu.lines = 20
system("xdg-open #{menu.run.value}")