Class: RDoc::Generator::RDocJSON
- Inherits:
-
Object
- Object
- RDoc::Generator::RDocJSON
- Includes:
- FileUtils
- Defined in:
- lib/rdoc/generator/rdocjson.rb
Instance Method Summary collapse
-
#class_dir ⇒ Object
Darkfish returns
nil, hence we do this as well. -
#debug(str) ⇒ Object
Outputs a string on standard output, but only if RDoc was invoked with the
--debugswitch. -
#file_dir ⇒ Object
Darkfish returns
nil, hence we do this as well. -
#generate ⇒ Object
Main hook method called by RDoc, triggers the generation process.
- #generate_json_file ⇒ Object
-
#initialize(store, options) ⇒ RDocJSON
constructor
Instanciates this generator.
Constructor Details
#initialize(store, options) ⇒ RDocJSON
Instanciates this generator. Automatically called by RDoc.
Parameter
- options
-
RDoc passed the current RDoc::Options instance.
19 20 21 22 23 |
# File 'lib/rdoc/generator/rdocjson.rb', line 19 def initialize(store, ) @store = store = @op_dir = Pathname.pwd. + .op_dir end |
Instance Method Details
#class_dir ⇒ Object
Darkfish returns nil, hence we do this as well.
57 58 59 |
# File 'lib/rdoc/generator/rdocjson.rb', line 57 def class_dir nil end |
#debug(str) ⇒ Object
Outputs a string on standard output, but only if RDoc was invoked with the --debug switch.
27 28 29 |
# File 'lib/rdoc/generator/rdocjson.rb', line 27 def debug(str) puts(str) if $DEBUG_RDOC end |
#file_dir ⇒ Object
Darkfish returns nil, hence we do this as well.
52 53 54 |
# File 'lib/rdoc/generator/rdocjson.rb', line 52 def file_dir nil end |
#generate ⇒ Object
Main hook method called by RDoc, triggers the generation process.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rdoc/generator/rdocjson.rb', line 32 def generate debug "Sorting classes, modules, and methods..." @toplevels = @store.all_files @classes_and_modules = @store.all_classes_and_modules.sort_by do |klass| klass.full_name end @methods = @classes_and_modules.map do |mod| mod.method_list end.flatten.sort # Create the output directory mkdir @op_dir unless @op_dir.exist? generate_json_file end |
#generate_json_file ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/rdoc/generator/rdocjson.rb', line 61 def generate_json_file json = {} json["toplevels"] = @toplevels.map do |toplevel| { name: toplevel.name, description: toplevel.description } end json["classes_and_modules"] = @classes_and_modules.map do |classmod| { name: classmod.full_name, superclass: classmod.module? ? "" : classmod.superclass, method_list: classmod.each_method.to_a.map do |method| { name: method.pretty_name } end, description: classmod.description, includes: classmod.includes.map do |included| { name: included.full_name } end, constants: classmod.constants.map do |const| { name: const.name, value: const.value, description: const.description } end, attributes: classmod.attributes.map do |attribute| { name: attribute.name, description: attribute.description } end } end json["methods"] = @methods.map do |method| { type: method.type, visibility: method.visibility, arglists: method.arglists, description: method.description, markup_code: method.markup_code, } end File.write(@op_dir + "all.json", JSON.pretty_generate(json)) end |