summaryrefslogtreecommitdiffhomepage
path: root/dragon/kernel_docs.rb
blob: 7ef9470f89db1c06c1fe141165303c871251f7c9 (plain)
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
# coding: utf-8
# Copyright 2019 DragonRuby LLC
# MIT License
# kernel_docs.rb has been released under MIT (*only this file*).

module KernelDocs
  def docs_method_sort_order
    [:docs_class, :docs_tick_count, :docs_global_tick_count]
  end

  def docs_class
    <<-S
* DOCS: ~Kernel~

Kernel in the DragonRuby Runtime has patches for how standard out is handled and also
contains a unit of time in games called a tick.

S
  end

  def docs_tick_count
    <<-S
* DOCS: ~Kernel::tick_count~

Returns the current tick of the game. This value is reset if you call $gtk.reset.

S
  end

  def docs_global_tick_count
    <<-S
* DOCS: ~Kernel::global_tick_count~

Returns the current tick of the application from the point it was started. This value is never reset.

S
  end

  def docs_export_docs!
    <<-S
* DOCS: ~Kernel::export_docs!~

Exports all GTK documentation to txt files and saves them to a docs directory.

S
  end

  def export_docs!
    DocsOrganizer.sort_docs_classes!
    final_string = ""
    $docs_classes.each do |k|
      log "* INFO: Retrieving docs for #{k.name}."
      final_string += k.docs_all
    end

    final_string += "\n" + (($gtk.read_file "docs/source.txt") || "")

    html_parse_result = (__docs_to_html__ final_string)

    $gtk.write_file_root 'docs/docs.txt', "#{final_string}"
    $gtk.write_file_root 'docs/docs.html', html_parse_result[:html]
    $gtk.write_file_root 'docs/parse_log.txt', (html_parse_result[:parse_log].join "\n")

    log "* INFO: All docs have been exported to docs/docs.txt."
    log "* INFO: All docs have been exported to docs/docs.html."

    nil
  end
end

module Kernel
  extend Docs
  extend KernelDocs
end