rdocjson 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/rdoc/discover.rb +1 -0
- data/lib/rdoc/generator/rdocjson.rb +110 -0
- metadata +72 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f24a44ad54f006f588f5205998ba8b146613d0723a6f064425cddcf2b9ea685f
|
4
|
+
data.tar.gz: 5eb1ed1f2994bbc9bebedff15f5a4886b9c65ad3a88e465326d29e387da8aeae
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: aa4eca088c8afc2d100c7aafab784699637b4901f638f12d6b79ff1ead7063ab84e4f68aae2152810e47b76d35d92a8adaaba6a6564f25a1db64917e9fb3c7f5
|
7
|
+
data.tar.gz: 16af7a36c9c99811dbfc47ffaa2e601965128426b2d814d38e2d9b09d36c36b9bb7f6529385e6892c4d3f13151815dec4b6565403e16483d215d642035fabd8d
|
@@ -0,0 +1 @@
|
|
1
|
+
require_relative "generator/rdocjson"
|
@@ -0,0 +1,110 @@
|
|
1
|
+
gem "rdoc"
|
2
|
+
|
3
|
+
require "pathname"
|
4
|
+
require "fileutils"
|
5
|
+
require "rdoc/rdoc"
|
6
|
+
require "rdoc/generator"
|
7
|
+
require "json"
|
8
|
+
|
9
|
+
class RDoc::Generator::RDocJSON
|
10
|
+
include FileUtils
|
11
|
+
|
12
|
+
RDoc::RDoc.add_generator(self)
|
13
|
+
|
14
|
+
# Instanciates this generator. Automatically called
|
15
|
+
# by RDoc.
|
16
|
+
# ==Parameter
|
17
|
+
# [options]
|
18
|
+
# RDoc passed the current RDoc::Options instance.
|
19
|
+
def initialize(store, options)
|
20
|
+
@store = store
|
21
|
+
@options = options
|
22
|
+
@op_dir = Pathname.pwd.expand_path + @options.op_dir
|
23
|
+
end
|
24
|
+
|
25
|
+
# Outputs a string on standard output, but only if RDoc
|
26
|
+
# was invoked with the <tt>--debug</tt> switch.
|
27
|
+
def debug(str)
|
28
|
+
puts(str) if $DEBUG_RDOC
|
29
|
+
end
|
30
|
+
|
31
|
+
# Main hook method called by RDoc, triggers the generation process.
|
32
|
+
def generate
|
33
|
+
debug "Sorting classes, modules, and methods..."
|
34
|
+
|
35
|
+
@toplevels = @store.all_files
|
36
|
+
|
37
|
+
@classes_and_modules = @store.all_classes_and_modules.sort_by do |klass|
|
38
|
+
klass.full_name
|
39
|
+
end
|
40
|
+
|
41
|
+
@methods = @classes_and_modules.map do |mod|
|
42
|
+
mod.method_list
|
43
|
+
end.flatten.sort
|
44
|
+
|
45
|
+
# Create the output directory
|
46
|
+
mkdir @op_dir unless @op_dir.exist?
|
47
|
+
|
48
|
+
generate_json_file
|
49
|
+
end
|
50
|
+
|
51
|
+
# Darkfish returns +nil+, hence we do this as well.
|
52
|
+
def file_dir
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
|
56
|
+
# Darkfish returns +nil+, hence we do this as well.
|
57
|
+
def class_dir
|
58
|
+
nil
|
59
|
+
end
|
60
|
+
|
61
|
+
def generate_json_file
|
62
|
+
json = {}
|
63
|
+
|
64
|
+
json["toplevels"] = @toplevels.map do |toplevel|
|
65
|
+
{
|
66
|
+
name: toplevel.name,
|
67
|
+
description: toplevel.description
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
json["classes_and_modules"] = @classes_and_modules.map do |classmod|
|
72
|
+
{
|
73
|
+
name: classmod.full_name,
|
74
|
+
superclass: classmod.module? ? "" : classmod.superclass,
|
75
|
+
method_list: classmod.each_method.to_a.map do |method|
|
76
|
+
{ name: method.pretty_name }
|
77
|
+
end,
|
78
|
+
description: classmod.description,
|
79
|
+
includes: classmod.includes.map do |included|
|
80
|
+
{ name: included.full_name }
|
81
|
+
end,
|
82
|
+
constants: classmod.constants.map do |const|
|
83
|
+
{
|
84
|
+
name: const.name,
|
85
|
+
value: const.value,
|
86
|
+
description: const.description
|
87
|
+
}
|
88
|
+
end,
|
89
|
+
attributes: classmod.attributes.map do |attribute|
|
90
|
+
{
|
91
|
+
name: attribute.name,
|
92
|
+
description: attribute.description
|
93
|
+
}
|
94
|
+
end
|
95
|
+
}
|
96
|
+
end
|
97
|
+
|
98
|
+
json["methods"] = @methods.map do |method|
|
99
|
+
{
|
100
|
+
type: method.type,
|
101
|
+
visibility: method.visibility,
|
102
|
+
arglists: method.arglists,
|
103
|
+
description: method.description,
|
104
|
+
markup_code: method.markup_code,
|
105
|
+
}
|
106
|
+
end
|
107
|
+
|
108
|
+
File.write(@op_dir + "all.json", JSON.pretty_generate(json))
|
109
|
+
end
|
110
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rdocjson
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dorian Marié
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-07-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rdoc
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.3'
|
41
|
+
description:
|
42
|
+
email: dorian@dorianmarie.fr
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- lib/rdoc/discover.rb
|
48
|
+
- lib/rdoc/generator/rdocjson.rb
|
49
|
+
homepage: https://github.com/dorianmariefr/rdocjson
|
50
|
+
licenses:
|
51
|
+
- MIT
|
52
|
+
metadata: {}
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
require_paths:
|
56
|
+
- lib
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
requirements: []
|
68
|
+
rubygems_version: 3.0.8
|
69
|
+
signing_key:
|
70
|
+
specification_version: 4
|
71
|
+
summary: JSON from RDoc
|
72
|
+
test_files: []
|