prmd 0.12.0 → 0.13.0

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: d1010706b78a9b6d770bb52a5a3bc0dd40cbb516
4
- data.tar.gz: 0c6021aedeb0bbeaee1af485ffdddcb7c4a83ec5
3
+ metadata.gz: 906209c8a327e103f1392faff3f4c7a35caac7b9
4
+ data.tar.gz: 42fbce50f4e8477a1a5c1607521b49101a37b349
5
5
  SHA512:
6
- metadata.gz: 812720e3b67bcf3f524a545364129751e4b87afb10dc67c74aaf586f6d18f5de644eaa20852bbe68017439004a3a6571eb4230dee4222221344c243a1ad26c99
7
- data.tar.gz: 442813d217485037daf7aa7a9854c99ec76ddd6371f4d0945c69a9d0000812a232a6b8e8acc6d793f8a4a94952f41335c83a39fd4b592cda212e9526fd5cdc81
6
+ metadata.gz: 1b246f23874af73656586f681cc2002ce8f37ba313ec128dc17ae4ee84814b641fd6bd42fd05007d4f040a289276b8be1fe7167990f6041b43c66ea2009339fb
7
+ data.tar.gz: 7bb6505cccc8df5313a2fd1b87411feac21ac4e7f126046be329a3a0d52e7bcd7f58428f66b8295c3583d5892d63b4f6b74c98499873031e8971f3cac302cede
data/README.md CHANGED
@@ -129,7 +129,8 @@ Available options (and their defaults)
129
129
  {
130
130
  "doc": {
131
131
  "url_style": "default", // can also be "json"
132
- "disable_title_and_description": false // remove the title and the description, useful when using your own custom header
132
+ "disable_title_and_description": false, // remove the title and the description, useful when using your own custom header
133
+ "toc": false // insert the table of content for json scheme documentation to the top of the file. (default disable)
133
134
  }
134
135
  }
135
136
  ```
@@ -138,6 +138,7 @@ Links that expect a custom http header MUST include the following attributes:
138
138
  },
139
139
  "title": "Update"
140
140
  }
141
+ ]
141
142
  }
142
143
  ```
143
144
 
@@ -28,7 +28,8 @@ module Prmd
28
28
  def append_default_options(options)
29
29
  options[:doc] = {
30
30
  url_style: 'default',
31
- disable_title_and_description: false
31
+ disable_title_and_description: false,
32
+ toc: false
32
33
  }.merge(options[:doc])
33
34
  end
34
35
 
@@ -21,6 +21,8 @@ module Prmd
21
21
  # @return [Array<String>, Hash<String, String>] list of files
22
22
  attr_accessor :files
23
23
 
24
+ attr_accessor :toc
25
+
24
26
  # Creates a new task with name +name+.
25
27
  #
26
28
  # @overload initialize(name)
@@ -1,3 +1,4 @@
1
+ <% if options[:doc][:toc] %><%= Prmd::Template::load('table_of_contents.erb', options[:template]).result({schema: schema}) %> <%end %>
1
2
  <%=
2
3
  schemata_template = Prmd::Template::load('schemata.md.erb', options[:template])
3
4
 
@@ -137,7 +137,7 @@
137
137
  end
138
138
 
139
139
  if value['pattern']
140
- description += "<br/> **pattern:** `#{value['pattern'].gsub /\|/, '&#124;'}`"
140
+ description += "<br/> **pattern:** `#{value['pattern']}`"
141
141
  end
142
142
 
143
143
  if value['minLength'] || value['maxLength']
@@ -3,7 +3,7 @@
3
3
  response_example = link['response_example']
4
4
  link_schema_properties_template = Prmd::Template.load_template('link_schema_properties.md.erb', options[:template])
5
5
  -%>
6
- ### <%= title %> <%= link['title'] %>
6
+ ### <a name="link-<%= link['method'] %>-<%= resource %>-<%= link['href'] %>"><%= title %> <%= link['title'] %></a>
7
7
 
8
8
  <%= link['description'] %>
9
9
 
@@ -0,0 +1,9 @@
1
+ # The table of contents
2
+ <% schema['properties'].keys.sort.map do |key| %>
3
+ <% resource, property = key, schema['properties'][key] %>
4
+ <% _, schemata = schema.dereference(property) %>
5
+ - <a href="#resource-<%= resource %>"><%= schemata['title'].split(' - ', 2).last %></a>
6
+ <% schemata.fetch('links', []).each do |l| %>
7
+ - <a href="#link-<%= l['method'] %>-<%= resource %>-<%= l['href'] %>"><%= l['method'] %> <%= l['href'] %></a>
8
+ <% end %>
9
+ <% end %>
@@ -2,7 +2,7 @@
2
2
  module Prmd
3
3
  # Well, duh, its a Version module, what did you expect?
4
4
  module Version
5
- MAJOR, MINOR, TEENY, PATCH = 0, 12, 0, nil
5
+ MAJOR, MINOR, TEENY, PATCH = 0, 13, 0, nil
6
6
  # version string
7
7
  # @return [String]
8
8
  STRING = [MAJOR, MINOR, TEENY, PATCH].compact.join('.').freeze
@@ -66,7 +66,7 @@
66
66
  },
67
67
  "properties": {
68
68
  "patternProperties": {
69
- "^[a-z][a-zA-Z_]*[a-zA-Z]$": {
69
+ "^[a-z0-9][a-zA-Z0-9_]*[a-zA-Z0-9]$": {
70
70
  "$ref": "#/definitions/resourceProperty"
71
71
  }
72
72
  },
@@ -28,11 +28,20 @@ class InteragentRenderTest < Minitest::Test
28
28
  def test_render_for_schema_with_property_defined_with_oneOf
29
29
  markdown = render
30
30
 
31
- assert_match(/\*\*options\/\[OPTION1\]\.type\*\*/, markdown)
32
- assert_match(/\*\*options\/\[OPTION2\]\.type\*\*/, markdown)
31
+ assert_match(/\*\*options\/\[OPTION1\]\.type\*\*/, markdown)
32
+ assert_match(/\*\*options\/\[OPTION2\]\.type\*\*/, markdown)
33
33
  end
34
34
 
35
+ def test_render_for_toc
36
+ schema = Prmd::Schema.new(data)
37
+ template = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib', 'prmd', 'templates'))
38
+ markdown = Prmd.render(schema, template: template, doc: { toc: true })
35
39
 
40
+ assert_match /^# The table of contents/, markdown
41
+ assert_match '<a href="#resource-app"', markdown
42
+ assert_match '- <a href="#link-POST-app-/apps">POST /apps', markdown
43
+ assert_match '<a name="link-POST-app-/apps"', markdown
44
+ end
36
45
 
37
46
  def test_render_for_example_as_an_array
38
47
  # matches -d '[{...}]' taking into account line breaks and spacing
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prmd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - geemus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-09 00:00:00.000000000 Z
11
+ date: 2016-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erubis
@@ -149,6 +149,7 @@ files:
149
149
  - lib/prmd/templates/schemata/helper.erb
150
150
  - lib/prmd/templates/schemata/link.md.erb
151
151
  - lib/prmd/templates/schemata/link_curl_example.md.erb
152
+ - lib/prmd/templates/table_of_contents.erb
152
153
  - lib/prmd/url_generator.rb
153
154
  - lib/prmd/url_generators/generators/default.rb
154
155
  - lib/prmd/url_generators/generators/json.rb