├── .gitignore ├── icon.png ├── README.md ├── Info.plist └── Rakefile /.gitignore: -------------------------------------------------------------------------------- 1 | CasperJS.docset 2 | -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gamma/dash-casperjs/master/icon.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [Dash](http://kapeli.com/dash) docset for [CasperJS](http://casperjs.org) 2 | 3 | ## Usage 4 | 5 | ```bash 6 | $ rake 7 | $ open CasperJS.docset 8 | ``` 9 | 10 | There is no step three! 11 | 12 | ### License 13 | 14 | MIT License, copyright 2013 by André Arko 15 | -------------------------------------------------------------------------------- /Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleIdentifier 6 | CasperJS 7 | CFBundleName 8 | CasperJS 9 | DocSetPlatformFamily 10 | CasperJS 11 | isDashDocset 12 | 13 | dashIndexFilePath 14 | index.html 15 | 16 | 17 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require 'nokogiri' 2 | 3 | namespace :docs do 4 | task :download do 5 | # Download the API docs 6 | sh "curl -O https://media.readthedocs.org/dash/casperjs/latest/CasperJS.tgz" 7 | sh "tar xfz CasperJS.tgz" 8 | rm "CasperJS.tgz" 9 | 10 | # Copy the Info.plist into the right place 11 | cp "Info.plist", "CasperJS.docset/Contents" 12 | 13 | # Install the favicon 14 | cp "icon.png", "CasperJS.docset" 15 | end 16 | 17 | task :index do 18 | def sql(*cmd) 19 | IO.popen('sqlite3 CasperJS.docset/Contents/Resources/docSet.dsidx', 'w+') do |sql| 20 | cmd.each{|l| sql << l } 21 | end 22 | end 23 | 24 | def index(name, type, path) 25 | sql("INSERT OR IGNORE INTO searchIndex(name, type, path) VALUES ('#{name}', '#{type}', '#{path}');") 26 | end 27 | 28 | # Create the database and schema 29 | db = "CasperJS.docset/Contents/Resources/docSet.dsidx" 30 | rm_rf db if File.exist?(db) 31 | sql "CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT);", 32 | "CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path);" 33 | 34 | # Index the Casper class, which is a slightly weird page 35 | index "Casper", "Class", "modules/casper.html#the-casper-class" 36 | index "Casper.options", "Property", "modules/casper.html#index-1" 37 | 38 | docsdir = "CasperJS.docset/Contents/Resources/Documents" 39 | casper = Nokogiri::HTML(File.read("#{docsdir}/modules/casper.html")) 40 | 41 | items = casper.css("h3").map do |item| 42 | name = item.css("tt span") 43 | next nil if name.empty? 44 | [name.text, "casper.html" + item.css("a").attr("href").value] 45 | end.compact 46 | 47 | items.each do |item| 48 | if item.first =~ /\(\)/ 49 | # this must be an instance function 50 | index "Casper.#{item.first[0..-3]}", "Method", "modules/#{item.last}" 51 | else 52 | # this must be an options attribute 53 | index "Casper.options.#{item.first}", "Attribute", "modules/#{item.last}" 54 | end 55 | end 56 | 57 | # Index the other modules 58 | %w(Clientutils Colorizer Tester utils).each do |modname| 59 | index modname, "Class", "modules/#{modname.downcase}.html" 60 | 61 | parsed = Nokogiri::HTML(File.read("#{docsdir}/modules/#{modname.downcase}.html")) 62 | parsed.css("h3").map do |item| 63 | name = item.css("tt span") 64 | next nil if name.empty? 65 | link = item.css("a").attr("href").value 66 | index "Casper.#{name.text[0..-3]}", "Method", "modules/#{modname.downcase}.html#{link}" 67 | end.compact 68 | end 69 | 70 | # Index the cli sections 71 | index "Casper.cli", "Property", "cli.html#using-the-command-line" 72 | index "Casper.cli.raw", "Property", "cli.html#raw-parameter-values" 73 | 74 | # Document the weird require requirement 75 | index "patchRequire", "Function", "writing_modules.html#writing-casperjs-modules" 76 | 77 | # Index the events and filters list 78 | parsed = Nokogiri::HTML(File.read("#{docsdir}/events-filters.html")) 79 | %w(Event Filter).each do |type| 80 | parsed.css("##{type.downcase}s-reference h4").map do |item| 81 | name = item.css("tt span") 82 | next nil if name.empty? 83 | link = item.css("a").attr("href").value 84 | index name.text, type, "events-filters.html" + link 85 | end 86 | end 87 | 88 | end 89 | 90 | desc 'generate a .docset for CasperJS' 91 | task :generate => [:download, :index] 92 | end 93 | 94 | task :default => "docs:generate" 95 | --------------------------------------------------------------------------------