@@ -16,12 +16,17 @@ def render(context) # rubocop:disable Metrics/MethodLength
1616 config = config . merge ( 'formats' => @page [ 'tools' ] ) unless config [ 'formats' ]
1717
1818 unless config [ 'formats' ]
19- raise ArgumentError , "Missing key `tools` in metadata, or `formats` in entity_examples block on page #{ @page [ 'path' ] } "
19+ raise ArgumentError ,
20+ "Missing key `tools` in metadata, or `formats` in entity_examples block on page #{ @page [ 'path' ] } "
2021 end
2122 unless config [ 'formats' ] == [ 'deck' ]
2223 raise ArgumentError , "entity_examples only supports deck, on page #{ @page [ 'path' ] } "
2324 end
2425
26+ @page [ 'kong_plugins' ] ||= [ ]
27+ kong_plugins = plugins ( config )
28+ @page [ 'kong_plugins' ] . concat ( kong_plugins ) if kong_plugins . any?
29+
2530 entity_examples_drop = Drops ::EntityExamples . new ( config :)
2631
2732 template = File . read ( entity_examples_drop . template )
@@ -32,12 +37,18 @@ def render(context) # rubocop:disable Metrics/MethodLength
3237 end
3338 rescue Psych ::SyntaxError => e
3439 message = <<~STRING
35- On `#{ @page [ 'path' ] } `, the following {% entity_examples %} block contains a malformed yaml:
36- #{ contents . strip . split ( "\n " ) . each_with_index . map { |l , i | "#{ i } : #{ l } " } . join ( "\n " ) }
37- #{ e . message }
40+ On `#{ @page [ 'path' ] } `, the following {% entity_examples %} block contains a malformed yaml:
41+ #{ contents . strip . split ( "\n " ) . each_with_index . map { |l , i | "#{ i } : #{ l } " } . join ( "\n " ) }
42+ #{ e . message }
3843 STRING
3944 raise ArgumentError . new ( message )
4045 end
46+
47+ def plugins ( config )
48+ return [ ] unless config . dig ( 'entities' , 'plugins' )
49+
50+ config [ 'entities' ] [ 'plugins' ] . map { |plugin | plugin [ 'name' ] } . compact
51+ end
4152 end
4253end
4354
0 commit comments