droutes 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5170a29cf67dc90e0ee5d42699090274abff096
4
- data.tar.gz: cb2c59bc4673ed3c57b7faa74d35da68943023aa
3
+ metadata.gz: e9ee275f75f3f7d41c1ca47ff00d5e21374f00c0
4
+ data.tar.gz: 8f7a4017c5547d13e72ea09cc10efb4d1feba0e1
5
5
  SHA512:
6
- metadata.gz: f09440c38cc9cb56fd0fca2471ac02e1908e8a3d64cf37ff3eaf2a0df748d3d3f1dd8fc0c5e99dc61ba7dc5c641c091879eaa78bda95977aa6ce53fdcdbb046f
7
- data.tar.gz: c69c4a8a1786dce0c687ea58bd3471077bf514811d3ef1ea8b005d1208c4b47e7a2bc2310294bf355fbfb34131ce607cd123e9569fbb8831e7b145f45ffe2740
6
+ metadata.gz: b7a35a2e01f9966a7b82105f7e47f68f54a45bb3dbde6fda2885b50db0a05ac78ea6f0b5fa8f4e8f2d40c6d106dcd7bef8b21dca889385e0b3c4f9853123ac13
7
+ data.tar.gz: 14aaced7ffabc0cf9fffcf29c5887009eea4d1bc0992b18812d8414ae84f9b97b3f532e1db50f77bf7f1f0a13e6b509fdd1b5332605078f05188f980b0bacda3
@@ -107,12 +107,34 @@ DOC
107
107
  end
108
108
 
109
109
  def comments_doc(doc)
110
+ params_dl = '<dl class="dl-horizontal params">'
111
+ example_json = ''
112
+ doc.tags("param").each do |param|
113
+ params_dl += " <dt>#{param.name}</dt><dd>[#{param.types.join('|')}] #{param.text}</dd>"
114
+ eg_param = param.types.first
115
+ eg_text = if ["String", "Symbol"].include?(eg_param)
116
+ '"some string"'
117
+ elsif ["Fixnum", "Integer", "Int"].include?(eg_param)
118
+ rand(100)
119
+ elsif ["Float", "Double", "Numeric"].include?(eg_param)
120
+ (rand * 100.0).round(2)
121
+ elsif eg_param == "Hash"
122
+ '{}'
123
+ elsif eg_param == "Arrray"
124
+ '[]'
125
+ end
126
+ example_json += "\n \"#{param.name}\": #{eg_text},"
127
+ end
128
+ unless example_json.blank?
129
+ example_json = "<p>Example JSON Body</p><pre><code>{#{example_json}\n}</code></pre>"
130
+ end
110
131
  <<DOC
111
132
  <p class="summary">#{doc.summary}</p>
112
133
  <dl class="dl-horizontal params">
113
- #{doc.tags("param").collect{|param| "<dt>#{param.name}</dt><dd>[#{param.types.join("|")}] #{param.text}</dd>"}.join("\n")}
134
+ #{params_dl}
114
135
  #{(ret = doc.tags("return").first) and "<dt>[return]</dt><dd>#{ret.text}</dd>"}
115
136
  </dl>
137
+ #{example_json}
116
138
  DOC
117
139
  end
118
140
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: droutes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Margison
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-17 00:00:00.000000000 Z
11
+ date: 2014-07-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Generating documentation for REST endpoints for client developers can
14
14
  be a pain, but droutes can make it easy.