graphql-docs 0.1.1 → 0.2.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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -1
  3. data/README.md +16 -12
  4. data/Rakefile +26 -15
  5. data/graphql-docs.gemspec +2 -1
  6. data/lib/graphql-docs/client.rb +2 -1
  7. data/lib/graphql-docs/configuration.rb +6 -1
  8. data/lib/graphql-docs/generator.rb +26 -2
  9. data/{sample_assets → lib/graphql-docs/layouts/assets}/_sass/_api-box.scss +0 -0
  10. data/{sample_assets → lib/graphql-docs/layouts/assets}/_sass/_content.scss +0 -0
  11. data/lib/graphql-docs/layouts/assets/_sass/_fonts.scss +21 -0
  12. data/{sample_assets → lib/graphql-docs/layouts/assets}/_sass/_header.scss +0 -0
  13. data/{sample_assets → lib/graphql-docs/layouts/assets}/_sass/_mobile.scss +1 -1
  14. data/{sample_assets → lib/graphql-docs/layouts/assets}/_sass/_normalize.scss +0 -0
  15. data/{sample_assets → lib/graphql-docs/layouts/assets}/_sass/_search.scss +2 -2
  16. data/{sample_assets → lib/graphql-docs/layouts/assets}/_sass/_sidebar.scss +0 -0
  17. data/{sample_assets → lib/graphql-docs/layouts/assets}/_sass/_syntax.scss +0 -0
  18. data/{sample_assets → lib/graphql-docs/layouts/assets}/_sass/_types.scss +0 -0
  19. data/{sample_assets → lib/graphql-docs/layouts/assets}/_sass/screen.scss +0 -0
  20. data/{sample_assets → lib/graphql-docs/layouts/assets}/css/screen.scss +0 -0
  21. data/lib/graphql-docs/layouts/assets/images/graphiql-headers.png +0 -0
  22. data/lib/graphql-docs/layouts/assets/images/graphiql-variables.png +0 -0
  23. data/lib/graphql-docs/layouts/assets/images/graphiql.png +0 -0
  24. data/lib/graphql-docs/layouts/assets/images/menu.png +0 -0
  25. data/lib/graphql-docs/layouts/assets/images/navbar.png +0 -0
  26. data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_B_0.eot +0 -0
  27. data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_B_0.ttf +0 -0
  28. data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_B_0.woff +0 -0
  29. data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_B_0.woff2 +0 -0
  30. data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_C_0.eot +0 -0
  31. data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_C_0.ttf +0 -0
  32. data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_C_0.woff +0 -0
  33. data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_C_0.woff2 +0 -0
  34. data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_D_0.eot +0 -0
  35. data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_D_0.ttf +0 -0
  36. data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_D_0.woff +0 -0
  37. data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_D_0.woff2 +0 -0
  38. data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_E_0.eot +0 -0
  39. data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_E_0.ttf +0 -0
  40. data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_E_0.woff +0 -0
  41. data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_E_0.woff2 +0 -0
  42. data/lib/graphql-docs/layouts/default.html +16 -5
  43. data/lib/graphql-docs/layouts/graphql_objects.html +1 -1
  44. data/lib/graphql-docs/layouts/includes/connections.html +1 -1
  45. data/lib/graphql-docs/layouts/includes/fields.html +1 -1
  46. data/lib/graphql-docs/layouts/includes/input_fields.html +1 -1
  47. data/lib/graphql-docs/layouts/includes/possible_types.html +1 -1
  48. data/lib/graphql-docs/layouts/includes/sidebar.html +9 -9
  49. data/lib/graphql-docs/layouts/index.md +7 -0
  50. data/lib/graphql-docs/parser.rb +9 -2
  51. data/lib/graphql-docs/renderer.rb +2 -1
  52. data/lib/graphql-docs/version.rb +1 -1
  53. metadata +64 -28
  54. data/sample_assets/_sass/_fonts.scss +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 540afb95d491f00898705c8bd73fdb8a31d685c9
4
- data.tar.gz: 23b419944ad81f60fff9264e3691d604ffeda467
3
+ metadata.gz: aaa1474842e99247ca5ed73d7bb1fb4eaf1ed3cf
4
+ data.tar.gz: 78c24d6cfe911f4990cf5453650aab0ea3b00026
5
5
  SHA512:
6
- metadata.gz: 6ee639a760366f5f240dc117d5770045700e1676eaf9abb06041009513e0a31470a3c6bd77eaf1da4642e542fdc35e2669f9ee22dff23da6ee8c2aa6ee74edf5
7
- data.tar.gz: 78561641aae9442b65c565b1f198f0dc9da933bfbefc8ad1f6ad50b3d553d4670fcebf3c3d094fb5ecc18779cd2fa7b043a572fe7b1c1d4181302a8fc6e2bddb
6
+ metadata.gz: b814f147f59e77c4a912741a66f494b033825c82c7206f8d5869ac31f38a0d5c910c93bd41ce95e6e22acaac2bbc7d8340a5eef745177079e9a97f82ec2410b9
7
+ data.tar.gz: 68d4bd88d2cb35d7ae765da04abab98273036e02f60faf68794673205f10409eb32836de653c4b9088f5f3accb40fd0612a6498207d4d7962eb217c05b89ee02
data/.gitignore CHANGED
@@ -10,4 +10,4 @@
10
10
  /output/
11
11
  /test/graphql-docs/fixtures/output/
12
12
  /.sass-cache/
13
- /sample/
13
+ /output/
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Easily generate beautiful documentation from your GraphQL schema.
4
4
 
5
+ ![sample](https://cloud.githubusercontent.com/assets/64050/23438604/6a23add0-fdc7-11e6-8852-ef41e8451033.png)
6
+
5
7
  ## Installation
6
8
 
7
9
  Add this line to your application's Gemfile:
@@ -23,22 +25,22 @@ Or install it yourself as:
23
25
  Simple! Call `GraphQLDocs.generate`, taking care to pass in the GraphQL endpoint:
24
26
 
25
27
  ``` ruby
26
- GraphQLDocs.build(url: "http://graphql.org/swapi-graphql/")
28
+ GraphQLDocs.build(url: 'http://graphql.org/swapi-graphql/')
27
29
  ```
28
30
 
29
31
  If your GraphQL endpoint requires authentication, you can provide a username or password, or an access token:
30
32
 
31
33
  ``` ruby
32
34
  options = {
33
- url: "http://graphql.org/swapi-graphql/"
34
- login: "gjtorikian",
35
- password: "lolnowai"
35
+ url: 'http://graphql.org/swapi-graphql/'
36
+ login: 'gjtorikian',
37
+ password: 'lolnowai'
36
38
  }
37
39
  GraphQLDocs.build(options)
38
40
 
39
41
  options = {
40
- url: "http://graphql.org/swapi-graphql/"
41
- access_token: "something123"
42
+ url: 'http://graphql.org/swapi-graphql/'
43
+ access_token: 'something123'
42
44
  }
43
45
 
44
46
  GraphQLDocs.build(options)
@@ -52,12 +54,12 @@ GraphQLDocs.build(path: 'location/to/sw-api.json')
52
54
 
53
55
  ## Breakdown
54
56
 
55
- There are several phaseses going on in one little `GraphQLDocs.build` call:
57
+ There are several phases going on in one little `GraphQLDocs.build` call:
56
58
 
57
59
  * The GraphQL JSON is _fetched_ (if you passed `url`) through `GraphQL::Client` (or simply read if you passed `path`).
58
60
  * `GraphQL::Parser` manipulates that JSON into a slightly saner format.
59
61
  * `GraphQL::Generator` takes that JSON and converts it into HTML.
60
- * `GraphQL::Parser` technically runs as part of the generation phase. It passes the contents of each page through a Markdown renderer.
62
+ * `GraphQL::Renderer` technically runs as part of the generation phase. It passes the contents of each page through a Markdown renderer.
61
63
 
62
64
  If you wanted to, you could break these calls up individually. For example:
63
65
 
@@ -110,14 +112,14 @@ In your ERB layouts, there are several helper methods you can use. The helper me
110
112
  * `slugify(str)` - This slugifies the given string.
111
113
  * `include(filename, opts)` - This embeds a template from your `includes` folder, passing along the local options provided.
112
114
  * `markdown(string)` - This converts a string from Markdown to HTML.
115
+ * `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.
113
116
 
114
- To call these methods, you must use the dot notation, such as `<%= slugify.(text) %>`.
117
+ To call these methods within templates, you must use the dot notation, such as `<%= slugify.(text) %>`.
115
118
 
116
119
  ## Configuration
117
120
 
118
121
  The following options are available:
119
122
 
120
-
121
123
  | Option | Description | Default |
122
124
  | :----- | :---------- | :------ |
123
125
  | `access_token` | Uses this token while making requests through `GraphQLDocs::Client`. | `nil` |
@@ -126,14 +128,16 @@ The following options are available:
126
128
  | `path` | `GraphQLDocs::Client` loads a JSON file found at this location, representing the response from an introspection query. | `nil` |
127
129
  | `url` | `GraphQLDocs::Client` makes a `POST` request to this URL, passing along the introspection query. | `nil` |
128
130
  | `output_dir` | The location of the output HTML. | `./output/` |
131
+ | `use_default_styles` | Indicates if you want to use the default styles. | `true` |
132
+ | `base_url` | Indicates the base URL to prepend for assets and links. | `true` |
129
133
  | `delete_output` | Deletes `output_dir` before generating content. | `false` |
130
134
  | `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. |
131
135
  | `renderer` | The rendering class to use. | `GraphQLDocs::Renderer`
132
- | `templates` | The templates to use when generating HTML. You may override any of the following keys: `includes`, `objects`, `mutations`, `interfaces`, `enums`, `unions`, `input_objects`, `scalars`. | The default gem ones are found in _layouts/_.
136
+ | `templates` | The templates to use when generating HTML. You may override any of the following keys: `includes`, `objects`, `mutations`, `interfaces`, `enums`, `unions`, `input_objects`, `scalars`, `index`. | The defaults are found in _lib/graphql-docs/layouts/_.
133
137
 
134
138
  ## Development
135
139
 
136
- After checking out the repo, run `script/bootstrap` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
140
+ After checking out the repo, run `script/bootstrap` to install dependencies. Then, run `rake test` to run the tests. You can also run `bundle exec rake console` for an interactive prompt that will allow you to experiment.
137
141
 
138
142
  ## Sample site
139
143
 
data/Rakefile CHANGED
@@ -22,30 +22,41 @@ task :console do
22
22
  Pry.start
23
23
  end
24
24
 
25
- task :sample do
25
+ task :generate_sample, [:base_url] do |task, args|
26
26
  require 'graphql-docs'
27
- require 'sass'
28
27
 
29
28
  options = {}
30
- options[:output_dir] = 'sample'
31
29
  options[:delete_output] = true
30
+ options[:base_url] = args.base_url || ''
32
31
  options[:path] = File.join(File.dirname(__FILE__), 'test', 'graphql-docs', 'fixtures', 'gh-api.json')
33
32
 
34
33
  GraphQLDocs.build(options)
34
+ end
35
35
 
36
- assets_dir = File.join('sample', 'assets')
37
- FileUtils.mkdir_p(assets_dir)
38
-
39
- sass = File.join('sample_assets', 'css', 'screen.scss')
40
- system `sass --sourcemap=none #{sass}:style.css`
36
+ task :sample => [:generate_sample] do
37
+ require 'webrick'
41
38
 
42
- FileUtils.mv('style.css', File.join('sample', 'assets/style.css'))
39
+ puts 'Navigate to http://localhost:3000 to see the sample docs'
43
40
 
44
- starting_dir = 'sample'
45
- starting_file = File.join(starting_dir, 'object', 'repository', 'index.html')
41
+ server = WEBrick::HTTPServer.new Port: 3000
42
+ server.mount '/', WEBrick::HTTPServlet::FileHandler, 'output'
43
+ trap('INT') { server.stop }
44
+ server.start
45
+ end
46
46
 
47
- puts 'Navigate to http://localhost:3000 to see the sample docs'
48
- puts "Launching #{starting_file}"
49
- system "open #{starting_file}"
50
- system "ruby -run -e httpd #{starting_dir} -p 3000"
47
+ desc 'Generate and publish docs to gh-pages'
48
+ task :publish do
49
+ Rake::Task[:generate_sample].invoke('https://www.gjtorikian.com/graphql-docs/')
50
+ Dir.mktmpdir do |tmp|
51
+ system "mv output/* #{tmp}"
52
+ system 'git checkout gh-pages'
53
+ system 'rm -rf *'
54
+ system "mv #{tmp}/* ."
55
+ message = "Site updated at #{Time.now.utc}"
56
+ system 'git add .'
57
+ system "git commit -am #{message.shellescape}"
58
+ system 'git push origin gh-pages --force'
59
+ system 'git checkout master'
60
+ system 'echo yolo'
61
+ end
51
62
  end
@@ -28,14 +28,15 @@ Gem::Specification.new do |spec|
28
28
  spec.add_dependency 'github-markdown', '0.6.9'
29
29
  spec.add_dependency 'extended-markdown-filter', '~> 0.4'
30
30
  spec.add_dependency 'gemoji', '2.1.0'
31
+ spec.add_dependency 'sass', '~> 3.4'
31
32
 
32
33
  spec.add_development_dependency 'awesome_print'
33
34
  spec.add_development_dependency 'bundler', '~> 1.14'
35
+ spec.add_development_dependency 'html-proofer', '~> 3.4'
34
36
  spec.add_development_dependency 'minitest', '~> 5.0'
35
37
  spec.add_development_dependency 'minitest-focus', '~> 1.1'
36
38
  spec.add_development_dependency 'pry', '~> 0.10.0'
37
39
  spec.add_development_dependency 'rake', '~> 10.0'
38
40
  spec.add_development_dependency 'rubocop-github'
39
- spec.add_development_dependency 'sass', '~> 3.4'
40
41
  spec.add_development_dependency 'webmock', '~> 2.3'
41
42
  end
@@ -30,10 +30,11 @@ module GraphQLDocs
30
30
  end
31
31
 
32
32
  def fetch
33
- @faraday.post do |req|
33
+ res = @faraday.post do |req|
34
34
  req.headers['Content-Type'] = 'application/json'
35
35
  req.body = "{ \"query\": \"#{GraphQL::Introspection::INTROSPECTION_QUERY.gsub("\n", '')}\" }"
36
36
  end
37
+ res.body
37
38
  end
38
39
 
39
40
  def inspect
@@ -22,9 +22,12 @@ module GraphQLDocs
22
22
  }
23
23
  },
24
24
  renderer: GraphQLDocs::Renderer,
25
+ use_default_styles: true,
26
+ base_url: '',
25
27
 
26
28
  templates: {
27
29
  default: "#{File.dirname(__FILE__)}/layouts/default.html",
30
+
28
31
  includes: "#{File.dirname(__FILE__)}/layouts/includes",
29
32
  objects: "#{File.dirname(__FILE__)}/layouts/graphql_objects.html",
30
33
  mutations: "#{File.dirname(__FILE__)}/layouts/graphql_mutations.html",
@@ -32,7 +35,9 @@ module GraphQLDocs
32
35
  enums: "#{File.dirname(__FILE__)}/layouts/graphql_enums.html",
33
36
  unions: "#{File.dirname(__FILE__)}/layouts/graphql_unions.html",
34
37
  input_objects: "#{File.dirname(__FILE__)}/layouts/graphql_input_objects.html",
35
- scalars: "#{File.dirname(__FILE__)}/layouts/graphql_scalars.html"
38
+ scalars: "#{File.dirname(__FILE__)}/layouts/graphql_scalars.html",
39
+
40
+ index: "#{File.dirname(__FILE__)}/layouts/index.md",
36
41
  }
37
42
  }.freeze
38
43
  end
@@ -1,4 +1,5 @@
1
1
  require 'erb'
2
+ require 'sass'
2
3
 
3
4
  module GraphQLDocs
4
5
  class Generator
@@ -32,6 +33,21 @@ module GraphQLDocs
32
33
  create_graphql_input_object_pages
33
34
  create_graphql_scalar_pages
34
35
 
36
+ unless @options[:templates][:index].nil?
37
+ write_file('static', 'index', File.read(@options[:templates][:index]))
38
+ end
39
+
40
+ if @options[:use_default_styles]
41
+ assets_dir = File.join(File.dirname(__FILE__), 'layouts', 'assets')
42
+ FileUtils.mkdir_p(File.join(@options[:output_dir], 'assets'))
43
+
44
+ sass = File.join(assets_dir, 'css', 'screen.scss')
45
+ system `sass --sourcemap=none #{sass}:#{@options[:output_dir]}/assets/style.css`
46
+
47
+ FileUtils.cp_r(File.join(assets_dir, 'images'), File.join(@options[:output_dir], 'assets'))
48
+ FileUtils.cp_r(File.join(assets_dir, 'webfonts'), File.join(@options[:output_dir], 'assets'))
49
+ end
50
+
35
51
  true
36
52
  end
37
53
 
@@ -106,8 +122,16 @@ module GraphQLDocs
106
122
  private
107
123
 
108
124
  def write_file(type, name, contents)
109
- path = File.join(@options[:output_dir], type, name.downcase)
110
- FileUtils.mkdir_p(path)
125
+ if type == 'static'
126
+ if name == 'index'
127
+ path = @options[:output_dir]
128
+ else
129
+ path = File.join(@options[:output_dir], name)
130
+ end
131
+ else
132
+ path = File.join(@options[:output_dir], type, name.downcase)
133
+ FileUtils.mkdir_p(path)
134
+ end
111
135
  contents = @renderer.render(type, name, contents)
112
136
  File.write(File.join(path, 'index.html'), contents) unless contents.nil?
113
137
  end
@@ -0,0 +1,21 @@
1
+ @import "//hello.myfonts.net/count/2c4b9d";
2
+ @font-face {
3
+ font-family: 'ProximaNova-Light';
4
+ src: url("webfonts/2C4B9D_B_0.eot");
5
+ src: url("webfonts/2C4B9D_B_0.eot?#iefix") format('embedded-opentype'), url("webfonts/2C4B9D_B_0.woff2") format('woff2'), url("webfonts/2C4B9D_B_0.woff") format('woff'), url("webfonts/2C4B9D_B_0.ttf") format('truetype');
6
+ }
7
+ @font-face {
8
+ font-family: 'ProximaNova-Semibold';
9
+ src: url("webfonts/2C4B9D_C_0.eot");
10
+ src: url("webfonts/2C4B9D_C_0.eot?#iefix") format('embedded-opentype'), url("webfonts/2C4B9D_C_0.woff2") format('woff2'), url("webfonts/2C4B9D_C_0.woff") format('woff'), url("webfonts/2C4B9D_C_0.ttf") format('truetype');
11
+ }
12
+ @font-face {
13
+ font-family: 'ProximaNova-Regular';
14
+ src: url("webfonts/2C4B9D_D_0.eot");
15
+ src: url("webfonts/2C4B9D_D_0.eot?#iefix") format('embedded-opentype'), url("webfonts/2C4B9D_D_0.woff2") format('woff2'), url("webfonts/2C4B9D_D_0.woff") format('woff'), url("webfonts/2C4B9D_D_0.ttf") format('truetype');
16
+ }
17
+ @font-face {
18
+ font-family: 'ProximaNova-Bold';
19
+ src: url("webfonts/2C4B9D_E_0.eot");
20
+ src: url("webfonts/2C4B9D_E_0.eot?#iefix") format('embedded-opentype'), url("webfonts/2C4B9D_E_0.woff2") format('woff2'), url("webfonts/2C4B9D_E_0.woff") format('woff'), url("webfonts/2C4B9D_E_0.ttf") format('truetype');
21
+ }
@@ -14,7 +14,7 @@
14
14
  height: 24px;
15
15
  top: 8px;
16
16
  left: 12px;
17
- background: url("../images/menu.png") center center no-repeat;
17
+ background: url("../assets/images/menu.png") center center no-repeat;
18
18
  background-size: 24px;
19
19
  opacity: 0.5;
20
20
  }
@@ -8,7 +8,7 @@
8
8
  padding: 7px 12px 6px 32px;
9
9
  border-radius: 20px;
10
10
  border: 1px solid #ddd;
11
- background: url("../images/search.png") 8px 6px no-repeat;
11
+ background: url("../assets/images/search.png") 8px 6px no-repeat;
12
12
  background-size: 20px;
13
13
  transition: border-color 0.25s ease;
14
14
  &:focus {
@@ -25,7 +25,7 @@
25
25
  padding: 7px 12px 6px 32px;
26
26
  border-radius: 20px;
27
27
  border: 1px solid #ddd;
28
- background: url("../images/search.png") 8px 6px no-repeat;
28
+ background: url("../assets/images/search.png") 8px 6px no-repeat;
29
29
  background-size: 20px;
30
30
  transition: border-color 0.25s ease;
31
31
  &:focus {
@@ -5,9 +5,21 @@
5
5
  <meta name="description" content="<%= name %> GraphQL documentation">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
7
7
  <title><%= name %></title>
8
- <link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,300,200,300italic,400italic' rel='stylesheet' type='text/css'>
9
- <link rel="stylesheet" href="../../assets/style.css">
10
- <script src="https://code.jquery.com/jquery-3.0.0.min.js" integrity="sha256-JmvOoLtYsmqlsWxa7mDSLMwa6dZ9rrIdtrrVYRnDRH0=" crossorigin="anonymous"></script>
8
+ <link rel="stylesheet" href="<%= base_url %>/assets/style.css">
9
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/anchor-js/3.2.2/anchor.min.js"></script>
10
+ <script>
11
+
12
+ // Add anchors on DOMContentLoaded
13
+ document.addEventListener("DOMContentLoaded", function(event) {
14
+ anchors.options = {
15
+ placement: 'left',
16
+ visible: 'hover',
17
+ icon: '¶'
18
+ };
19
+ anchors.add('h3');
20
+ });
21
+
22
+ </script>
11
23
  </head>
12
24
  <body>
13
25
 
@@ -19,8 +31,6 @@
19
31
  </div>
20
32
  <div id="content">
21
33
 
22
- <h1><%= name %></h1>
23
-
24
34
  <%= contents %>
25
35
 
26
36
  </div>
@@ -35,5 +45,6 @@
35
45
  <div id="mobile-shade"></div>
36
46
 
37
47
  </div>
48
+
38
49
  </body>
39
50
  </html>
@@ -8,7 +8,7 @@
8
8
 
9
9
  <ul>
10
10
  <% type['interfaces'].each do |interface| %>
11
- <li><code><a href="./interface/<%= slugify.(interface['name']) %>"><%= interface['name'] %></a></code></li>
11
+ <li><code><a href="<%= base_url %>/interface/<%= slugify.(interface['name']) %>"><%= interface['name'] %></a></code></li>
12
12
  <% end %>
13
13
  </ul>
14
14
 
@@ -1,7 +1,7 @@
1
1
  <% connections.each do |connection| %>
2
2
 
3
3
  <div class="field-entry my-4">
4
- <span class="field-name connection-name"><%= connection['name'] %> (<a href="./object/<%= slugify.(connection['type']['ofType']['name']) %>" class="js-connection-name"><code><%= connection['type']['ofType']['name'] %></code></a>)</span>
4
+ <span class="field-name connection-name"><%= connection['name'] %> (<a href="<%= base_url %>/object/<%= slugify.(connection['type']['ofType']['name']) %>" class="js-connection-name"><code><%= connection['type']['ofType']['name'] %></code></a>)</span>
5
5
 
6
6
  <div class="description-wrapper">
7
7
  <%= connection['description'] %>
@@ -24,7 +24,7 @@
24
24
  <% @type_name = field['type']['ofType']['name'] %>
25
25
  <% end %>
26
26
 
27
- <span class="field-name"><%= field['name'] %> (<code><a href="./<%= @type_path.downcase %>/<%= slugify.(@type_name) %>"><%= @type_name %></a></code>)</span>
27
+ <span class="field-name"><%= field['name'] %> (<code><a href="<%= base_url %>/<%= @type_path.downcase %>/<%= slugify.(@type_name) %>"><%= @type_name %></a></code>)</span>
28
28
 
29
29
  <div class="description-wrapper">
30
30
  <% if field['isDeprecated'] %>
@@ -26,7 +26,7 @@
26
26
  <% @type_name = field['type']['ofType']['name'] %>
27
27
  <% end %>
28
28
 
29
- <span class="field-name"><%= field['name'] %> (<a href="./<%= @type_path.downcase %>/slugify.(@type_name.parameterize)"><code><%= @type_name %></code></a>)</span>
29
+ <span class="field-name"><%= field['name'] %> (<a href="<%= base_url %>/<%= @type_path.downcase %>/<%= slugify.(@type_name) %>"><code><%= @type_name %></code></a>)</span>
30
30
 
31
31
  <div class="description-wrapper">
32
32
  <%= field['description'] %>
@@ -3,7 +3,7 @@
3
3
  <ul>
4
4
 
5
5
  <% possible_types.each do |possible_type| %>
6
- <li><a href="./<%= slugify.(possible_type['name']) %>"><%= possible_type['name'] %></a></li>
6
+ <li><a href="<%= base_url %>/object/<%= slugify.(possible_type['name']) %>"><%= possible_type['name'] %></a></li>
7
7
  <% end %>
8
8
 
9
9
  </ul>
@@ -2,7 +2,7 @@
2
2
  <li>
3
3
  <ul class="menu-root">
4
4
  <li>
5
- GraphQL Reference
5
+ <a href="/">GraphQL Reference</a>
6
6
  </ul>
7
7
  </li>
8
8
 
@@ -10,12 +10,12 @@
10
10
  <p>Queries</p>
11
11
  <ul class="menu-root">
12
12
  <li>
13
- <a href="../../object/query" class="sidebar-link<% if title == "Query" %> current<% end %>">
13
+ <a href="<%= base_url %>/object/query/" class="sidebar-link<% if title == "Query" %> current<% end %>">
14
14
  RootQuery
15
15
  </a>
16
16
  </li>
17
17
  <li>
18
- <a href="../../object/mutation" class="sidebar-link<% if title == "Mutation" %> current<% end %>">
18
+ <a href="<%= base_url %>/object/mutation" class="sidebar-link<% if title == "Mutation" %> current<% end %>">
19
19
  Mutation
20
20
  </a>
21
21
  </li>
@@ -43,7 +43,7 @@
43
43
  <% end %>
44
44
 
45
45
  <li>
46
- <a href="../../object/<%= @name.downcase %>/index.html" class="sidebar-link<% if title == @name %> current<% end %>">
46
+ <a href="<%= base_url %>/object/<%= @name.downcase %>/index.html" class="sidebar-link<% if title == @name %> current<% end %>">
47
47
  <%= @name %>
48
48
  </a>
49
49
  </li>
@@ -57,7 +57,7 @@
57
57
  <% graphql_interface_types.().each do |type| %>
58
58
  <% @name = type["name"] %>
59
59
  <li>
60
- <a href="../../interface/<%= @name.downcase %>/index.html" class="sidebar-link<% if title == @name %> current<% end %>">
60
+ <a href="<%= base_url %>/interface/<%= @name.downcase %>/index.html" class="sidebar-link<% if title == @name %> current<% end %>">
61
61
  <%= @name %>
62
62
  </a>
63
63
  </li>
@@ -75,7 +75,7 @@
75
75
  <% next %>
76
76
  <% end %>
77
77
  <li>
78
- <a href="../../enum/<%= @name.downcase %>/index.html" class="sidebar-link<% if title == @name %> current<% end %>">
78
+ <a href="<%= base_url %>/enum/<%= @name.downcase %>/index.html" class="sidebar-link<% if title == @name %> current<% end %>">
79
79
  <%= @name %>
80
80
  </a>
81
81
  </li>
@@ -89,7 +89,7 @@
89
89
  <% graphql_union_types.().each do |type| %>
90
90
  <% @name = type["name"] %>
91
91
  <li>
92
- <a href="../../union/<%= @name.downcase %>/index.html" class="sidebar-link<% if title == @name %> current<% end %>">
92
+ <a href="<%= base_url %>/union/<%= @name.downcase %>/index.html" class="sidebar-link<% if title == @name %> current<% end %>">
93
93
  <%= @name %>
94
94
  </a>
95
95
  </li>
@@ -103,7 +103,7 @@
103
103
  <% graphql_input_object_types.().each do |type| %>
104
104
  <% @name = type["name"] %>
105
105
  <li>
106
- <a href="../../input_object/<%= @name.downcase %>/index.html" class="sidebar-link<% if title == @name %> current<% end %>">
106
+ <a href="<%= base_url %>/input_object/<%= @name.downcase %>/index.html" class="sidebar-link<% if title == @name %> current<% end %>">
107
107
  <%= @name %>
108
108
  </a>
109
109
  </li>
@@ -117,7 +117,7 @@
117
117
  <% graphql_scalar_types.().each do |type| %>
118
118
  <% @name = type["name"] %>
119
119
  <li>
120
- <a href="../../scalar/<%= @name.downcase %>/index.html" class="sidebar-link<% if title == @name %> current<% end %>">
120
+ <a href="<%= base_url %>/scalar/<%= @name.downcase %>/index.html" class="sidebar-link<% if title == @name %> current<% end %>">
121
121
  <%= @name %>
122
122
  </a>
123
123
  </li>
@@ -0,0 +1,7 @@
1
+ # GraphQL Reference
2
+
3
+ These docs were generated by [graphql-docs](https://github.com/gjtorikian/graphql-docs).
4
+
5
+ ## New to GraphQL?
6
+
7
+ Just starting out with GraphQL? Check out GraphQL's [official documentation](http://graphql.org/)!
@@ -23,9 +23,16 @@ module GraphQLDocs
23
23
  type_kinds.each do |kind|
24
24
  @processed_schema["#{kind.downcase}_types"] = @processed_schema['types'].select { |t| t['kind'] == kind }
25
25
  end
26
- @processed_schema['mutation_types'] = @processed_schema['object_types'].select do |t|
26
+ mutation_types = @processed_schema['object_types'].select do |t|
27
27
  t['name'] == 'Mutation'
28
- end.first['fields']
28
+ end
29
+
30
+ @processed_schema['mutation_types'] = if mutation_types.empty?
31
+ []
32
+ else
33
+ @processed_schema['mutation_types'] = mutation_types.first['fields']
34
+ end
35
+
29
36
  # TODO: should the 'types' key be deleted now?
30
37
 
31
38
  @processed_schema
@@ -36,7 +36,8 @@ 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 = { contents: contents, type: type, name: name}.merge(helper_methods)
39
+ opts = @options
40
+ opts = opts.merge({ contents: contents, type: type, name: name}).merge(helper_methods)
40
41
  @graphql_default_layout.result(OpenStruct.new(opts).instance_eval { binding })
41
42
  end
42
43
 
@@ -1,3 +1,3 @@
1
1
  module GraphQLDocs
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  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: 0.1.1
4
+ version: 0.2.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: 2017-02-17 00:00:00.000000000 Z
11
+ date: 2017-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - '='
95
95
  - !ruby/object:Gem::Version
96
96
  version: 2.1.0
97
+ - !ruby/object:Gem::Dependency
98
+ name: sass
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.4'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.4'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: awesome_print
99
113
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +136,20 @@ dependencies:
122
136
  - - "~>"
123
137
  - !ruby/object:Gem::Version
124
138
  version: '1.14'
139
+ - !ruby/object:Gem::Dependency
140
+ name: html-proofer
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '3.4'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '3.4'
125
153
  - !ruby/object:Gem::Dependency
126
154
  name: minitest
127
155
  requirement: !ruby/object:Gem::Requirement
@@ -192,20 +220,6 @@ dependencies:
192
220
  - - ">="
193
221
  - !ruby/object:Gem::Version
194
222
  version: '0'
195
- - !ruby/object:Gem::Dependency
196
- name: sass
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - "~>"
200
- - !ruby/object:Gem::Version
201
- version: '3.4'
202
- type: :development
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - "~>"
207
- - !ruby/object:Gem::Version
208
- version: '3.4'
209
223
  - !ruby/object:Gem::Dependency
210
224
  name: webmock
211
225
  requirement: !ruby/object:Gem::Requirement
@@ -240,6 +254,39 @@ files:
240
254
  - lib/graphql-docs/configuration.rb
241
255
  - lib/graphql-docs/generator.rb
242
256
  - lib/graphql-docs/helpers.rb
257
+ - lib/graphql-docs/layouts/assets/_sass/_api-box.scss
258
+ - lib/graphql-docs/layouts/assets/_sass/_content.scss
259
+ - lib/graphql-docs/layouts/assets/_sass/_fonts.scss
260
+ - lib/graphql-docs/layouts/assets/_sass/_header.scss
261
+ - lib/graphql-docs/layouts/assets/_sass/_mobile.scss
262
+ - lib/graphql-docs/layouts/assets/_sass/_normalize.scss
263
+ - lib/graphql-docs/layouts/assets/_sass/_search.scss
264
+ - lib/graphql-docs/layouts/assets/_sass/_sidebar.scss
265
+ - lib/graphql-docs/layouts/assets/_sass/_syntax.scss
266
+ - lib/graphql-docs/layouts/assets/_sass/_types.scss
267
+ - lib/graphql-docs/layouts/assets/_sass/screen.scss
268
+ - lib/graphql-docs/layouts/assets/css/screen.scss
269
+ - lib/graphql-docs/layouts/assets/images/graphiql-headers.png
270
+ - lib/graphql-docs/layouts/assets/images/graphiql-variables.png
271
+ - lib/graphql-docs/layouts/assets/images/graphiql.png
272
+ - lib/graphql-docs/layouts/assets/images/menu.png
273
+ - lib/graphql-docs/layouts/assets/images/navbar.png
274
+ - lib/graphql-docs/layouts/assets/webfonts/2C4B9D_B_0.eot
275
+ - lib/graphql-docs/layouts/assets/webfonts/2C4B9D_B_0.ttf
276
+ - lib/graphql-docs/layouts/assets/webfonts/2C4B9D_B_0.woff
277
+ - lib/graphql-docs/layouts/assets/webfonts/2C4B9D_B_0.woff2
278
+ - lib/graphql-docs/layouts/assets/webfonts/2C4B9D_C_0.eot
279
+ - lib/graphql-docs/layouts/assets/webfonts/2C4B9D_C_0.ttf
280
+ - lib/graphql-docs/layouts/assets/webfonts/2C4B9D_C_0.woff
281
+ - lib/graphql-docs/layouts/assets/webfonts/2C4B9D_C_0.woff2
282
+ - lib/graphql-docs/layouts/assets/webfonts/2C4B9D_D_0.eot
283
+ - lib/graphql-docs/layouts/assets/webfonts/2C4B9D_D_0.ttf
284
+ - lib/graphql-docs/layouts/assets/webfonts/2C4B9D_D_0.woff
285
+ - lib/graphql-docs/layouts/assets/webfonts/2C4B9D_D_0.woff2
286
+ - lib/graphql-docs/layouts/assets/webfonts/2C4B9D_E_0.eot
287
+ - lib/graphql-docs/layouts/assets/webfonts/2C4B9D_E_0.ttf
288
+ - lib/graphql-docs/layouts/assets/webfonts/2C4B9D_E_0.woff
289
+ - lib/graphql-docs/layouts/assets/webfonts/2C4B9D_E_0.woff2
243
290
  - lib/graphql-docs/layouts/default.html
244
291
  - lib/graphql-docs/layouts/graphql_enums.html
245
292
  - lib/graphql-docs/layouts/graphql_input_objects.html
@@ -255,21 +302,10 @@ files:
255
302
  - lib/graphql-docs/layouts/includes/possible_types.html
256
303
  - lib/graphql-docs/layouts/includes/sidebar.html
257
304
  - lib/graphql-docs/layouts/includes/values.html
305
+ - lib/graphql-docs/layouts/index.md
258
306
  - lib/graphql-docs/parser.rb
259
307
  - lib/graphql-docs/renderer.rb
260
308
  - lib/graphql-docs/version.rb
261
- - sample_assets/_sass/_api-box.scss
262
- - sample_assets/_sass/_content.scss
263
- - sample_assets/_sass/_fonts.scss
264
- - sample_assets/_sass/_header.scss
265
- - sample_assets/_sass/_mobile.scss
266
- - sample_assets/_sass/_normalize.scss
267
- - sample_assets/_sass/_search.scss
268
- - sample_assets/_sass/_sidebar.scss
269
- - sample_assets/_sass/_syntax.scss
270
- - sample_assets/_sass/_types.scss
271
- - sample_assets/_sass/screen.scss
272
- - sample_assets/css/screen.scss
273
309
  - script/bootstrap
274
310
  - script/console
275
311
  homepage: https://github.com/gjtorikian/graphql-docs
@@ -1,21 +0,0 @@
1
- @import "//hello.myfonts.net/count/2c4b9d";
2
- @font-face {
3
- font-family: 'ProximaNova-Light';
4
- src: url("/assets/webfonts/2C4B9D_B_0.eot");
5
- src: url("/assets/webfonts/2C4B9D_B_0.eot?#iefix") format('embedded-opentype'), url("/assets/webfonts/2C4B9D_B_0.woff2") format('woff2'), url("/assets/webfonts/2C4B9D_B_0.woff") format('woff'), url("/assets/webfonts/2C4B9D_B_0.ttf") format('truetype');
6
- }
7
- @font-face {
8
- font-family: 'ProximaNova-Semibold';
9
- src: url("/assets/webfonts/2C4B9D_C_0.eot");
10
- src: url("/assets/webfonts/2C4B9D_C_0.eot?#iefix") format('embedded-opentype'), url("/assets/webfonts/2C4B9D_C_0.woff2") format('woff2'), url("/assets/webfonts/2C4B9D_C_0.woff") format('woff'), url("/assets/webfonts/2C4B9D_C_0.ttf") format('truetype');
11
- }
12
- @font-face {
13
- font-family: 'ProximaNova-Regular';
14
- src: url("/assets/webfonts/2C4B9D_D_0.eot");
15
- src: url("/assets/webfonts/2C4B9D_D_0.eot?#iefix") format('embedded-opentype'), url("/assets/webfonts/2C4B9D_D_0.woff2") format('woff2'), url("/assets/webfonts/2C4B9D_D_0.woff") format('woff'), url("/assets/webfonts/2C4B9D_D_0.ttf") format('truetype');
16
- }
17
- @font-face {
18
- font-family: 'ProximaNova-Bold';
19
- src: url("/assets/webfonts/2C4B9D_E_0.eot");
20
- src: url("/assets/webfonts/2C4B9D_E_0.eot?#iefix") format('embedded-opentype'), url("/assets/webfonts/2C4B9D_E_0.woff2") format('woff2'), url("/assets/webfonts/2C4B9D_E_0.woff") format('woff'), url("/assets/webfonts/2C4B9D_E_0.ttf") format('truetype');
21
- }