Last active
August 6, 2019 00:19
-
-
Save amirrajan/d2206cd820adeba44ce384e549b69b18 to your computer and use it in GitHub Desktop.
Export GTK documentation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1. Create a file called mygame/app/repl.rb | |
# 2. Start up the GTK environment. | |
# 3. Change the line at the bottom of this file. | |
# 4. Save repl.rb. | |
# Explanation: | |
# The code below tells GTK to give me all private member variables that have a public method, | |
# and for those member variables, execute the public method, then call `.help` on whatever | |
# that public method returned. Then finally save the help result to a file. | |
def export_help_for_instance_variable o, ivar | |
attr_name = ivar.to_s.gsub("@", "").to_sym | |
if o.respond_to? attr_name | |
output_file_name = "app/help-#{attr_name}.txt" | |
.gsub("--", "-") | |
.gsub("class", "") | |
.gsub(":", "") | |
.gsub(" ", "") | |
.gsub("(", "") | |
.gsub(")", "") | |
$gtk.ffi_file.storefile output_file_name, o.send(attr_name).help | |
end | |
end | |
def export_help_for_instance_variables o | |
o.instance_variables.sort.map do |ivar| | |
export_help_for_instance_variable o, ivar | |
end | |
end | |
# Change the line below to things like $gtk, $gtk.args, $gtk.args.keyboard, etc | |
export_help_for_instance_variables $gtk |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment