├── .gitignore ├── .rvmrc ├── Gemfile ├── Gemfile.lock ├── _input ├── .gitkeep ├── Info.plist ├── logo.png └── otp_doc.css ├── _output └── Erlang.xml ├── fetch.sh ├── generate.sh └── src └── generate.rb /.gitignore: -------------------------------------------------------------------------------- 1 | _input/doc.tar.gz 2 | _output/*.tgz 3 | _output/erlang.docset/ 4 | -------------------------------------------------------------------------------- /.rvmrc: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # This is an RVM Project .rvmrc file, used to automatically load the ruby 4 | # development environment upon cd'ing into the directory 5 | 6 | # First we specify our desired [@], the @gemset name is optional. 7 | environment_id="ruby-1.9.3-p194@erlang.docset" 8 | 9 | # 10 | # Uncomment the following lines if you want to verify rvm version per project 11 | # 12 | # rvmrc_rvm_version="1.10.2" # 1.10.1 seams as a safe start 13 | # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || { 14 | # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading." 15 | # return 1 16 | # } 17 | # 18 | 19 | # 20 | # Uncomment following line if you want options to be set only for given project. 21 | # 22 | # PROJECT_JRUBY_OPTS=( --1.9 ) 23 | # 24 | # The variable PROJECT_JRUBY_OPTS requires the following to be run in shell: 25 | # 26 | # chmod +x ${rvm_path}/hooks/after_use_jruby_opts 27 | # 28 | 29 | # 30 | # First we attempt to load the desired environment directly from the environment 31 | # file. This is very fast and efficient compared to running through the entire 32 | # CLI and selector. If you want feedback on which environment was used then 33 | # insert the word 'use' after --create as this triggers verbose mode. 34 | # 35 | if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \ 36 | && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]] 37 | then 38 | \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id" 39 | 40 | if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] 41 | then 42 | . "${rvm_path:-$HOME/.rvm}/hooks/after_use" 43 | fi 44 | else 45 | # If the environment file has not yet been created, use the RVM CLI to select. 46 | if ! rvm --create "$environment_id" 47 | then 48 | echo "Failed to create RVM environment '${environment_id}'." 49 | return 1 50 | fi 51 | fi 52 | 53 | # 54 | # If you use an RVM gemset file to install a list of gems (*.gems), you can have 55 | # it be automatically loaded. Uncomment the following and adjust the filename if 56 | # necessary. 57 | # 58 | # filename=".gems" 59 | # if [[ -s "$filename" ]] 60 | # then 61 | # rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d' 62 | # fi 63 | 64 | # If you use bundler, this might be useful to you: 65 | # if [[ -s Gemfile ]] && ! command -v bundle >/dev/null 66 | # then 67 | # printf "%b" "The rubygem 'bundler' is not installed. Installing it now.\n" 68 | # gem install bundler 69 | # fi 70 | # if [[ -s Gemfile ]] && command -v bundle 71 | # then 72 | # bundle install 73 | # fi 74 | 75 | if [[ $- == *i* ]] # check for interactive shells 76 | then 77 | echo "Using: $(tput setaf 2)$GEM_HOME$(tput sgr0)" # show the user the ruby and gemset they are using in green 78 | else 79 | echo "Using: $GEM_HOME" # don't use colors in interactive shells 80 | fi 81 | 82 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'http://ruby.taobao.org' 2 | gem 'ruby-debug19' 3 | gem 'rake' 4 | gem 'nokogiri' 5 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: http://ruby.taobao.org/ 3 | specs: 4 | archive-tar-minitar (0.5.2) 5 | columnize (0.3.6) 6 | linecache19 (0.5.12) 7 | ruby_core_source (>= 0.1.4) 8 | nokogiri (1.5.2) 9 | rake (0.9.2.2) 10 | ruby-debug-base19 (0.11.25) 11 | columnize (>= 0.3.1) 12 | linecache19 (>= 0.5.11) 13 | ruby_core_source (>= 0.1.4) 14 | ruby-debug19 (0.11.6) 15 | columnize (>= 0.3.1) 16 | linecache19 (>= 0.5.11) 17 | ruby-debug-base19 (>= 0.11.19) 18 | ruby_core_source (0.1.5) 19 | archive-tar-minitar (>= 0.5.2) 20 | 21 | PLATFORMS 22 | ruby 23 | 24 | DEPENDENCIES 25 | nokogiri 26 | rake 27 | ruby-debug19 28 | -------------------------------------------------------------------------------- /_input/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kapeli/erlang-docset/409d131f809e1f8a1d246542d146a4b21d7564e8/_input/.gitkeep -------------------------------------------------------------------------------- /_input/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleIdentifier 6 | Erlang 7 | CFBundleName 8 | Erlang 9 | DocSetPlatformFamily 10 | Erlang 11 | isDashDocset 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /_input/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kapeli/erlang-docset/409d131f809e1f8a1d246542d146a4b21d7564e8/_input/logo.png -------------------------------------------------------------------------------- /_input/otp_doc.css: -------------------------------------------------------------------------------- 1 | /* standard OTP style sheet */ 2 | body { 3 | background: white; 4 | font-family: Verdana, Arial, Helvetica, sans-serif; 5 | margin: 0; 6 | padding: 0; 7 | border: 0; 8 | overflow: scroll; 9 | height: 100%; 10 | max-height: 100%; 11 | } 12 | 13 | th { font-family: Verdana, Arial, Helvetica, sans-serif } 14 | td { font-family: Verdana, Arial, Helvetica, sans-serif } 15 | p { font-family: Verdana, Arial, Helvetica, sans-serif } 16 | 17 | .header { background: #222; color: #fff } 18 | .top { background: #efe } 19 | .otp { background: #efe } 20 | .erlang { background: #ffe } 21 | .otp2 { background: #efe } 22 | .app { background: #ffe } 23 | 24 | a:link { color: blue; text-decoration: none } 25 | a:active { color: blue; text-decoration: none } 26 | a:visited { color: blue; text-decoration: none } 27 | 28 | #container { 29 | width: 100%; 30 | margin: 0; 31 | background-color: #fff; 32 | } 33 | 34 | #leftnav { 35 | display: none; 36 | position: fixed; 37 | float: left; 38 | top: 0; 39 | bottom: 0; 40 | left: 0; 41 | width: 200px; 42 | overflow:auto; 43 | margin: 0; 44 | padding: 1px; 45 | border-right: 1px solid red; 46 | } 47 | 48 | #content { 49 | /*margin-left: 240px; [> set left value to WidthOfFrameDiv <]*/ 50 | } 51 | 52 | .frontpage 53 | { 54 | padding-top: 50px; /* Magins for inner DIV inside each DIV (to provide padding) */ 55 | } 56 | 57 | .innertube 58 | { 59 | margin: 15px; /* Magins for inner DIV inside each DIV (to provide padding) */ 60 | } 61 | 62 | .footer 63 | { 64 | margin: 15px; /* Magins for inner DIV inside each DIV (to provide padding) */ 65 | } 66 | 67 | span.bold_code { font-family: Courier, monospace; font-weight: bold } 68 | span.code { font-family: Courier, monospace; font-weight: normal } 69 | 70 | .note, .warning { 71 | border: solid black 1px; 72 | margin: 1em 3em; 73 | } 74 | .note .label { 75 | background: #30d42a; 76 | color: white; 77 | font-weight: bold; 78 | padding: 5px 10px; 79 | } 80 | .note .content { 81 | background: #eafeea; 82 | color: black; 83 | line-height: 120%; 84 | font-size: 90%; 85 | padding: 5px 10px; 86 | } 87 | .warning .label { 88 | background: #C00; 89 | color: white; 90 | font-weight: bold; 91 | padding: 5px 10px; 92 | } 93 | .warning .content { 94 | background: #FFF0F0; 95 | color: black; 96 | line-height: 120%; 97 | font-size: 90%; 98 | padding: 5px 10px; 99 | } 100 | .example { 101 | background-color:#eeeeff; 102 | padding: 0px 10px; 103 | } 104 | 105 | pre { font-family: Courier, monospace; font-weight: normal } 106 | 107 | .REFBODY { margin-left: 13mm } 108 | 109 | .REFTYPES { margin-left: 8mm } 110 | 111 | footer { } 112 | -------------------------------------------------------------------------------- /_output/Erlang.xml: -------------------------------------------------------------------------------- 1 | 2 | 15B01 3 | https://github.com/hpyhacking/erlang.docset/raw/master/_output/erlang.tgz 4 | 5 | -------------------------------------------------------------------------------- /fetch.sh: -------------------------------------------------------------------------------- 1 | mkdir -p _output/erlang.docset/Contents/Resources/Documents 2 | wget -O _input/doc.tar.gz http://www.erlang.org/download/otp_doc_html_R15B01.tar.gz 3 | -------------------------------------------------------------------------------- /generate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | rm -rf _output/erlang.docset/Contents/Resources/docSet.dsidx 4 | rm -rf _output/erlang.docset/Contents/Resources/Documents/* 5 | 6 | mkdir -p _output/erlang.docset/Contents/Resources/Documents 7 | tar zxf _input/doc.tar.gz -C _output/erlang.docset/Contents/Resources/Documents 8 | cp -rf _input/Info.plist _output/erlang.docset/Contents/Info.plist 9 | cp -rf _input/logo.png _output/erlang.docset/icon.png 10 | cp -rf _input/otp_doc.css _output/erlang.docset/Contents/Resources/Documents/doc/otp_doc.css 11 | 12 | cd _output/erlang.docset/Contents/Resources/Documents 13 | 14 | #find doc -name \*\.html | xargs -n 1 ruby ../src/generate.rb | sqlite3 ../_output/erlang.docset/Contents/Resources/docSet.dsidx 15 | #find lib -name \*\.html | xargs -n 1 ruby ../src/generate.rb | sqlite3 ../_output/erlang.docset/Contents/Resources/docSet.dsidx 16 | find doc -name \*\.html | xargs -n 1 ruby ~/Codes/erlang.docset/src/generate.rb | sqlite3 ../docSet.dsidx 17 | find lib -name \*\.html | xargs -n 1 ruby ~/Codes/erlang.docset/src/generate.rb | sqlite3 ../docSet.dsidx 18 | find erts-5.9.1 -name \*\.html | xargs -n 1 ruby ~/Codes/erlang.docset/src/generate.rb | sqlite3 ../docSet.dsidx 19 | 20 | cd - 21 | 22 | cd _output 23 | 24 | tar --exclude='*.pdf' --exclude='.DS_Store' -cvzf Erlang.tgz erlang.docset 25 | 26 | cd - 27 | -------------------------------------------------------------------------------- /src/generate.rb: -------------------------------------------------------------------------------- 1 | require 'nokogiri' 2 | 3 | doc_file = ARGV.first 4 | file_name = ARGV.first 5 | 6 | def check_doc_type doc 7 | sample = doc.css('h3').collect { |x| x.content } 8 | case sample[0...2] 9 | when ["MODULE", "MODULE SUMMARY"] then :module 10 | else :undef 11 | end 12 | end 13 | 14 | def write_html doc, file 15 | builder = Nokogiri::HTML::Builder.new do |b| 16 | b.html do 17 | b.header do b << '' end 18 | b.body do b << doc.css("#content").first end 19 | end 20 | end 21 | File.open("_output/erlang.docset/Contents/Resources/Documents/#{file}", 'w') {|f| f.write(builder.to_html) } 22 | end 23 | 24 | doc = Nokogiri::HTML(ARGF.read) 25 | case check_doc_type(doc) 26 | when :module then 27 | puts "CREATE TABLE IF NOT EXISTS searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT);" 28 | 29 | #write_html(doc, file_name) 30 | 31 | mod = doc.css("h3").first.next.next.content 32 | puts "INSERT INTO searchIndex VALUES (NULL, '#{mod}', 'cl', '#{file_name}');" 33 | doc.css("#content > .innertube > p > a").each do |x| 34 | fun = x.attr('name').gsub("'", "") 35 | puts "INSERT INTO searchIndex VALUES (NULL, '#{mod}:#{fun.sub('-', '/')}', 'func', '#{file_name}##{fun}');" 36 | end 37 | end 38 | --------------------------------------------------------------------------------