graphql-docs 1.8.0 → 1.9.0
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 +4 -4
- data/.rubocop.yml +1 -1
- data/README.md +4 -4
- data/graphql-docs.gemspec +2 -1
- data/lib/graphql-docs/configuration.rb +2 -0
- data/lib/graphql-docs/generator.rb +16 -2
- data/lib/graphql-docs/helpers.rb +4 -0
- data/lib/graphql-docs/landing_pages/directive.md +9 -0
- data/lib/graphql-docs/layouts/graphql_directives.html +15 -0
- data/lib/graphql-docs/layouts/includes/locations.html +9 -0
- data/lib/graphql-docs/layouts/includes/sidebar.html +14 -0
- data/lib/graphql-docs/layouts/includes/values.html +1 -1
- data/lib/graphql-docs/parser.rb +22 -7
- data/lib/graphql-docs/version.rb +1 -1
- metadata +20 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea32dc7266ed5483301f965839b71b611f17df3e87cdb1de18ed3ccbd4ff601e
|
4
|
+
data.tar.gz: 292fb21272e4293d4ed23ae996281d34522487ab71f47a13ae7943185407f2c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3108decb47aeaeddf1fdeef7c0f48cf55c03c0e413fb3354f595284977629704159ccaf0b6b574b5d0845301021fc6211a819138bdf6a63589dccb2e46cabff
|
7
|
+
data.tar.gz: 609e77fd5c372af5c23edc1893470ee835cae90f9f0587100542b2d6cd020c155973e78f7e0d59561d384bcced55dbc0bae436512af0fe1615b4ff97183d2ee6
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -109,7 +109,7 @@ In your ERB layouts, there are several helper methods you can use. The helper me
|
|
109
109
|
* `slugify(str)` - This slugifies the given string.
|
110
110
|
* `include(filename, opts)` - This embeds a template from your `includes` folder, passing along the local options provided.
|
111
111
|
* `markdownify(string)` - This converts a string into HTML via CommonMarker.
|
112
|
-
* `graphql_operation_types`, `graphql_mutation_types`, `graphql_object_types`, `graphql_interface_types`, `graphql_enum_types`, `graphql_union_types`, `graphql_input_object_types`, `graphql_scalar_types` - Collections of the various GraphQL types.
|
112
|
+
* `graphql_operation_types`, `graphql_mutation_types`, `graphql_object_types`, `graphql_interface_types`, `graphql_enum_types`, `graphql_union_types`, `graphql_input_object_types`, `graphql_scalar_types`, `graphql_directive_types` - Collections of the various GraphQL types.
|
113
113
|
|
114
114
|
To call these methods within templates, you must use the dot notation, such as `<%= slugify.(text) %>`.
|
115
115
|
|
@@ -127,8 +127,8 @@ The following options are available:
|
|
127
127
|
| `delete_output` | Deletes `output_dir` before generating content. | `false` |
|
128
128
|
| `pipeline_config` | Defines two sub-keys, `pipeline` and `context`, which are used by `html-pipeline` when rendering your output. | `pipeline` has `ExtendedMarkdownFilter`, `EmojiFilter`, and `TableOfContentsFilter`. `context` has `gfm: false` and `asset_root` set to GitHub's CDN. |
|
129
129
|
| `renderer` | The rendering class to use. | `GraphQLDocs::Renderer`
|
130
|
-
| `templates` | The templates to use when generating HTML. You may override any of the following keys: `default`, `includes`, `operations`, `objects`, `mutations`, `interfaces`, `enums`, `unions`, `input_objects`, `scalars`. | The defaults are found in _lib/graphql-docs/layouts/_.
|
131
|
-
| `landing_pages` | The landing page to use when generating HTML for each type. You may override any of the following keys: `index`, `query`, `object`, `mutation`, `interface`, `enum`, `union`, `input_object`, `scalar`. | The defaults are found in _lib/graphql-docs/
|
130
|
+
| `templates` | The templates to use when generating HTML. You may override any of the following keys: `default`, `includes`, `operations`, `objects`, `mutations`, `interfaces`, `enums`, `unions`, `input_objects`, `scalars`, `directives`. | The defaults are found in _lib/graphql-docs/layouts/_.
|
131
|
+
| `landing_pages` | The landing page to use when generating HTML for each type. You may override any of the following keys: `index`, `query`, `object`, `mutation`, `interface`, `enum`, `union`, `input_object`, `scalar`, `directive`. | The defaults are found in _lib/graphql-docs/landing\_pages/_.
|
132
132
|
| `classes` | Additional class names you can provide to certain elements. | The full list is available in _lib/graphql-docs/configuration.rb_.
|
133
133
|
| `notices` | A proc used to add notices to schema members. See *Customizing Notices* section below. | `nil` |
|
134
134
|
|
@@ -153,7 +153,7 @@ A `notice` has the following options:
|
|
153
153
|
Example of a `notices` proc that adds a notice to the `TeamDiscussion` type:
|
154
154
|
|
155
155
|
```ruby
|
156
|
-
options[:
|
156
|
+
options[:notices] = ->(schema_member_path) {
|
157
157
|
notices = []
|
158
158
|
|
159
159
|
if schema_member_path == "TeamDiscussion"
|
data/graphql-docs.gemspec
CHANGED
@@ -38,6 +38,7 @@ Gem::Specification.new do |spec|
|
|
38
38
|
spec.add_development_dependency 'pry-byebug', '~> 3.6'
|
39
39
|
spec.add_development_dependency 'rake'
|
40
40
|
spec.add_development_dependency 'rubocop'
|
41
|
-
spec.add_development_dependency 'rubocop-
|
41
|
+
spec.add_development_dependency 'rubocop-performance'
|
42
|
+
spec.add_development_dependency 'rubocop-standard'
|
42
43
|
spec.add_development_dependency 'webmock', '~> 2.3'
|
43
44
|
end
|
@@ -37,6 +37,7 @@ module GraphQLDocs
|
|
37
37
|
unions: "#{File.dirname(__FILE__)}/layouts/graphql_unions.html",
|
38
38
|
input_objects: "#{File.dirname(__FILE__)}/layouts/graphql_input_objects.html",
|
39
39
|
scalars: "#{File.dirname(__FILE__)}/layouts/graphql_scalars.html",
|
40
|
+
directives: "#{File.dirname(__FILE__)}/layouts/graphql_directives.html",
|
40
41
|
},
|
41
42
|
|
42
43
|
landing_pages: {
|
@@ -49,6 +50,7 @@ module GraphQLDocs
|
|
49
50
|
union: "#{File.dirname(__FILE__)}/landing_pages/union.md",
|
50
51
|
input_object: "#{File.dirname(__FILE__)}/landing_pages/input_object.md",
|
51
52
|
scalar: "#{File.dirname(__FILE__)}/landing_pages/scalar.md",
|
53
|
+
directive: "#{File.dirname(__FILE__)}/landing_pages/directive.md",
|
52
54
|
|
53
55
|
variables: {} # only used for ERB landing pages
|
54
56
|
},
|
@@ -14,14 +14,14 @@ module GraphQLDocs
|
|
14
14
|
|
15
15
|
@renderer = @options[:renderer].new(@parsed_schema, @options)
|
16
16
|
|
17
|
-
%i(operations objects mutations interfaces enums unions input_objects scalars).each do |sym|
|
17
|
+
%i(operations objects mutations interfaces enums unions input_objects scalars directives).each do |sym|
|
18
18
|
if !File.exist?(@options[:templates][sym])
|
19
19
|
raise IOError, "`#{sym}` template #{@options[:templates][sym]} was not found"
|
20
20
|
end
|
21
21
|
instance_variable_set("@graphql_#{sym}_template", ERB.new(File.read(@options[:templates][sym])))
|
22
22
|
end
|
23
23
|
|
24
|
-
%i(index object query mutation interface enum union input_object scalar).each do |sym|
|
24
|
+
%i(index object query mutation interface enum union input_object scalar directive).each do |sym|
|
25
25
|
if @options[:landing_pages][sym].nil?
|
26
26
|
instance_variable_set("@#{sym}_landing_page", nil)
|
27
27
|
elsif !File.exist?(@options[:landing_pages][sym])
|
@@ -58,6 +58,7 @@ module GraphQLDocs
|
|
58
58
|
create_graphql_union_pages
|
59
59
|
create_graphql_input_object_pages
|
60
60
|
create_graphql_scalar_pages
|
61
|
+
create_graphql_directive_pages
|
61
62
|
|
62
63
|
unless @graphql_index_landing_page.nil?
|
63
64
|
write_file('static', 'index', @graphql_index_landing_page, trim: false)
|
@@ -95,6 +96,10 @@ module GraphQLDocs
|
|
95
96
|
write_file('static', 'scalar', @graphql_scalar_landing_page, trim: false)
|
96
97
|
end
|
97
98
|
|
99
|
+
unless @graphql_directive_landing_page.nil?
|
100
|
+
write_file('static', 'directive', @graphql_directive_landing_page, trim: false)
|
101
|
+
end
|
102
|
+
|
98
103
|
if @options[:use_default_styles]
|
99
104
|
assets_dir = File.join(File.dirname(__FILE__), 'layouts', 'assets')
|
100
105
|
FileUtils.mkdir_p(File.join(@options[:output_dir], 'assets'))
|
@@ -196,6 +201,15 @@ module GraphQLDocs
|
|
196
201
|
end
|
197
202
|
end
|
198
203
|
|
204
|
+
def create_graphql_directive_pages
|
205
|
+
graphql_directive_types.each do |directive_type|
|
206
|
+
opts = default_generator_options(type: directive_type)
|
207
|
+
|
208
|
+
contents = @graphql_directives_template.result(OpenStruct.new(opts).instance_eval { binding })
|
209
|
+
write_file('directive', directive_type[:name], contents)
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
199
213
|
private
|
200
214
|
|
201
215
|
def default_generator_options(opts = {})
|
data/lib/graphql-docs/helpers.rb
CHANGED
@@ -62,6 +62,10 @@ module GraphQLDocs
|
|
62
62
|
@parsed_schema[:scalar_types] || []
|
63
63
|
end
|
64
64
|
|
65
|
+
def graphql_directive_types
|
66
|
+
@parsed_schema[:directive_types] || []
|
67
|
+
end
|
68
|
+
|
65
69
|
def split_into_metadata_and_contents(contents, parse: true)
|
66
70
|
opts = {}
|
67
71
|
pieces = yaml_split(contents)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
---
|
2
|
+
title: Directives
|
3
|
+
---
|
4
|
+
|
5
|
+
# Directives
|
6
|
+
|
7
|
+
Directives provide a way to describe alternate runtime execution and type validation behavior in a GraphQL document.
|
8
|
+
|
9
|
+
For more information, see [the GraphQL spec](https://graphql.github.io/graphql-spec/draft/#sec-Language.Directives).
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<h1><%= type[:name] %></h1>
|
2
|
+
|
3
|
+
<%= include.('notices.html', notices: type[:notices]) %>
|
4
|
+
|
5
|
+
<%= type[:description] %>
|
6
|
+
|
7
|
+
<%= include.('locations.html', locations: type[:locations]) %>
|
8
|
+
|
9
|
+
<% unless type[:arguments].empty? %>
|
10
|
+
|
11
|
+
<h2>Arguments</h2>
|
12
|
+
|
13
|
+
<%= include.('arguments.html', arguments: type[:arguments]) %>
|
14
|
+
|
15
|
+
<% end %>
|
@@ -119,4 +119,18 @@
|
|
119
119
|
<% end %>
|
120
120
|
</ul>
|
121
121
|
</li>
|
122
|
+
|
123
|
+
<li>
|
124
|
+
<p><a href="<%= base_url %>/directive">Directives</a></p>
|
125
|
+
<ul class="menu-root">
|
126
|
+
<% graphql_directive_types.().each do |type| %>
|
127
|
+
<% @name = type[:name] %>
|
128
|
+
<li>
|
129
|
+
<a href="<%= base_url %>/directive/<%= @name.downcase %>/" class="sidebar-link<% if title == @name %> current<% end %>">
|
130
|
+
<%= @name %>
|
131
|
+
</a>
|
132
|
+
</li>
|
133
|
+
<% end %>
|
134
|
+
</ul>
|
135
|
+
</li>
|
122
136
|
</ul>
|
data/lib/graphql-docs/parser.rb
CHANGED
@@ -27,6 +27,7 @@ module GraphQLDocs
|
|
27
27
|
union_types: [],
|
28
28
|
input_object_types: [],
|
29
29
|
scalar_types: [],
|
30
|
+
directive_types: [],
|
30
31
|
}
|
31
32
|
end
|
32
33
|
|
@@ -133,13 +134,20 @@ module GraphQLDocs
|
|
133
134
|
end
|
134
135
|
end
|
135
136
|
|
136
|
-
@
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
137
|
+
@schema.directives.each_value do |directive|
|
138
|
+
data = {}
|
139
|
+
data[:notices] = @options[:notices].call(directive.name)
|
140
|
+
|
141
|
+
data[:name] = directive.name
|
142
|
+
data[:description] = directive.description
|
143
|
+
data[:locations] = directive.locations
|
144
|
+
|
145
|
+
data[:arguments], _ = fetch_fields(directive.arguments, directive.name)
|
146
|
+
|
147
|
+
@processed_schema[:directive_types] << data
|
148
|
+
end
|
149
|
+
|
150
|
+
sort_by_name!
|
143
151
|
|
144
152
|
@processed_schema[:interface_types].each do |interface|
|
145
153
|
interface[:implemented_by] = []
|
@@ -229,5 +237,12 @@ module GraphQLDocs
|
|
229
237
|
def argument?(field)
|
230
238
|
field.is_a?(::GraphQL::Argument)
|
231
239
|
end
|
240
|
+
|
241
|
+
def sort_by_name!
|
242
|
+
@processed_schema.each_pair do |key, value|
|
243
|
+
next if key == :operation_types || key == :root_types
|
244
|
+
value.sort_by! { |o| o[:name] }
|
245
|
+
end
|
246
|
+
end
|
232
247
|
end
|
233
248
|
end
|
data/lib/graphql-docs/version.rb
CHANGED
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.
|
4
|
+
version: 1.9.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: 2019-
|
11
|
+
date: 2019-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|
@@ -207,7 +207,21 @@ dependencies:
|
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: '0'
|
209
209
|
- !ruby/object:Gem::Dependency
|
210
|
-
name: rubocop-
|
210
|
+
name: rubocop-performance
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: rubocop-standard
|
211
225
|
requirement: !ruby/object:Gem::Requirement
|
212
226
|
requirements:
|
213
227
|
- - ">="
|
@@ -253,6 +267,7 @@ files:
|
|
253
267
|
- lib/graphql-docs/configuration.rb
|
254
268
|
- lib/graphql-docs/generator.rb
|
255
269
|
- lib/graphql-docs/helpers.rb
|
270
|
+
- lib/graphql-docs/landing_pages/directive.md
|
256
271
|
- lib/graphql-docs/landing_pages/enum.md
|
257
272
|
- lib/graphql-docs/landing_pages/index.md
|
258
273
|
- lib/graphql-docs/landing_pages/input_object.md
|
@@ -296,6 +311,7 @@ files:
|
|
296
311
|
- lib/graphql-docs/layouts/assets/webfonts/2C4B9D_E_0.woff
|
297
312
|
- lib/graphql-docs/layouts/assets/webfonts/2C4B9D_E_0.woff2
|
298
313
|
- lib/graphql-docs/layouts/default.html
|
314
|
+
- lib/graphql-docs/layouts/graphql_directives.html
|
299
315
|
- lib/graphql-docs/layouts/graphql_enums.html
|
300
316
|
- lib/graphql-docs/layouts/graphql_input_objects.html
|
301
317
|
- lib/graphql-docs/layouts/graphql_interfaces.html
|
@@ -309,6 +325,7 @@ files:
|
|
309
325
|
- lib/graphql-docs/layouts/includes/deprecations.html
|
310
326
|
- lib/graphql-docs/layouts/includes/fields.html
|
311
327
|
- lib/graphql-docs/layouts/includes/input_fields.html
|
328
|
+
- lib/graphql-docs/layouts/includes/locations.html
|
312
329
|
- lib/graphql-docs/layouts/includes/notices.html
|
313
330
|
- lib/graphql-docs/layouts/includes/possible_types.html
|
314
331
|
- lib/graphql-docs/layouts/includes/sidebar.html
|