doc2json 1.0.0.pre.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +8 -0
- data/CONTRIBUTING.md +0 -0
- data/Gemfile +2 -0
- data/LICENSE.md +0 -0
- data/README.md +27 -0
- data/Rakefile +35 -0
- data/bin/doc2json +7 -0
- data/doc2json.gemspec +29 -0
- data/lib/doc2json.rb +2 -0
- data/lib/doc2json/generator.rb +72 -0
- data/lib/doc2json/version.rb +3 -0
- data/test/.keep +0 -0
- metadata +157 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 762219781b46ca4db9d85ca3d83a798a31021744
|
4
|
+
data.tar.gz: fb798ecaf0c747cd1bed1f4d348f68d59eac5643
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 637cccc00eed782c08e77baebb448da382cc558fcbecab9ca070a128de95aba8bf18df8e9f6adfa85924be8350381ae2acfea544ea6690e658a1b5f372e72520
|
7
|
+
data.tar.gz: ea1ff7a5a0ffde423286c3c183e52473938c19ecc1e85499544f9ac22e998417be59ea8fcc339af70c00f53e35bd0996f827c4308452fca4b4620e0f9c3ac2a4
|
data/.gitignore
ADDED
data/CONTRIBUTING.md
ADDED
File without changes
|
data/Gemfile
ADDED
data/LICENSE.md
ADDED
File without changes
|
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
Overview
|
2
|
+
========
|
3
|
+
doc2json generates a JSON based ruby documentation with YARD.
|
4
|
+
|
5
|
+
Installation
|
6
|
+
============
|
7
|
+
|
8
|
+
```bash
|
9
|
+
gem install doc2json
|
10
|
+
```
|
11
|
+
|
12
|
+
Afterwards you can generate a machine friendly documentation for
|
13
|
+
your project.
|
14
|
+
|
15
|
+
Usage
|
16
|
+
=====
|
17
|
+
|
18
|
+
```bash
|
19
|
+
doc2json "lib/**/.rb" "doc/json"
|
20
|
+
```
|
21
|
+
This will generate a json based documentation for all `*.rb` files inside
|
22
|
+
your `lib` directory and outputs the files in `./doc/json`
|
23
|
+
|
24
|
+
License
|
25
|
+
=======
|
26
|
+
Licensed under the MIT License
|
27
|
+
(c) Jens Nazarenus, 2014
|
data/Rakefile
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'rdoc'
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), *%w[lib]))
|
6
|
+
|
7
|
+
# Returns the name of the project
|
8
|
+
def name
|
9
|
+
@name ||= Dir['*.gemspec'].first.split('.').first
|
10
|
+
end
|
11
|
+
|
12
|
+
# Returns the version number of the project
|
13
|
+
def version
|
14
|
+
line = File.read("lib/#{name}/version.rb")[/^\s*VERSION\s*=\s*.*/]
|
15
|
+
line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
|
16
|
+
end
|
17
|
+
|
18
|
+
task :default => [:test]
|
19
|
+
|
20
|
+
# << test
|
21
|
+
require 'rake/testtask'
|
22
|
+
Rake::TestTask.new(:test) do |test|
|
23
|
+
test.libs << 'lib' << 'test'
|
24
|
+
test.pattern = 'test/**/test_*.rb'
|
25
|
+
test.verbose = true
|
26
|
+
end
|
27
|
+
|
28
|
+
# << rdoc
|
29
|
+
require 'rdoc/task'
|
30
|
+
Rake::RDocTask.new do |rdoc|
|
31
|
+
rdoc.rdoc_dir = 'rdoc'
|
32
|
+
rdoc.title = "#{name} #{version}"
|
33
|
+
rdoc.rdoc_files.include('README*')
|
34
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
35
|
+
end
|
data/bin/doc2json
ADDED
data/doc2json.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "doc2json/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "doc2json"
|
7
|
+
s.version = Doc2Json::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Jens Nazarenus"]
|
10
|
+
s.email = ["me@jens-na.de"]
|
11
|
+
s.homepage = "https://github.com/jens-na/doc2json"
|
12
|
+
s.summary = %q{Generate JSON based Ruby documentation}
|
13
|
+
s.description = %q{Generate JSON based Ruby documentations with yard}
|
14
|
+
|
15
|
+
s.add_runtime_dependency("yard", "~> 0.8.7.4")
|
16
|
+
s.add_runtime_dependency("json", "~> 1.8.1")
|
17
|
+
|
18
|
+
s.add_development_dependency("rspec", "~>2.14.1")
|
19
|
+
s.add_development_dependency('rake', "~> 10.1.1")
|
20
|
+
s.add_development_dependency('redgreen', "~> 1.2.2")
|
21
|
+
s.add_development_dependency('shoulda-context', "~> 1.1.6")
|
22
|
+
s.add_development_dependency('rr', "~> 1.1.2")
|
23
|
+
|
24
|
+
s.files = `git ls-files`.split("\n")
|
25
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
26
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
27
|
+
s.require_paths = ["lib"]
|
28
|
+
end
|
29
|
+
|
data/lib/doc2json.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
module Doc2Json
|
2
|
+
|
3
|
+
require 'yard'
|
4
|
+
require 'json'
|
5
|
+
require 'fileutils'
|
6
|
+
|
7
|
+
class Generator
|
8
|
+
|
9
|
+
attr_reader :input
|
10
|
+
attr_reader :output
|
11
|
+
attr_reader :options
|
12
|
+
|
13
|
+
# Creates a new generator to output documentation in JSON
|
14
|
+
#
|
15
|
+
# input- the input file pattern as an array which will be passed to Yard
|
16
|
+
# output - the output directory where to store the JSON files, defaults to doc/json
|
17
|
+
# options - an options hash
|
18
|
+
def initialize(input = ["{lib,app}/**/*.rb", "ext/**/*.c"], output = "doc/json", options = {})
|
19
|
+
@input = input
|
20
|
+
@output = output
|
21
|
+
@options = options
|
22
|
+
end
|
23
|
+
|
24
|
+
# Generates the JSON API and outputs the data to the output
|
25
|
+
# directory.
|
26
|
+
def generate
|
27
|
+
classes = registry.all(:class)
|
28
|
+
classes.each do |c|
|
29
|
+
data = methods(c)
|
30
|
+
output(data, c.to_s)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
# Outputs the data for the given class name to file.
|
37
|
+
# Creates directories where neccessary.
|
38
|
+
#
|
39
|
+
# data - the data to write (a hash)
|
40
|
+
# classname - the classname which is used as filename
|
41
|
+
def output(data, classname)
|
42
|
+
sanitized = File.join(@output, classname.gsub('::', '/')).downcase
|
43
|
+
path = Pathname(sanitized).dirname
|
44
|
+
FileUtils.mkdir_p path.to_s unless path.exist?
|
45
|
+
|
46
|
+
File.open("#{sanitized}.json", "w") do |f|
|
47
|
+
f.write(JSON.pretty_generate(data))
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Creates a hash with all the methods inside a class
|
52
|
+
#
|
53
|
+
# c - the class object of Yard
|
54
|
+
#
|
55
|
+
# Returns a hash. For example:
|
56
|
+
# "generate" => "Generates the JSON API"
|
57
|
+
def methods(c)
|
58
|
+
data = Hash.new
|
59
|
+
c.children.each do |m|
|
60
|
+
data[m.name] = m.base_docstring
|
61
|
+
end
|
62
|
+
data
|
63
|
+
end
|
64
|
+
|
65
|
+
# Generates a Yard registry with the specified input file pattern,
|
66
|
+
# passed in the constructor
|
67
|
+
def registry
|
68
|
+
YARD::Registry.load(@input, true)
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
data/test/.keep
ADDED
File without changes
|
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: doc2json
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.pre.alpha.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jens Nazarenus
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: yard
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.7.4
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.8.7.4
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.8.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.8.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.14.1
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.14.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 10.1.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 10.1.1
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: redgreen
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.2.2
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.2.2
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: shoulda-context
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.1.6
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.1.6
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rr
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.1.2
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.1.2
|
111
|
+
description: Generate JSON based Ruby documentations with yard
|
112
|
+
email:
|
113
|
+
- me@jens-na.de
|
114
|
+
executables:
|
115
|
+
- doc2json
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- CONTRIBUTING.md
|
121
|
+
- Gemfile
|
122
|
+
- Gemfile.lock
|
123
|
+
- LICENSE.md
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- bin/doc2json
|
127
|
+
- doc2json.gemspec
|
128
|
+
- lib/doc2json.rb
|
129
|
+
- lib/doc2json/generator.rb
|
130
|
+
- lib/doc2json/version.rb
|
131
|
+
- test/.keep
|
132
|
+
homepage: https://github.com/jens-na/doc2json
|
133
|
+
licenses: []
|
134
|
+
metadata: {}
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">"
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: 1.3.1
|
149
|
+
requirements: []
|
150
|
+
rubyforge_project:
|
151
|
+
rubygems_version: 2.2.2
|
152
|
+
signing_key:
|
153
|
+
specification_version: 4
|
154
|
+
summary: Generate JSON based Ruby documentation
|
155
|
+
test_files:
|
156
|
+
- test/.keep
|
157
|
+
has_rdoc:
|