#!/usr/bin/env bash if [[ ! -z "$rvm_trace_flag" ]] ; then set -x ; export rvm_trace_flag ; fi trap "if [[ -d $rvm_tmp_path/ ]] && [[ -f $rvm_tmp_path/$$ ]] ; then rm -f $rvm_tmp_path/$$ > /dev/null 2>&1 ; fi ; exit" 0 1 2 3 15 source $rvm_scripts_path/initialize rvm_ruby_string="$(basename $GEM_HOME 2>/dev/null | awk -F'@' '{print $1}')" if [[ -z "$rvm_ruby_string" ]] && echo $GEM_HOME | grep -v 'rvm/' > /dev/null 2>&1 ; then $rvm_scripts_path/log "error" "Currently 'rvm docs ...' does not work with non-rvm rubies." exit 1 fi rvm_docs_type="${rvm_docs_type:-rdoc}" action="$(echo $rvm_ruby_args | awk '{print $1}')" if [[ ! -d "$rvm_docs_path" ]] ; then mkdir -p "$rvm_docs_path/rdoc" "$rvm_docs_path/yard" ; fi open_docs() { if [[ -s "$rvm_docs_path/$rvm_ruby_string/$rvm_docs_type/index.html" ]] ; then if command -v open >/dev/null ; then open $rvm_docs_path/$rvm_ruby_string/$rvm_docs_type/index.html elif command -v xdg-open >/dev/null ; then xdg-open $rvm_docs_path/$rvm_ruby_string/$rvm_docs_type/index.html else $rvm_scripts_path/log "error" "Neither open nor xdg-open were found, in order to open the docs one of these two are required. \n(OR you can let me know how else to open the html in your browser from comand line on your OS :) )" fi else $rvm_scripts_path/log "error" "$rvm_docs_type docs are missing, perhaps run 'rvm docs generate' first?" fi } generate_docs() { builtin cd "$rvm_src_path/$rvm_ruby_string/" rm -rf $rvm_docs_path/$rvm_ruby_string/$rvm_docs_type/ $rvm_scripts_path/log "info" "Generating documentation, be aware that this could take a *long* time, and depends heavily on your system resources..." $rvm_scripts_path/log "info" "( Errors will be logged to $rvm_log_path/$rvm_ruby_string/docs.error.log )" if gem list | grep ^hanna >/dev/null 2>&1 ; then hanna -o $rvm_docs_path/$rvm_ruby_string/$rvm_docs_type --inline-source --line-numbers --fmt=html 2>> $rvm_log_path/$rvm_ruby_string/docs.error.log else rdoc -a -o $rvm_docs_path/$rvm_ruby_string/$rvm_docs_type 2>> $rvm_log_path/$rvm_ruby_string/docs.error.log fi rdoc -a --ri-site 2>> $rvm_log_path/$rvm_ruby_string/docs.error.log } if [[ "open" = "$action" ]] ; then open_docs elif [[ "generate" = "$action" ]] ; then generate_docs else $rvm_scripts_path/log "error" "" exit 1 fi exit $result