File: setup.rb

package info (click to toggle)
yard 0.9.37-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,720 kB
  • sloc: ruby: 31,354; javascript: 7,608; makefile: 21
file content (52 lines) | stat: -rw-r--r-- 1,292 bytes parent folder | download | duplicates (3)
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
# frozen_string_literal: true
def init
  return if object.docstring.blank? && !object.has_tag?(:api)
  sections :index, [:private, :deprecated, :abstract, :todo, :note, :returns_void, :text], T('tags')
end

def private
  return unless object.has_tag?(:api) && object.tag(:api).text == 'private'
  erb(:private)
end

def abstract
  return unless object.has_tag?(:abstract)
  erb(:abstract)
end

def deprecated
  return unless object.has_tag?(:deprecated)
  erb(:deprecated)
end

def todo
  return unless object.has_tag?(:todo)
  erb(:todo)
end

def note
  return unless object.has_tag?(:note)
  erb(:note)
end

def returns_void
  return unless object.type == :method
  return if object.name == :initialize && object.scope == :instance
  return unless object.tags(:return).size == 1 && object.tag(:return).types == ['void']
  erb(:returns_void)
end

def docstring_text
  text = ""
  unless object.tags(:overload).size == 1 && object.docstring.empty?
    text = object.docstring
  end

  if text.strip.empty? && object.tags(:return).size == 1 && object.tag(:return).text
    text = object.tag(:return).text.gsub(/\A([a-z])/, &:downcase)
    text = "Returns #{text.sub(/\.\Z/, '')}." unless text.empty? || text =~ /^\s*return/i
    text = text.gsub(/\A([a-z])/, &:upcase)
  end

  text.strip
end