summaryrefslogtreecommitdiffhomepage
path: root/scan.rb
blob: 75c7959e6a2c5ab765853affaff214cb0c7b0b1a (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
require "rexml/document"

class CodeModule
  attr_accessor :title, :color, :files, :code

  def initialize(title:, files:, color:)
    self.title = title
    self.color = color
    self.files = files
    self.code = ""
  end
end

code_modules = [
  CodeModule.new(title: "Core", files: ['rodeo_8h.xml', 'common_8h.xml'], color: "stone"),
  CodeModule.new(title: "Audio", files: ['audio_8h.xml'], color: "blue"),
  CodeModule.new(title: "Input", files: ['input_8h.xml'], color: "red"),
  CodeModule.new(title: "Log", files: ['log_8h.xml'], color: "yellow"),
]
code_modules.each_with_index do |mod, index|
  mod.files.each do |file|
    file = File.new("doxygen/xml/#{file}")
    doc = REXML::Document.new file
    root = doc.root

    defines = root.get_elements('//sectiondef').filter { |attr| attr.attributes['kind'] == "func" }

    defines.each do |func|
      func.get_elements('//definition').each_with_index do |defi, i|
        mod.code += "#{defi.text}#{func.get_elements('//argsstring')[i].text};\n"
      end
    end
  end
  File.write("./docs/#{index}#{mod.title.downcase}.html",
             "---
title: #{mod.title}
id: #{mod.title.downcase}
color: #{mod.color}
---
{% highlight c %}
#{mod.code}
{% endhighlight %}
")
end