doc-digger 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 17164d4df2f3a412e76adcfeae6d4d10328f28bc
4
+ data.tar.gz: be414103a11f78c85ad4d4914a3b96f896045e54
5
+ SHA512:
6
+ metadata.gz: 3f4de6a9a70659a912341a5a4043a50a9ad7cefddee6164eb6eb481728568fb58d0a0b65da544f76955f040953106a9b03eefa86beb1bb8fbaab4dc62133615c
7
+ data.tar.gz: d2dcaab2fa40f572334d1f344ad185a475821c3f4a1760256623bd82402dc6757fbfde44731c9fa4f679beafc9e49fe5db86bc62664a5760d62009efeb50c3b7
@@ -0,0 +1,10 @@
1
+ *.gem
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,16 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ - 2.4.0
6
+ before_install: gem install bundler -v 1.12.5
7
+ script: bundle exec rspec spec
8
+ notifications:
9
+ email:
10
+ recipients:
11
+ - wootaw@gmail.com
12
+ on_failure: change
13
+ on_success: never
14
+ addons:
15
+ code_climate:
16
+ repo_token: 7fedad134e1b7d283411989b2063972bb9fada64a076b9a2a6bf6c523baa4057
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at wootaw@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://gems.ruby-china.org'
2
+
3
+ # Specify your gem's dependencies in restwoods.gemspec
4
+ gemspec
@@ -0,0 +1,11 @@
1
+ guard :rspec, cmd: "bundle exec rspec --color --format=doc --format=Nc" do
2
+ # watch /lib/ files
3
+ watch(%r{^lib/(.+).rb$}) do |m|
4
+ "spec/#{m[1]}_spec.rb"
5
+ end
6
+
7
+ # watch /spec/ files
8
+ watch(%r{^spec/(.+).rb$}) do |m|
9
+ "spec/#{m[1]}.rb"
10
+ end
11
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 wootaw
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,208 @@
1
+ # DocDigger
2
+
3
+ [![Build Status](https://travis-ci.org/wootaw/doc-digger.svg?branch=master)](https://travis-ci.org/wootaw/doc-digger)
4
+ [![Gem Version](https://badge.fury.io/rb/doc-digger.png)](http://badge.fury.io/rb/doc-digger)
5
+ [![Code Climate](https://codeclimate.com/github/wootaw/doc-digger/badges/gpa.svg)](https://codeclimate.com/github/wootaw/doc-digger)
6
+ [![Test Coverage](https://codeclimate.com/github/wootaw/doc-digger/badges/coverage.svg)](https://codeclimate.com/github/wootaw/doc-digger/coverage)
7
+
8
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/doc-digger`. To experiment with that code, run `bin/console` for an interactive prompt.
9
+
10
+ TODO: Delete this and the text above, and describe your gem
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'doc-digger'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install doc-digger
27
+
28
+ ## Basic Usage
29
+
30
+ DocDigger is a tool for generating RESTful web API documentation by analyzing block comments. Below is a simple example showing some of the more common features of DocDigger in documenting parts of the Twitter API that created by Grape.
31
+
32
+ ```ruby
33
+ module Twitter
34
+
35
+ =begin
36
+ @doc (twitter) Twitter
37
+ This row is a description of this document.
38
+ Detail:
39
+
40
+ This is document of number one.
41
+ It do not anything. Just to at here.
42
+
43
+ This is the second paragraph of this document description.
44
+ It do not anything, too.
45
+ =end
46
+ class API < Grape::API
47
+ version 'v1'
48
+ format :json
49
+ prefix :api
50
+
51
+ resource :statuses do
52
+ =begin
53
+ @res get /api/v1/statuses/public_timeline Return a public timeline
54
+
55
+ @res_response {Object[]} data Status List
56
+ @res_response {String} data.id Status ID
57
+ @res_response {String} data.status Your status
58
+ =end
59
+ get :public_timeline do
60
+ end
61
+
62
+ =begin
63
+ @res get /api/v1/statuses/home_timeline Return a personal timeline
64
+ @res_error (401) msg 401 Unauthorized
65
+
66
+ @res_response {Object[]} data Status List
67
+ @res_response {String} data.id Status ID
68
+ @res_response {String} data.status Your status
69
+ =end
70
+ get :home_timeline do
71
+ end
72
+
73
+ =begin
74
+ @res get /api/v1/statuses/:id Return a status
75
+ @res_param (path) {Number} id Status id
76
+
77
+ @res_response {String} id Status ID
78
+ @res_response {String} status Your status
79
+
80
+ @res_state deprecated
81
+ =end
82
+ route_param :id do
83
+ get do
84
+ end
85
+ end
86
+
87
+ =begin
88
+ @res post /api/v1/statuses Create a status
89
+ @res_param (form) {String} status Your status
90
+ @res_response (body=401) msg 401 Unauthorized
91
+ =end
92
+ post do
93
+ end
94
+
95
+ =begin
96
+ @res put /api/v1/statuses/:id Update a status
97
+ @res_param (path) {String} id Status ID
98
+ @res_param (form) {String} status Your status
99
+ @res_response (body=401) msg 401 Unauthorized
100
+ =end
101
+ put ':id' do
102
+ end
103
+
104
+ =begin
105
+ @res delete /api/v1/statuses/:id Delete a status
106
+ @res_param (path) {String} id Status ID
107
+ @res_response (body=401) msg 401 Unauthorized
108
+ @res_state coming This resource will be coming soon
109
+ =end
110
+ delete ':id' do
111
+ end
112
+ end
113
+ end
114
+ end
115
+ ```
116
+
117
+ ## Supported Programming Languages
118
+
119
+ - Java, JavaScript, C#, Go, Dart, PHP, Scala (all DocStyle capable languages):
120
+ ```c
121
+ /**
122
+ * @doc (twitter) Twitter
123
+ */
124
+ ```
125
+
126
+ - ruby
127
+ ```ruby
128
+ =begin
129
+ @doc (twitter) Twitter
130
+ =end
131
+ ```
132
+
133
+ - perl
134
+ ```perl
135
+ #**
136
+ # @doc (twitter) Twitter
137
+ #*
138
+ ```
139
+
140
+ - python
141
+ ```python
142
+ """
143
+ @doc (twitter) Twitter
144
+ """
145
+ ```
146
+
147
+ - elixir
148
+ ```elixir
149
+ @dd """
150
+ @doc (twitter) Twitter
151
+ """
152
+ ```
153
+
154
+ - coffee
155
+ ```coffee
156
+ ###
157
+ @doc (twitter) Twitter
158
+ ###
159
+ ```
160
+
161
+ - lua
162
+ ```lua
163
+ --[[
164
+ @doc (twitter) Twitter
165
+ ]]
166
+ ```
167
+
168
+ - erlang
169
+ ```erlang
170
+ %{
171
+ % @doc (twitter) Twitter
172
+ %}
173
+ ```
174
+
175
+ ## Commands
176
+
177
+
178
+
179
+ ### @doc
180
+
181
+ | Field | Description |
182
+ | --- | --- |
183
+ | name | |
184
+ | summary | |
185
+ | descriptions | |
186
+
187
+ ### @res
188
+
189
+ ### @doc_state and @res_state
190
+
191
+ ### @res_param @res_response
192
+
193
+ ## Descriptions
194
+
195
+ ## Development
196
+
197
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
198
+
199
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
200
+
201
+ ## Contributing
202
+
203
+ Bug reports and pull requests are welcome on GitHub at https://github.com/wootaw/doc-digger. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
204
+
205
+
206
+ ## License
207
+
208
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "restwoods"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,43 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'doc-digger/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "doc-digger"
8
+ spec.version = DocDigger::VERSION
9
+ spec.authors = ["wootaw"]
10
+ spec.email = ["wootaw@gmail.com"]
11
+
12
+ spec.summary = "This gem generate RESTful web API documentation."
13
+ spec.description = "RESTWoods is a tool for generating RESTful web API documentation by analyzing block comments."
14
+ spec.homepage = "https://github.com/wootaw/doc-digger"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = ""
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ # spec.post_install_message = "Thanks for installing!"
31
+
32
+ spec.add_development_dependency "bundler", "~> 1.12"
33
+ spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_development_dependency "rspec", "~> 3.0"
35
+ spec.add_development_dependency "rspec-nc", '~> 0'
36
+ spec.add_development_dependency "awesome_print", '~> 1.7'
37
+ spec.add_development_dependency "guard", '~> 2'
38
+ spec.add_development_dependency "guard-rspec", '~> 4'
39
+ spec.add_development_dependency "pry", '~> 0'
40
+ spec.add_development_dependency "pry-remote", '~> 0'
41
+ spec.add_development_dependency "pry-nav", '~> 0'
42
+ spec.add_development_dependency "codeclimate-test-reporter", '~> 0.4.8'
43
+ end
@@ -0,0 +1,9 @@
1
+ require "base64"
2
+ require "json"
3
+ require "doc-digger/version"
4
+ require "doc-digger/line_parser"
5
+ require "doc-digger/file_parser"
6
+
7
+ module DocDigger
8
+ # Your code goes here...
9
+ end
@@ -0,0 +1,115 @@
1
+ module DocDigger
2
+ class FileParser
3
+
4
+ LANGUAGES = {
5
+ java: [['/**', '*/'], /\A\.(js|jsx|c|cs|java|php?|ts|cpp|go|scala|dart)\Z/],
6
+ ruby: [['=begin', '=end'], /\A\.(rb)\Z/],
7
+ perl: [['#**', '#*'], /\A\.(perl|pl|pm)\Z/],
8
+ python: [['"""', '"""'], /\A\.(py)\Z/],
9
+ elixir: [['@dd """', '"""'], /\A\.(ex|exs?)\Z/],
10
+ erlang: [['%{', '%}'], /\A\.(erl)\Z/],
11
+ coffee: [['###', '###'], /\A\.(coffee)\Z/],
12
+ lua: [['--[[', ']]'], /\A\.(lua)\Z/]
13
+ }
14
+ MARKDOWNS = /\A\s*(#+|>|\-\s*|\d+\.|`{3})/
15
+
16
+ attr_reader :document_name
17
+
18
+ def initialize(filename)
19
+ @name = filename
20
+ @type = File.ftype(filename)
21
+ @ext = File.extname(@name)
22
+ @document_name = File.basename(filename, @ext)
23
+ end
24
+
25
+ def lang
26
+ @flang ||= check_lang
27
+ end
28
+
29
+ def results
30
+ @results ||= parse
31
+ end
32
+
33
+ def parse
34
+ @results = []
35
+ File.open(@name, "r") do |f|
36
+ started = false
37
+ f.each_line do |s|
38
+ if s.strip == LANGUAGES[lang][0][0]
39
+ started = true
40
+ @source = false
41
+ next
42
+ end
43
+
44
+ started = false if started && s.strip == LANGUAGES[lang][0][1]
45
+ process_line(s) if started
46
+ end
47
+ end if @type == "file" && !lang.nil?
48
+ @results
49
+ end
50
+
51
+ protected
52
+
53
+ def process_line(str)
54
+ line_parser = LineParser.new(str, lang)
55
+ hash = line_parser.parse
56
+ if hash[:type] == :joint
57
+ return if @recent_command.nil?
58
+ process_descriptions(branch(@recent_command), hash)
59
+ else
60
+ branch(hash, true).merge!(hash[:data])
61
+ @recent_command = hash.select { |k| k != :data }
62
+ @recent_command[:space] = line_parser.indentation
63
+ @linebreak = false
64
+ end
65
+ end
66
+
67
+ def branch(command, initial=false)
68
+ @results << {} if initial && (@results.length == 0 || command[:type] == :doc && command[:part] == :main)
69
+ item = @results.last
70
+
71
+ if command[:type] == :res
72
+ if initial
73
+ item[:resources] = [] unless item.has_key?(:resources)
74
+ item[:resources] << {} if command[:part] == :main
75
+ end
76
+ item = item[:resources].last
77
+ end
78
+
79
+ case command[:part]
80
+ when :state
81
+ item[:state] = {} if initial && !item.has_key?(:state)
82
+ item = item[:state]
83
+ when /\A(param|header|response|bind)\Z/
84
+ part = "#{command[:part]}s".to_sym
85
+ if initial
86
+ item[part] = [] unless item.has_key?(part)
87
+ item[part] << {}
88
+ end
89
+ item = item[part].last
90
+ end
91
+ item
92
+ end
93
+
94
+ def process_descriptions(item, hash)
95
+ text = hash[:text].to_s.gsub(/\A\s{,#{@recent_command[:space] + 2}}/, '').rstrip
96
+ if text.length == 0
97
+ @linebreak = true
98
+ return
99
+ end
100
+ markdown = MARKDOWNS === text || @source
101
+ @source ^= /\A\s*`{3}/ === text if markdown
102
+
103
+ item[:descriptions] = [[]] unless item.has_key?(:descriptions)
104
+ item[:descriptions] << [] if @linebreak || markdown
105
+ item[:descriptions].last << text
106
+ @linebreak = markdown
107
+ end
108
+
109
+ def check_lang
110
+ LANGUAGES.each { |l, options| return l if options[1] === @ext }
111
+ nil
112
+ end
113
+
114
+ end
115
+ end
@@ -0,0 +1,120 @@
1
+ module DocDigger
2
+ class LineParser
3
+
4
+ PICKS = { java: /\A\s*\*/, erlang: /\A\s*%/, perl: /\A\s*#/ }
5
+ COMMANDS = /\A@(doc(\_state)?|res(\_(param|response|state|bind))?|cmd\_(def|use))\Z/
6
+ PARAMETER_LOCATIONS = /\Apath|query|header|form|body\Z/
7
+ RESPONSE_LOCATIONS = /\Aheader|body\Z/
8
+
9
+ def initialize(str, clazz)
10
+ @clazz = clazz
11
+ pick = PICKS[clazz]
12
+ @str = pick.nil? ? str : str.gsub(pick, '')
13
+ end
14
+
15
+ def parse
16
+ parts = @str.strip.split(/\s+/)
17
+ command = parts[0].to_s.match(COMMANDS)
18
+ if command.nil? || command[1].nil?
19
+ { type: :joint, text: @str }
20
+ else
21
+ send(command[1], parts[1..-1], command)
22
+ end
23
+ end
24
+
25
+ def indentation
26
+ @indentation ||= @str.match(/\A\s*/)[0].length
27
+ end
28
+
29
+ protected
30
+
31
+ def cmd(args, cmd)
32
+ { type: :cmd, part: cmd[1].split("_")[1].to_sym, data: { name: args[0] } }
33
+ end
34
+
35
+ def doc(args, _cmd)
36
+ { type: :doc, part: :main, data: {} }.tap do |result|
37
+ m = args[0].match(/\((\w+)\)/)
38
+ result[:data][:summary] = args[[m].compact.length..-1].join(" ")
39
+ result[:data][:name] = m[1] unless m.nil?
40
+ end
41
+ end
42
+
43
+ def res(args, _cmd)
44
+ {
45
+ type: :res,
46
+ part: :main,
47
+ data: { method: args[0], path: args[1], summary: args[2..-1].join(" ") }
48
+ }
49
+ end
50
+
51
+ def res_bind(args, _cmd)
52
+ { type: :res, part: :bind, data: {} }.tap do |result|
53
+ m = args[0].match(/\((param|header|return|error)\)/)
54
+ result[:data][:scope] = m[1] unless m.nil?
55
+ result[:data][:command] = args[[m].compact.length]
56
+ result[:data][:vars] = args[([m].compact.length + 1)..-1]
57
+ end
58
+ end
59
+
60
+ def state(args, cmd)
61
+ {
62
+ type: cmd[1].split("_")[0].to_sym,
63
+ part: :state,
64
+ data: { name: args[0], summary: args[1..-1].join(" ") }
65
+ }
66
+ end
67
+
68
+ def analyze_arguments(args)
69
+ { group: args[0].to_s.match(/\((.+)\)/) }.tap do |r|
70
+ r[:type] = (r[:group].nil? ? args[0] : args[1]).to_s.match(/\{(.+)\}/)
71
+ r[:names] = args[[r[:group], r[:type]].compact.length].to_s
72
+ r[:name] = r[:names].match(/\A\[(.+)\]\Z/)
73
+ r[:default] = (r[:name].nil? ? r[:names] : r[:name][1]).split("=")
74
+ r[:parent] = r[:default][0].split(".")
75
+ end
76
+ end
77
+
78
+ def res_io(args, cmd)
79
+ { type: :res, part: cmd[4].to_sym, data: {} }.tap do |result|
80
+ r = analyze_arguments(args)
81
+ unless r[:type].nil?
82
+ options = r[:type][1].split("=")
83
+ array = options[0].match(/(\w+)(\[\])?\Z/)
84
+
85
+ result[:data][:options] = options[1].split(",") if options.length == 2
86
+ unless array.nil?
87
+ result[:data][:array] = !array[2].nil?
88
+ result[:data][:type] = array[1]
89
+ end
90
+ end
91
+
92
+ case result[:part]
93
+ when :param
94
+ location = (r[:group] || [])[1]
95
+ result[:data][:location] = PARAMETER_LOCATIONS === location ? location : 'query'
96
+ result[:data][:required] = location == "path" || r[:name].nil?
97
+ result[:data][:default] = r[:default][1] if r[:default].length == 2
98
+ result[:data][:name] = r[:parent].length == 1 ? r[:default][0] : r[:parent][-1]
99
+ when :response
100
+ location = (r[:group] || [nil, 'body'])[1].split('=')
101
+ result[:data][:group] = location[1] if location.length > 1
102
+ result[:data][:location] = RESPONSE_LOCATIONS === location[0] ? location[0] : 'body'
103
+ result[:data][:name] = r[:parent].length == 1 ? r[:names] : r[:parent][-1]
104
+ end
105
+
106
+ result[:data][:parent] = r[:parent][0..-2] if r[:parent].length > 1
107
+ result[:data][:summary] = args[([r[:group], r[:type]].compact.length + 1)..-1].join(' ')
108
+ end
109
+ end
110
+
111
+ alias_method :res_param, :res_io
112
+ alias_method :res_response, :res_io
113
+
114
+ alias_method :doc_state, :state
115
+ alias_method :res_state, :state
116
+
117
+ alias_method :cmd_def, :cmd
118
+ alias_method :cmd_use, :cmd
119
+ end
120
+ end
@@ -0,0 +1,3 @@
1
+ module DocDigger
2
+ VERSION = "0.1.1"
3
+ end
metadata ADDED
@@ -0,0 +1,215 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: doc-digger
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - wootaw
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-02-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-nc
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: awesome_print
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.7'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '2'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard-rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '4'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '4'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: pry-remote
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry-nav
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: codeclimate-test-reporter
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.4.8
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 0.4.8
167
+ description: RESTWoods is a tool for generating RESTful web API documentation by analyzing
168
+ block comments.
169
+ email:
170
+ - wootaw@gmail.com
171
+ executables: []
172
+ extensions: []
173
+ extra_rdoc_files: []
174
+ files:
175
+ - ".gitignore"
176
+ - ".rspec"
177
+ - ".travis.yml"
178
+ - CODE_OF_CONDUCT.md
179
+ - Gemfile
180
+ - Guardfile
181
+ - LICENSE.txt
182
+ - README.md
183
+ - Rakefile
184
+ - bin/console
185
+ - bin/setup
186
+ - doc-digger.gemspec
187
+ - lib/doc-digger.rb
188
+ - lib/doc-digger/file_parser.rb
189
+ - lib/doc-digger/line_parser.rb
190
+ - lib/doc-digger/version.rb
191
+ homepage: https://github.com/wootaw/doc-digger
192
+ licenses:
193
+ - MIT
194
+ metadata: {}
195
+ post_install_message:
196
+ rdoc_options: []
197
+ require_paths:
198
+ - lib
199
+ required_ruby_version: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - ">="
202
+ - !ruby/object:Gem::Version
203
+ version: '0'
204
+ required_rubygems_version: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ requirements: []
210
+ rubyforge_project:
211
+ rubygems_version: 2.5.1
212
+ signing_key:
213
+ specification_version: 4
214
+ summary: This gem generate RESTful web API documentation.
215
+ test_files: []