nexmo-oas-renderer 0.7.1 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/Gemfile.lock +16 -7
  4. data/lib/nexmo/oas/renderer/app.rb +2 -4
  5. data/lib/nexmo/oas/renderer/presenters/api_specification.rb +1 -1
  6. data/lib/nexmo/oas/renderer/presenters/open_api_specification.rb +1 -1
  7. data/lib/nexmo/oas/renderer/public/assets/stylesheets/nexmo-oas-renderer.css +1 -1
  8. data/lib/nexmo/oas/renderer/version.rb +1 -1
  9. data/lib/nexmo/oas/renderer/views/open_api/_model.erb +1 -1
  10. data/lib/nexmo/oas/renderer/views/open_api/_parameter_groups.erb +7 -37
  11. data/lib/nexmo/oas/renderer/views/open_api/_tabbed_parameters.erb +53 -0
  12. data/nexmo-oas-renderer.gemspec +1 -0
  13. metadata +17 -53
  14. data/lib/nexmo/oas/renderer/filters/anchor.rb +0 -17
  15. data/lib/nexmo/oas/renderer/filters/audio.rb +0 -21
  16. data/lib/nexmo/oas/renderer/filters/block_escape.rb +0 -24
  17. data/lib/nexmo/oas/renderer/filters/break.rb +0 -13
  18. data/lib/nexmo/oas/renderer/filters/code.rb +0 -64
  19. data/lib/nexmo/oas/renderer/filters/code_snippet.rb +0 -194
  20. data/lib/nexmo/oas/renderer/filters/code_snippet_list.rb +0 -33
  21. data/lib/nexmo/oas/renderer/filters/code_snippets.rb +0 -158
  22. data/lib/nexmo/oas/renderer/filters/collapsible.rb +0 -27
  23. data/lib/nexmo/oas/renderer/filters/columns.rb +0 -50
  24. data/lib/nexmo/oas/renderer/filters/concept_list.rb +0 -33
  25. data/lib/nexmo/oas/renderer/filters/dynamic_content.rb +0 -30
  26. data/lib/nexmo/oas/renderer/filters/external_link.rb +0 -32
  27. data/lib/nexmo/oas/renderer/filters/frontmatter.rb +0 -14
  28. data/lib/nexmo/oas/renderer/filters/heading.rb +0 -61
  29. data/lib/nexmo/oas/renderer/filters/icon.rb +0 -22
  30. data/lib/nexmo/oas/renderer/filters/indent.rb +0 -20
  31. data/lib/nexmo/oas/renderer/filters/inline_escape.rb +0 -17
  32. data/lib/nexmo/oas/renderer/filters/js_sequence_diagram.rb +0 -21
  33. data/lib/nexmo/oas/renderer/filters/label.rb +0 -32
  34. data/lib/nexmo/oas/renderer/filters/language.rb +0 -15
  35. data/lib/nexmo/oas/renderer/filters/markdown.rb +0 -85
  36. data/lib/nexmo/oas/renderer/filters/modal.rb +0 -41
  37. data/lib/nexmo/oas/renderer/filters/partial.rb +0 -28
  38. data/lib/nexmo/oas/renderer/filters/php_inliner.rb +0 -15
  39. data/lib/nexmo/oas/renderer/filters/screenshot.rb +0 -26
  40. data/lib/nexmo/oas/renderer/filters/tab.rb +0 -250
  41. data/lib/nexmo/oas/renderer/filters/techio.rb +0 -24
  42. data/lib/nexmo/oas/renderer/filters/tooltip.rb +0 -22
  43. data/lib/nexmo/oas/renderer/filters/tutorial_link.rb +0 -27
  44. data/lib/nexmo/oas/renderer/filters/tutorials.rb +0 -28
  45. data/lib/nexmo/oas/renderer/filters/unfreeze.rb +0 -20
  46. data/lib/nexmo/oas/renderer/filters/user_personalization.rb +0 -43
  47. data/lib/nexmo/oas/renderer/lib/core_ext/string.rb +0 -14
  48. data/lib/nexmo/oas/renderer/lib/redcarpet.rb +0 -14
  49. data/lib/nexmo/oas/renderer/models/code_snippet.rb +0 -75
  50. data/lib/nexmo/oas/renderer/models/tutorial.rb +0 -83
  51. data/lib/nexmo/oas/renderer/pipelines/markdown_pipeline.rb +0 -52
  52. data/lib/nexmo/oas/renderer/services/code_language_api.rb +0 -98
  53. data/lib/nexmo/oas/renderer/views/code_snippets/_application_messages_dispatch.html.erb +0 -9
  54. data/lib/nexmo/oas/renderer/views/code_snippets/_application_rtc.html.erb +0 -41
  55. data/lib/nexmo/oas/renderer/views/code_snippets/_application_voice.html.erb +0 -24
  56. data/lib/nexmo/oas/renderer/views/code_snippets/_code_only.html.erb +0 -6
  57. data/lib/nexmo/oas/renderer/views/code_snippets/_configure_client.html.erb +0 -20
  58. data/lib/nexmo/oas/renderer/views/code_snippets/_dependencies.html.erb +0 -11
  59. data/lib/nexmo/oas/renderer/views/code_snippets/_write_code.html.erb +0 -13
  60. data/lib/nexmo/oas/renderer/views/code_snippets/list/plain.html.erb +0 -10
  61. data/lib/nexmo/oas/renderer/views/tutorials/_index.html.erb +0 -32
  62. data/lib/nexmo/oas/renderer/views/tutorials/index.html.erb +0 -7
  63. data/lib/nexmo/oas/renderer/views/tutorials/list/plain.html.erb +0 -5
  64. data/lib/nexmo/oas/renderer/views/tutorials/show.html.erb +0 -8
@@ -1,27 +0,0 @@
1
- module Nexmo
2
- module OAS
3
- module Renderer
4
- module Filters
5
- class Collapsible < Banzai::Filter
6
- def call(input)
7
- input.gsub(/^\|\s(\#{1,6})(\s)?(.+?)\n^\|\n(.+?)\n\n/m) do |_s|
8
- heading = $3
9
- body = $4.gsub(/^\|\n/, "\n")
10
- body = body.gsub(/^\|\s/, '')
11
- parsed_body = MarkdownPipeline.new.call(body)
12
-
13
- <<~HEREDOC
14
- <div class="Vlt-accordion Vlt-box Vlt-box--lesspadding Nxd-accordion-emphasis">
15
- <h5 class="Vlt-accordion__trigger" tabindex="0">#{heading}</h5>
16
- <div class="Vlt-accordion__content Vlt-accordion__content--noborder">
17
- #{parsed_body}
18
- </div>
19
- </div>
20
- HEREDOC
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,50 +0,0 @@
1
- module Nexmo
2
- module OAS
3
- module Renderer
4
- module Filters
5
- class Columns < Banzai::Filter
6
- def call(input)
7
- input.gsub!(%r{{column\:([1-4])\/([1-4])}\n(.+?){end}}m) do
8
- s = []
9
- s << row_start if $1 == '1'
10
- s << column_start($2)
11
- s << $3
12
- s << column_end
13
- s << row_end if $1 == $2
14
- s.join('')
15
- end
16
-
17
- input
18
- end
19
-
20
- private
21
-
22
- def row_start
23
- "FREEZESTART#{Base64.urlsafe_encode64('<div class="row">')}FREEZEEND\n"
24
- end
25
-
26
- def row_end
27
- close_tag
28
- end
29
-
30
- def close_tag
31
- "FREEZESTART#{Base64.urlsafe_encode64('</div>')}FREEZEEND"
32
- end
33
-
34
- def column_start(columns)
35
- html = "<div class='column small-12 medium-#{part_size(columns)}'>"
36
- "FREEZESTART#{Base64.urlsafe_encode64(html)}FREEZEEND\n"
37
- end
38
-
39
- def column_end
40
- "FREEZESTART#{Base64.urlsafe_encode64('</div>')}FREEZEEND\n"
41
- end
42
-
43
- def part_size(columns)
44
- 12 / Integer(columns)
45
- end
46
- end
47
- end
48
- end
49
- end
50
- end
@@ -1,33 +0,0 @@
1
- module Nexmo
2
- module OAS
3
- module Renderer
4
- module Filters
5
- class ConceptList < Banzai::Filter
6
- def call(input)
7
- input.gsub(/```concept_list(.+?)```/m) do |_s|
8
- config = YAML.safe_load($1)
9
-
10
- raise 'concept_list filter takes a YAML config' if config.nil?
11
- raise "concept_list filter requires 'product' or 'concepts' key" unless config['product'] || config['concepts']
12
-
13
- if config['product']
14
- @product = config['product']
15
- @concepts = Concept.by_product(@product)
16
- elsif config['concepts']
17
- @concepts = Concept.by_name(config['concepts'])
18
- end
19
-
20
- @concepts.reject!(&:ignore_in_list)
21
-
22
- return '' if @concepts.empty?
23
-
24
- erb = File.read("#{API.root}/views/concepts/list/plain.html.erb")
25
- html = ERB.new(erb).result(binding)
26
- "FREEZESTART#{Base64.urlsafe_encode64(html)}FREEZEEND"
27
- end
28
- end
29
- end
30
- end
31
- end
32
- end
33
- end
@@ -1,30 +0,0 @@
1
- module Nexmo
2
- module OAS
3
- module Renderer
4
- module Filters
5
- class DynamicContent < Banzai::Filter
6
- def call(input)
7
- input.gsub(/(\s|^)\[\~(.+?)\~\](\s|$)/) do
8
- content = environment_value($2) || config_value($2) || "VALUE NOT SET: #{$2}"
9
- "#{$1}#{content}#{$3}"
10
- end
11
- end
12
-
13
- private
14
-
15
- def environment_value(key)
16
- return nil unless ENV['DYNAMIC_CONTENT']
17
- @environment_dynamic_content ||= YAML.safe_load(ENV['DYNAMIC_CONTENT'])
18
- @environment_dynamic_content ||= YAML.safe_load(temp)
19
- @environment_dynamic_content[key]
20
- end
21
-
22
- def config_value(key)
23
- @config_dynamic_content ||= YAML.load_file("#{API.root}/config/dynamic_content.yml")
24
- @config_dynamic_content[key]
25
- end
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,32 +0,0 @@
1
- module Nexmo
2
- module OAS
3
- module Renderer
4
- module Filters
5
- class ExternalLink < Banzai::Filter
6
- def call(input)
7
- @input = input
8
-
9
- document.css('a').each_with_index do |link, _index|
10
- if link['href']&.start_with?('http') && link['class'] && !link['class'].include?('no-external-marker')
11
- link['target'] = '_blank'
12
- if link.css('svg').empty?
13
- link.add_child <<~HEREDOC
14
- &nbsp;<svg class="Vlt-icon Vlt-icon--smaller Vlt-icon--text-bottom Vlt-blue-dark"><use xlink:href="/assets/symbol/volta-icons.svg#Vlt-icon-open"></use></svg>
15
- HEREDOC
16
- end
17
- end
18
- end
19
-
20
- @document.to_html
21
- end
22
-
23
- private
24
-
25
- def document
26
- @document ||= Nokogiri::HTML::DocumentFragment.parse(@input)
27
- end
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,14 +0,0 @@
1
- module Nexmo
2
- module OAS
3
- module Renderer
4
- module Filters
5
- class Frontmatter < Banzai::Filter
6
- def call(input)
7
- # Remove frontmatter from the input
8
- input.gsub(/\A(---.+?---)/mo, '')
9
- end
10
- end
11
- end
12
- end
13
- end
14
- end
@@ -1,61 +0,0 @@
1
- module Nexmo
2
- module OAS
3
- module Renderer
4
- module Filters
5
- class Heading < Banzai::Filter
6
- def call(input)
7
- @input = input
8
- @headings = []
9
-
10
- heading_tag_list = %w[h1 h2 h3 h4 h5 h6]
11
- headings = document.children.select do |child|
12
- heading_tag_list.include? child.name
13
- end
14
-
15
- headings.each do |heading|
16
- parameterized_heading = parameterized_heading_without_collision(heading)
17
- heading['id'] = parameterized_heading
18
- heading['data-id'] = SecureRandom.hex
19
- heading['class'] = heading[:class]
20
- heading['class'] += ' Vlt-title--icon'
21
-
22
- heading.prepend_child <<~HEREDOC
23
- <a href="##{parameterized_heading}" class="heading-permalink">
24
- <svg class="Vlt-grey"><use xlink:href=\"/assets/symbol/volta-icons.svg#Vlt-icon-link\" /></svg>
25
- </a>
26
- HEREDOC
27
- end
28
-
29
- @document.to_html
30
- end
31
-
32
- private
33
-
34
- def document
35
- @document ||= Nokogiri::HTML::DocumentFragment.parse(@input)
36
- end
37
-
38
- def parameterized_heading_without_collision(heading)
39
- parameterized_heading = nil
40
- index = nil
41
-
42
- loop do
43
- if index
44
- parameterized_heading = "#{heading.text.parameterize}-#{index}"
45
- index += 1
46
- else
47
- parameterized_heading = heading.text.parameterize
48
- index = 2
49
- end
50
-
51
- break if @headings.exclude? parameterized_heading
52
- end
53
-
54
- @headings << parameterized_heading
55
- parameterized_heading
56
- end
57
- end
58
- end
59
- end
60
- end
61
- end
@@ -1,22 +0,0 @@
1
- module Nexmo
2
- module OAS
3
- module Renderer
4
- module Filters
5
- class Icon < Banzai::Filter
6
- def call(input)
7
- input.gsub!('✅', '<svg class="Vlt-green Vlt-icon Vlt-icon--small"><use xlink:href="/assets/symbol/volta-icons.svg#Vlt-icon-check" /></svg>')
8
- input.gsub!('❌', '<svg class="Vlt-red Vlt-icon Vlt-icon--small"><use xlink:href="/assets/symbol/volta-icons.svg#Vlt-icon-cross" /></svg>')
9
-
10
- input.gsub!(/\[icon="(.+?)"\]/) do
11
- <<~HEREDOC
12
- <svg class="Vlt-green Vlt-icon Vlt-icon--small"><use xlink:href="/assets/symbol/volta-icons.svg#Vlt-icon-#{$1}" /></svg>
13
- HEREDOC
14
- end
15
-
16
- input
17
- end
18
- end
19
- end
20
- end
21
- end
22
- end
@@ -1,20 +0,0 @@
1
- module Nexmo
2
- module OAS
3
- module Renderer
4
- module Filters
5
- class Indent < Banzai::Filter
6
- def call(input)
7
- input.gsub(/^^\s{4}\-\>\s(.+?)$/) do
8
- body = MarkdownPipeline.new.call($1)
9
- <<~HEREDOC
10
- <div class="indent">
11
- #{body}
12
- </div>
13
- HEREDOC
14
- end
15
- end
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,17 +0,0 @@
1
- module Nexmo
2
- module OAS
3
- module Renderer
4
- module Filters
5
- class InlineEscape < Banzai::Filter
6
- def call(input)
7
- # Freeze to prevent Markdown formatting
8
- input.gsub(/``(.+?)``/) do |_s|
9
- frozen_code = Base64.urlsafe_encode64("<code>#{$1}</code>")
10
- "FREEZESTART#{frozen_code}FREEZEEND"
11
- end
12
- end
13
- end
14
- end
15
- end
16
- end
17
- end
@@ -1,21 +0,0 @@
1
- module Nexmo
2
- module OAS
3
- module Renderer
4
- module Filters
5
- class JsSequenceDiagram < Banzai::Filter
6
- def call(input)
7
- input.gsub(/```js_sequence_diagram(.+?)```/m) do |_s|
8
- diagram = <<~HEREDOC
9
- <div class="js-diagram">
10
- #{$1}
11
- </div>
12
- HEREDOC
13
-
14
- "FREEZESTART#{Base64.urlsafe_encode64(diagram)}FREEZEEND"
15
- end
16
- end
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,32 +0,0 @@
1
- module Nexmo
2
- module OAS
3
- module Renderer
4
- module Filters
5
- class Label < Banzai::Filter
6
- def call(input)
7
- input.gsub(/\[(GET|POST|PUT|DELETE|OPTIONS)\]/i) do |_s|
8
- "<span class='Vlt-badge #{class_name($1)}'>#{$1}</span> "
9
- end
10
- end
11
-
12
- private
13
-
14
- def class_name(text)
15
- case text
16
- when 'POST'
17
- 'Vlt-badge--green'
18
- when 'GET'
19
- 'Vlt-badge--blue'
20
- when 'DELETE'
21
- 'Vlt-badge--red'
22
- when 'PUT'
23
- 'Vlt-badge--yellow'
24
- when 'OPTIONS'
25
- 'Vlt-badge--grey'
26
- end
27
- end
28
- end
29
- end
30
- end
31
- end
32
- end
@@ -1,15 +0,0 @@
1
- module Nexmo
2
- module OAS
3
- module Renderer
4
- module Filters
5
- class Language < Banzai::Filter
6
- def call(input)
7
- input.gsub(/\[(.+?)\]\(lang:.+?(?:'(.+?)'|"(.+?)")\)/) do |_s|
8
- "<span lang='#{$2}'>#{$1}</span>"
9
- end
10
- end
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,85 +0,0 @@
1
- require_relative '../lib/redcarpet'
2
-
3
- module Nexmo
4
- module OAS
5
- module Renderer
6
- module Filters
7
- class Markdown < Banzai::Filter
8
- def call(input)
9
- markdown.render(input)
10
- end
11
-
12
- private
13
-
14
- def renderer
15
- @renderer ||= VoltaRender.new(options)
16
- end
17
-
18
- def markdown
19
- @markdown ||= Redcarpet::Markdown.new(renderer, {
20
- no_intra_emphasis: true,
21
- tables: true,
22
- strikethrough: true,
23
- superscript: true,
24
- underline: true,
25
- highlight: true,
26
- fenced_code_blocks: true,
27
- disable_indented_code_blocks: true,
28
- start_inline: true,
29
- })
30
- end
31
- end
32
-
33
- class VoltaRender < HTML
34
- def initialize(options)
35
- @options = options
36
- super(options)
37
- end
38
-
39
- def paragraph(text)
40
- return text if @options[:skip_paragraph_surround]
41
- "<p>#{text}</p>"
42
- end
43
-
44
- def table(header, body)
45
- '<div class="Vlt-table Vlt-table--data Vlt-table--bordered">' \
46
- '<table>' \
47
- "<thead>#{header}</thead>" \
48
- "<tbody>#{body}</tbody>" \
49
- '</table>' \
50
- '</div>'
51
- end
52
-
53
- def block_quote(quote)
54
- '<div class="Vlt-callout Vlt-callout--tip">' \
55
- '<i></i>' \
56
- '<div class="Vlt-callout__content">' \
57
- "#{quote}" \
58
- '</div>' \
59
- '</div>'
60
- end
61
-
62
- def image(link, _title, _alt_text)
63
- '<figure>' \
64
- '<img src="'\
65
- "#{link}"\
66
- '" alt="#{alt_text}">' \
67
- '</figure>'
68
- end
69
-
70
- def list(contents, list_type)
71
- if "#{list_type}" == 'unordered'
72
- '<ul class="Vlt-list Vlt-list--simple">' \
73
- "#{contents}" \
74
- '</ul>'
75
- else
76
- '<ol class="Vlt-list Vlt-list--simple">' \
77
- "#{contents}" \
78
- '</ol>' \
79
- end
80
- end
81
- end
82
- end
83
- end
84
- end
85
- end