Module: DocsOrganizer

Defined in:
dragon/docs.rb

Overview

Copyright 2019 DragonRuby LLC MIT License docs.rb has been released under MIT (*only this file*).

Class Method Summary collapse

Class Method Details

.check_class_sort_orderObject


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'dragon/docs.rb', line 41

def self.check_class_sort_order
  unsorted = $docs_classes.find_all do |klass|
    !class_sort_order.include? klass
  end

  unsorted.each do |k|
      puts <<-S
* WARNING: #{klass.name} is not included in DocsOrganizer::class_sort_order. Please place this
module in it's correct topological order.
S
  end

  if unsorted.length == 0
    puts <<-S
* INFO: Success. All documented classes have a sort order associated with them.
S
  end
end

.class_sort_orderObject


27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'dragon/docs.rb', line 27

def self.class_sort_order
  [
    GTK::ReadMe,
    GTK::Runtime,
    Array,
    GTK::Args,
    GTK::Outputs,
    GTK::Mouse,
    GTK::OpenEntity,
    Numeric,
    Kernel,
  ]
end

.find_methods_with_docs(klass) ⇒ Object


70
71
72
73
74
75
76
77
# File 'dragon/docs.rb', line 70

def self.find_methods_with_docs klass
  klass_method_sort_order = klass.docs_method_sort_order
  klass.methods.find_all { |m| m.start_with? 'docs_' }
               .reject { |m| reserved_methods.include? m }
               .sort do |l, r|
                 sort_method_delegate l, r, klass_method_sort_order
               end
end

.reserved_methodsObject


17
18
19
20
21
22
23
24
25
# File 'dragon/docs.rb', line 17

def self.reserved_methods
  [
   :docs_export_docs!,
   :docs_all,
   :docs_method_sort_order,
   :docs_classes,
   :docs_search
  ]
end

.sort_docs_classes!Object


7
8
9
10
11
12
13
14
15
# File 'dragon/docs.rb', line 7

def self.sort_docs_classes!
  $docs_classes.sort! do |l, r|
    l_index = (class_sort_order.find_index l) || 50000
    r_index = (class_sort_order.find_index r) || 50000
    l_index = 51000 if l == :docs_classes
    r_index = 51000 if r == :docs_classes
    l_index <=> r_index
  end
end

.sort_method_delegate(l, r, method_sort_order) ⇒ Object


60
61
62
63
64
65
66
67
68
# File 'dragon/docs.rb', line 60

def self.sort_method_delegate l, r, method_sort_order
  l_index = (method_sort_order.find_index l) || 50000
  r_index = (method_sort_order.find_index r) || 50000
  l_index = 51000 if l == :docs_classes
  r_index = 51000 if r == :docs_classes
  l_index = -51000 if l == :docs_class
  r_index = -51000 if r == :docs_class
  l_index <=> r_index
end