graphql-docs 1.6.1 → 1.7.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
  SHA256:
3
- metadata.gz: f9927fcaa99294d832438c2e32b14d36e75da6208bbd320c689b323960ddf9e0
4
- data.tar.gz: 9033c5e6ce19659232675b03b56a18ef33e7bc7d8903913b4858c4e3fa60b93c
3
+ metadata.gz: c06368e890af03ce399e5d4531d0a5973da8e8063511f68c3a3dccab3411e51e
4
+ data.tar.gz: a5122bc69a78683981d5b7782dd8299659f1abd2f391cdefd73ab790f919532b
5
5
  SHA512:
6
- metadata.gz: e5a88d674aadea5199215b96ec816ab79512caab5e7d5d1c786a9a537aa5abb806c557d3f8e1552ec305af456050dcdb11eee2f4022fc5a114ed259ca1819f24
7
- data.tar.gz: 2b8aa52f4fbfa76ff9db32dca0c157ea4989380da1fb5755ef9f4428bf523fd4a09d2afb41cb0573506d5a0e3a10c7957173ea6ca8184add61bde1405e52c67f
6
+ metadata.gz: 514e90e4ea3adc0cd60b40aa604f9e6c74168a42f46e7829bd720891f87c642dcba1401faacc25f8154f580c65fa820fd88e871b323ecac498b3e9f1721a5bbf
7
+ data.tar.gz: d62e5f13da7c60938f809c49f8c3dd405ae0dc4cbed72474bf6426237c7a468d7ce045f4dafb9587b4a6b1a0c34d43a1febddb14d952d9eca50a71322e911c19
@@ -1,29 +1,23 @@
1
+ sudo: false
1
2
  language: ruby
3
+ cache: bundler
4
+
2
5
  rvm:
3
6
  - 2.3.6
4
7
  - 2.4.3
5
8
  - 2.5.0
9
+ - 2.6.0
6
10
 
7
11
  git:
8
12
  depth: 10
9
13
 
10
- env:
11
- global:
12
- - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
13
-
14
- sudo: false
15
- cache: bundler
16
-
17
- addons:
18
- apt:
19
- sources:
20
- - kalakris-cmake
21
- packages:
22
- - cmake
14
+ before_install:
15
+ - gem update --system
16
+ - gem install bundler
23
17
 
24
18
  matrix:
25
19
  include:
26
20
  - script: bundle exec rake rubocop
27
- rvm: 2.5.0
21
+ rvm: 2.6.0
28
22
  - script: bundle exec rake html_proofer
29
- rvm: 2.5.0
23
+ rvm: 2.6.0
data/README.md CHANGED
@@ -96,6 +96,12 @@ GraphQLDocs.build(options)
96
96
 
97
97
  If your `render` method returns `nil`, the `Generator` will not attempt to write any HTML file.
98
98
 
99
+ ### Templates
100
+
101
+ The layouts for the individual GraphQL pages are ERB templates, but you can also use ERB templates for your static landing pages.
102
+
103
+ If you want to add additional variables for your landing pages, you can add define a `variables` hash within the `landing_pages` option.
104
+
99
105
  ### Helper methods
100
106
 
101
107
  In your ERB layouts, there are several helper methods you can use. The helper methods are:
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ['lib']
23
23
 
24
- spec.add_dependency 'graphql', '~> 1.6'
24
+ spec.add_dependency 'graphql', '~> 1.8'
25
25
 
26
26
  # rendering
27
27
  spec.add_dependency 'commonmarker', '~> 0.16'
@@ -32,7 +32,6 @@ Gem::Specification.new do |spec|
32
32
  spec.add_dependency 'sass', '~> 3.4'
33
33
 
34
34
  spec.add_development_dependency 'awesome_print'
35
- spec.add_development_dependency 'bundler', '~> 1.14'
36
35
  spec.add_development_dependency 'html-proofer', '~> 3.4'
37
36
  spec.add_development_dependency 'minitest', '~> 5.0'
38
37
  spec.add_development_dependency 'minitest-focus', '~> 1.1'
@@ -48,7 +48,9 @@ module GraphQLDocs
48
48
  enum: "#{File.dirname(__FILE__)}/landing_pages/enum.md",
49
49
  union: "#{File.dirname(__FILE__)}/landing_pages/union.md",
50
50
  input_object: "#{File.dirname(__FILE__)}/landing_pages/input_object.md",
51
- scalar: "#{File.dirname(__FILE__)}/landing_pages/scalar.md"
51
+ scalar: "#{File.dirname(__FILE__)}/landing_pages/scalar.md",
52
+
53
+ variables: {} # only used for ERB landing pages
52
54
  },
53
55
 
54
56
  classes: {
@@ -27,7 +27,23 @@ module GraphQLDocs
27
27
  elsif !File.exist?(@options[:landing_pages][sym])
28
28
  raise IOError, "`#{sym}` landing page #{@options[:landing_pages][sym]} was not found"
29
29
  end
30
- instance_variable_set("@graphql_#{sym}_landing_page", File.read(@options[:landing_pages][sym]))
30
+
31
+ landing_page_contents = File.read(@options[:landing_pages][sym])
32
+ metadata = ''
33
+
34
+ if File.extname((@options[:landing_pages][sym])) == '.erb'
35
+ opts = @options.merge(@options[:landing_pages][:variables]).merge(helper_methods)
36
+ if has_yaml?(landing_page_contents)
37
+ metadata, landing_page = split_into_metadata_and_contents(landing_page_contents, parse: false)
38
+ erb_template = ERB.new(landing_page)
39
+ else
40
+ erb_template = ERB.new(landing_page_contents)
41
+ end
42
+
43
+ landing_page_contents = erb_template.result(OpenStruct.new(opts).instance_eval { binding })
44
+ end
45
+
46
+ instance_variable_set("@graphql_#{sym}_landing_page", metadata + landing_page_contents)
31
47
  end
32
48
  end
33
49
 
@@ -62,7 +62,7 @@ module GraphQLDocs
62
62
  @parsed_schema[:scalar_types] || []
63
63
  end
64
64
 
65
- def split_into_metadata_and_contents(contents)
65
+ def split_into_metadata_and_contents(contents, parse: true)
66
66
  opts = {}
67
67
  pieces = yaml_split(contents)
68
68
  if pieces.size < 4
@@ -72,7 +72,11 @@ module GraphQLDocs
72
72
  end
73
73
  # Parse
74
74
  begin
75
- meta = YAML.load(pieces[2]) || {}
75
+ if parse
76
+ meta = YAML.load(pieces[2]) || {}
77
+ else
78
+ meta = pieces[2]
79
+ end
76
80
  rescue Exception => e # rubocop:disable Lint/RescueException
77
81
  raise "Could not parse YAML for #{name}: #{e.message}"
78
82
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQLDocs
3
- VERSION = '1.6.1'.freeze
3
+ VERSION = '1.7.0'.freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-docs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-13 00:00:00.000000000 Z
11
+ date: 2019-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.6'
19
+ version: '1.8'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.6'
26
+ version: '1.8'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: commonmarker
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -122,20 +122,6 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: bundler
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '1.14'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '1.14'
139
125
  - !ruby/object:Gem::Dependency
140
126
  name: html-proofer
141
127
  requirement: !ruby/object:Gem::Requirement