zsh-workers
 help / color / mirror / code / Atom feed
070f46ac2a184df20330d7f2366622c62dcb04c6 blob 3798 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
 
#compdef ri

local curcontext="$curcontext" state line ret=1
typeset -A opt_args

_arguments -C \
  '(- *)'{-h,--help}'[print help information and exit]' \
  '(- *)'{-v,--version}'[display the version of ri]' \
  '*'{-d,--doc-dir}'[directory to search for documentation]:ri doc directory:_files -/' \
  '(-f --fmt --format)'{-f,--fmt,--format}'[format to use when displaying output]:output format:(ansi bs html plain simple)' \
  '(-T --no-pager)'{-T,--no-pager}'[send output directly to stdout]' \
  '(-i, --interactive)'{-i,--interactive}'[interactive mode]' \
  '--list-doc-dirs[list the directories from which ri will source documentation]' \
  '(-w --width)'{-w,--width}'[set the width of the output]:output width:' \
  '--no-standard-docs[do not include documentation from the Ruby standard library, site_lib, installed gems, or ~/.rdoc]' \
  '(--no-use-cache --use-cache)--'{no-,}'use-cache[whether or not to use ri'\''s cache]' \
  '(--no-system --system)--'{no-,}'system[include documentation from Ruby'\''s standard library]' \
  '(--no-site --site)--'{no-,}'site[include documentation from libraries installed in site_lib]' \
  '(--no-gems --gems)--'{no-,}'gems[include documentation from RubyGems]' \
  '(--no-home --home)--'{no-,}'home[include documentation stored in ~/.rdoc]' \
  '*:ri name:->ri-name' && ret=0

if [[ "$state" = ri-name ]]; then
  local -a ri_dirs ri_ext ri_names ri_wants ri_names
  local class_dir esc_name dir curtag tag descr expl

  ret=1

  if "ruby${words[1]#ri}" -rrdoc/ri/ri_options -e 1 >/dev/null 2>&1; then
    # Old-style Ruby 1.8.x RI
    ri_dirs=( ${(f)"$(_call_program ri-names "ruby${words[1]#ri}" -rrdoc/ri/ri_options -e '"o = RI::Options.instance; o.parse(ARGV); o.path.each { |p| puts p }"' -- ${(kv)opt_args[(I)-d|--doc-dir|--(system|site|gems|home)]})"} )
    ri_ext=yaml
  elif "ruby${words[1]#ri}" -rrdoc/ri -rrdoc/ri/store -e 1 >/dev/null 2>&1; then
    # Newer-style Ruby 1.9.2 RI
    ri_dirs=( ${(f)"$(_call_program ri-names "$words[1]" ${(kv)opt_args[(I)-d|--doc-dir|--((no-|)(system|site|gems|home)|standard-docs)]} --list-doc-dirs -f bs -T)"} )
    ri_ext=ri
  else
    # New-style Ruby 1.9+ RI
    ri_dirs=( ${(f)"$(_call_program ri-names "$words[1]" ${(kv)opt_args[(I)-d|--doc-dir|--((no-|)(system|site|gems|home)|standard-docs)]} --list-doc-dirs -f plain -T)"} )
    ri_ext=yaml
  fi

  if compset -P '?*(::|\#|.)'; then
    class_dir=${IPREFIX//(::|\#|.)/\/}
  fi
  esc_name=${${(Q)PREFIX}//(#b)([^A-Za-z0-9_])/$(printf %%%x ${(qq)match[1]})}

  case "$IPREFIX" in
    (*::) ri_wants=( 'classes:class names' 'class-methods:class methods' );;
    (*\#) ri_wants=( 'instance-methods:instance methods' );;
    (*.) ri_wants=( 'class-methods:class methods' 'instance-methods:instance methods' );;
    (*) ri_wants=( 'classes:class names' )
  esac

  for curtag in $ri_wants; do
    tag=${curtag%%:*}
    descr=${curtag#*:}

    _tags "$tag"
    while _tags; do
      while _next_label "$tag" expl "$descr"; do
        ri_wants=()
        case "$tag" in
          (classes)
          for dir in $ri_dirs[@]; do
            ri_wants+=( $dir/$class_dir*(-/:t) )
          done
          ;;
          (class-methods)
          for dir in $ri_dirs[@]; do
            fnames=( $dir/$class_dir*-c.$ri_ext(-.:t) )
            ri_wants+=( ${${fnames%-c.$ri_ext}//(#b)%(??)/$(print "\\x$match[1]")} )
          done
          ;;
          (instance-methods)
          for dir in $ri_dirs[@]; do
            fnames=( $dir/$class_dir*-i.$ri_ext(-.:t) )
            ri_wants+=( ${${fnames%-i.$ri_ext}//(#b)%(??)/$(print "\\x$match[1]")} )
          done
          ;;
        esac
        ri_names=( ${(Q)ri_wants} )
        compadd -S '' -d ri_names -a "$expl[@]" ri_wants && ret=0
      done
      (( ret )) || break
    done
  done
fi

return ret
debug log:

solving 070f46ac2 ...
found 070f46ac2 in https://git.vuxu.org/mirror/zsh/

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).