graphql-docs 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aaa1474842e99247ca5ed73d7bb1fb4eaf1ed3cf
4
- data.tar.gz: 78c24d6cfe911f4990cf5453650aab0ea3b00026
3
+ metadata.gz: 34778b48d1030614b38cb76926c0a9efb07e37ff
4
+ data.tar.gz: deb65920cdd0793ce20d6eb22b3da6404090e94c
5
5
  SHA512:
6
- metadata.gz: b814f147f59e77c4a912741a66f494b033825c82c7206f8d5869ac31f38a0d5c910c93bd41ce95e6e22acaac2bbc7d8340a5eef745177079e9a97f82ec2410b9
7
- data.tar.gz: 68d4bd88d2cb35d7ae765da04abab98273036e02f60faf68794673205f10409eb32836de653c4b9088f5f3accb40fd0612a6498207d4d7962eb217c05b89ee02
6
+ metadata.gz: 513bf928412916481c9e63622c527f19ea0e8b652dfef73b3f3ed35e326c9853e915280b785caba06fc15addca760a8660cf477bf6eb07c1d2f07a07fdebae2e
7
+ data.tar.gz: eb0fc393dc01f797cbae2fca181ab450956d4e50be8611170df3f31525f7acd12b2f40b664a08248257f4232688617294bf8bfbe2ff8c08fb520c02f99cd171b
data/Rakefile CHANGED
@@ -46,7 +46,7 @@ end
46
46
 
47
47
  desc 'Generate and publish docs to gh-pages'
48
48
  task :publish do
49
- Rake::Task[:generate_sample].invoke('https://www.gjtorikian.com/graphql-docs/')
49
+ Rake::Task[:generate_sample].invoke('https://www.gjtorikian.com/graphql-docs')
50
50
  Dir.mktmpdir do |tmp|
51
51
  system "mv output/* #{tmp}"
52
52
  system 'git checkout gh-pages'
@@ -54,7 +54,7 @@ module GraphQLDocs
54
54
  def create_graphql_object_pages
55
55
  graphql_object_types.each do |object_type|
56
56
  next if object_type['name'].start_with?('__')
57
- opts = { type: object_type }.merge(helper_methods)
57
+ opts = default_generator_options(type: object_type)
58
58
  contents = @graphql_object_template.result(OpenStruct.new(opts).instance_eval { binding })
59
59
  write_file('object', object_type['name'], contents)
60
60
  end
@@ -67,7 +67,7 @@ module GraphQLDocs
67
67
  input = graphql_input_object_types.find { |t| t['name'] == input_name }
68
68
  payload = graphql_object_types.find { |t| t['name'] == return_name }
69
69
 
70
- opts = { type: mutation, input_fields: input, return_fields: payload }.merge(helper_methods)
70
+ opts = default_generator_options({ type: mutation, input_fields: input, return_fields: payload })
71
71
 
72
72
  contents = @graphql_mutations_template.result(OpenStruct.new(opts).instance_eval { binding })
73
73
  write_file('mutation', mutation['name'], contents)
@@ -76,7 +76,7 @@ module GraphQLDocs
76
76
 
77
77
  def create_graphql_interface_pages
78
78
  graphql_interface_types.each do |interface_type|
79
- opts = { type: interface_type }.merge(helper_methods)
79
+ opts = default_generator_options({ type: interface_type })
80
80
 
81
81
  contents = @graphql_interfaces_template.result(OpenStruct.new(opts).instance_eval { binding })
82
82
  write_file('interface', interface_type['name'], contents)
@@ -85,7 +85,7 @@ module GraphQLDocs
85
85
 
86
86
  def create_graphql_enum_pages
87
87
  graphql_enum_types.each do |enum_type|
88
- opts = { type: enum_type }.merge(helper_methods)
88
+ opts = default_generator_options({ type: enum_type })
89
89
 
90
90
  contents = @graphql_enums_template.result(OpenStruct.new(opts).instance_eval { binding })
91
91
  write_file('enum', enum_type['name'], contents)
@@ -94,7 +94,7 @@ module GraphQLDocs
94
94
 
95
95
  def create_graphql_union_pages
96
96
  graphql_union_types.each do |union_type|
97
- opts = { type: union_type }.merge(helper_methods)
97
+ opts = default_generator_options({ type: union_type })
98
98
 
99
99
  contents = @graphql_unions_template.result(OpenStruct.new(opts).instance_eval { binding })
100
100
  write_file('union', union_type['name'], contents)
@@ -103,7 +103,7 @@ module GraphQLDocs
103
103
 
104
104
  def create_graphql_input_object_pages
105
105
  graphql_input_object_types.each do |input_object_type|
106
- opts = { type: input_object_type }.merge(helper_methods)
106
+ opts = default_generator_options({ type: input_object_type })
107
107
 
108
108
  contents = @graphql_input_objects_template.result(OpenStruct.new(opts).instance_eval { binding })
109
109
  write_file('input_object', input_object_type['name'], contents)
@@ -112,7 +112,7 @@ module GraphQLDocs
112
112
 
113
113
  def create_graphql_scalar_pages
114
114
  graphql_scalar_types.each do |scalar_type|
115
- opts = { type: scalar_type }.merge(helper_methods)
115
+ opts = default_generator_options({ type: scalar_type })
116
116
 
117
117
  contents = @graphql_scalars_template.result(OpenStruct.new(opts).instance_eval { binding })
118
118
  write_file('scalar', scalar_type['name'], contents)
@@ -121,6 +121,10 @@ module GraphQLDocs
121
121
 
122
122
  private
123
123
 
124
+ def default_generator_options(opts = {})
125
+ @options.merge(opts).merge(helper_methods)
126
+ end
127
+
124
128
  def write_file(type, name, contents)
125
129
  if type == 'static'
126
130
  if name == 'index'
@@ -12,6 +12,7 @@ module GraphQLDocs
12
12
 
13
13
  def include(filename, opts = {})
14
14
  template = fetch_include(filename)
15
+ opts = { base_url: @options[:base_url] }.merge(opts)
15
16
  template.result(OpenStruct.new(opts.merge(helper_methods)).instance_eval { binding })
16
17
  end
17
18
 
@@ -36,8 +36,7 @@ module GraphQLDocs
36
36
  def render(type, name, contents)
37
37
  contents = @pipeline.to_html(contents)
38
38
  return contents if @graphql_default_layout.nil?
39
- opts = @options
40
- opts = opts.merge({ contents: contents, type: type, name: name}).merge(helper_methods)
39
+ opts = { base_url: @options[:base_url] }.merge({ contents: contents, type: type, name: name}).merge(helper_methods)
41
40
  @graphql_default_layout.result(OpenStruct.new(opts).instance_eval { binding })
42
41
  end
43
42
 
@@ -1,3 +1,3 @@
1
1
  module GraphQLDocs
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-docs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian