graphql-docs 0.4.1 → 0.5.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/.travis.yml +20 -3
- data/README.md +2 -1
- data/Rakefile +5 -1
- data/lib/graphql-docs.rb +1 -0
- data/lib/graphql-docs/configuration.rb +11 -1
- data/lib/graphql-docs/generator.rb +57 -5
- data/lib/graphql-docs/landing_pages/enum.md +9 -0
- data/lib/graphql-docs/{layouts → landing_pages}/index.md +4 -0
- data/lib/graphql-docs/landing_pages/input_object.md +9 -0
- data/lib/graphql-docs/landing_pages/interface.md +9 -0
- data/lib/graphql-docs/landing_pages/mutation.md +11 -0
- data/lib/graphql-docs/landing_pages/object.md +8 -0
- data/lib/graphql-docs/landing_pages/query.md +4 -0
- data/lib/graphql-docs/landing_pages/scalar.md +9 -0
- data/lib/graphql-docs/landing_pages/union.md +9 -0
- data/lib/graphql-docs/layouts/default.html +1 -1
- data/lib/graphql-docs/layouts/graphql_enums.html +1 -1
- data/lib/graphql-docs/layouts/graphql_input_objects.html +1 -1
- data/lib/graphql-docs/layouts/graphql_interfaces.html +2 -2
- data/lib/graphql-docs/layouts/graphql_mutations.html +2 -2
- data/lib/graphql-docs/layouts/graphql_objects.html +4 -4
- data/lib/graphql-docs/layouts/graphql_scalars.html +1 -1
- data/lib/graphql-docs/layouts/graphql_unions.html +1 -1
- data/lib/graphql-docs/layouts/includes/sidebar.html +33 -10
- data/lib/graphql-docs/renderer.rb +30 -1
- data/lib/graphql-docs/version.rb +1 -1
- metadata +11 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 57b3bab2a270f24272f4dbd5f01e35b4ca808c69
         | 
| 4 | 
            +
              data.tar.gz: 40b5d99232276274abc5f96fd0cf3e6a3744ffe1
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 44dbb949bd168632077b04c060766740929309f04353730d165518241633b5f5f814b01935ad854a1fd1307e4950936b0f054b6be388a96c58c827efd3f15d77
         | 
| 7 | 
            +
              data.tar.gz: acc2174c4f16ec02f995185c70817e337db9c045b57f9cc91a85c84036f9d1d7cc33692e49d5f2ff2811dec3c5aed6152c66bbf72a7e48d1e99bef1b8772c540
         | 
    
        data/.travis.yml
    CHANGED
    
    | @@ -1,9 +1,26 @@ | |
| 1 1 | 
             
            language: ruby
         | 
| 2 2 | 
             
            rvm:
         | 
| 3 | 
            -
              - 2.3. | 
| 3 | 
            +
              - 2.3.4
         | 
| 4 | 
            +
              - 2.4.0
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            git:
         | 
| 7 | 
            +
              depth: 10
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            env:
         | 
| 10 | 
            +
              global:
         | 
| 11 | 
            +
                - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
         | 
| 4 12 |  | 
| 5 13 | 
             
            sudo: false
         | 
| 6 14 | 
             
            cache: bundler
         | 
| 7 15 |  | 
| 8 | 
            -
             | 
| 9 | 
            -
               | 
| 16 | 
            +
            addons:
         | 
| 17 | 
            +
              apt:
         | 
| 18 | 
            +
                sources:
         | 
| 19 | 
            +
                  - kalakris-cmake
         | 
| 20 | 
            +
                packages:
         | 
| 21 | 
            +
                  - cmake
         | 
| 22 | 
            +
             | 
| 23 | 
            +
            matrix:
         | 
| 24 | 
            +
              include:
         | 
| 25 | 
            +
                - script: bundle exec rake rubocop
         | 
| 26 | 
            +
                  rvm: 2.4.0
         | 
    
        data/README.md
    CHANGED
    
    | @@ -134,7 +134,8 @@ The following options are available: | |
| 134 134 | 
             
            | `delete_output` | Deletes `output_dir` before generating content. | `false` |
         | 
| 135 135 | 
             
            | `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. |
         | 
| 136 136 | 
             
            | `renderer` | The rendering class to use. | `GraphQLDocs::Renderer`
         | 
| 137 | 
            -
            | `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 | 
| 137 | 
            +
            | `templates` | The templates to use when generating HTML. You may override any of the following keys: `default`, `includes`, `objects`, `mutations`, `interfaces`, `enums`, `unions`, `input_objects`, `scalars`. | The defaults are found in _lib/graphql-docs/layouts/_.
         | 
| 138 | 
            +
            | `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/layouts/_.
         | 
| 138 139 | 
             
            | `classes` | Additional class names you can provide to certain elements. | The full list is found in _lib/graphql-docs/configuration.rb/_.
         | 
| 139 140 |  | 
| 140 141 | 
             
            ## Development
         | 
    
        data/Rakefile
    CHANGED
    
    | @@ -1,6 +1,10 @@ | |
| 1 1 | 
             
            require 'bundler/gem_tasks'
         | 
| 2 2 | 
             
            require 'rake/testtask'
         | 
| 3 3 |  | 
| 4 | 
            +
            require 'rubocop/rake_task'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            RuboCop::RakeTask.new(:rubocop)
         | 
| 7 | 
            +
             | 
| 4 8 | 
             
            Rake::TestTask.new(:test) do |t|
         | 
| 5 9 | 
             
              t.libs << 'test'
         | 
| 6 10 | 
             
              t.libs << 'lib'
         | 
| @@ -33,7 +37,7 @@ task :generate_sample, [:base_url] do |task, args| | |
| 33 37 | 
             
              GraphQLDocs.build(options)
         | 
| 34 38 | 
             
            end
         | 
| 35 39 |  | 
| 36 | 
            -
            task : | 
| 40 | 
            +
            task sample: [:generate_sample] do
         | 
| 37 41 | 
             
              require 'webrick'
         | 
| 38 42 |  | 
| 39 43 | 
             
              puts 'Navigate to http://localhost:3000 to see the sample docs'
         | 
    
        data/lib/graphql-docs.rb
    CHANGED
    
    
| @@ -36,8 +36,18 @@ module GraphQLDocs | |
| 36 36 | 
             
                    unions: "#{File.dirname(__FILE__)}/layouts/graphql_unions.html",
         | 
| 37 37 | 
             
                    input_objects: "#{File.dirname(__FILE__)}/layouts/graphql_input_objects.html",
         | 
| 38 38 | 
             
                    scalars: "#{File.dirname(__FILE__)}/layouts/graphql_scalars.html",
         | 
| 39 | 
            +
                  },
         | 
| 39 40 |  | 
| 40 | 
            -
             | 
| 41 | 
            +
                  landing_pages: {
         | 
| 42 | 
            +
                    index: "#{File.dirname(__FILE__)}/landing_pages/index.md",
         | 
| 43 | 
            +
                    query: "#{File.dirname(__FILE__)}/landing_pages/query.md",
         | 
| 44 | 
            +
                    object: "#{File.dirname(__FILE__)}/landing_pages/object.md",
         | 
| 45 | 
            +
                    mutation: "#{File.dirname(__FILE__)}/landing_pages/mutation.md",
         | 
| 46 | 
            +
                    interface: "#{File.dirname(__FILE__)}/landing_pages/interface.md",
         | 
| 47 | 
            +
                    enum: "#{File.dirname(__FILE__)}/landing_pages/enum.md",
         | 
| 48 | 
            +
                    union: "#{File.dirname(__FILE__)}/landing_pages/union.md",
         | 
| 49 | 
            +
                    input_object: "#{File.dirname(__FILE__)}/landing_pages/input_object.md",
         | 
| 50 | 
            +
                    scalar: "#{File.dirname(__FILE__)}/landing_pages/scalar.md"
         | 
| 41 51 | 
             
                  },
         | 
| 42 52 |  | 
| 43 53 | 
             
                  classes: {
         | 
| @@ -33,8 +33,36 @@ module GraphQLDocs | |
| 33 33 | 
             
                  create_graphql_input_object_pages
         | 
| 34 34 | 
             
                  create_graphql_scalar_pages
         | 
| 35 35 |  | 
| 36 | 
            -
                  unless @options[: | 
| 37 | 
            -
                    write_file('static', 'index', File.read(@options[: | 
| 36 | 
            +
                  unless @options[:landing_pages][:index].nil?
         | 
| 37 | 
            +
                    write_file('static', 'index', File.read(@options[:landing_pages][:index]))
         | 
| 38 | 
            +
                  end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  unless @options[:landing_pages][:object].nil?
         | 
| 41 | 
            +
                    write_file('static', 'object', File.read(@options[:landing_pages][:object]))
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                  unless @options[:landing_pages][:mutation].nil?
         | 
| 45 | 
            +
                    write_file('static', 'mutation', File.read(@options[:landing_pages][:mutation]))
         | 
| 46 | 
            +
                  end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                  unless @options[:landing_pages][:interface].nil?
         | 
| 49 | 
            +
                    write_file('static', 'interface', File.read(@options[:landing_pages][:interface]))
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                  unless @options[:landing_pages][:enum].nil?
         | 
| 53 | 
            +
                    write_file('static', 'enum', File.read(@options[:landing_pages][:enum]))
         | 
| 54 | 
            +
                  end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                  unless @options[:landing_pages][:union].nil?
         | 
| 57 | 
            +
                    write_file('static', 'union', File.read(@options[:landing_pages][:union]))
         | 
| 58 | 
            +
                  end
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                  unless @options[:landing_pages][:input_object].nil?
         | 
| 61 | 
            +
                    write_file('static', 'input_object', File.read(@options[:landing_pages][:input_object]))
         | 
| 62 | 
            +
                  end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                  unless @options[:landing_pages][:scalar].nil?
         | 
| 65 | 
            +
                    write_file('static', 'scalar', File.read(@options[:landing_pages][:scalar]))
         | 
| 38 66 | 
             
                  end
         | 
| 39 67 |  | 
| 40 68 | 
             
                  if @options[:use_default_styles]
         | 
| @@ -54,9 +82,32 @@ module GraphQLDocs | |
| 54 82 | 
             
                def create_graphql_object_pages
         | 
| 55 83 | 
             
                  graphql_object_types.each do |object_type|
         | 
| 56 84 | 
             
                    next if object_type['name'].start_with?('__')
         | 
| 57 | 
            -
                     | 
| 58 | 
            -
             | 
| 59 | 
            -
                     | 
| 85 | 
            +
                    if object_type['name'] == 'Mutation'
         | 
| 86 | 
            +
                      next unless @options[:landing_pages][:mutation].nil?
         | 
| 87 | 
            +
                    end
         | 
| 88 | 
            +
                    if object_type['name'] == 'Query'
         | 
| 89 | 
            +
                      metadata = ''
         | 
| 90 | 
            +
                      unless @options[:landing_pages][:query].nil?
         | 
| 91 | 
            +
                        query_landing_page = @options[:landing_pages][:query]
         | 
| 92 | 
            +
                        query_landing_page = File.read(query_landing_page)
         | 
| 93 | 
            +
                        if @renderer.respond_to?(:has_yaml?) && \
         | 
| 94 | 
            +
                           @renderer.has_yaml?(query_landing_page) && \
         | 
| 95 | 
            +
                           @renderer.respond_to?(:yaml_split)
         | 
| 96 | 
            +
                          pieces = @renderer.yaml_split(query_landing_page)
         | 
| 97 | 
            +
                          pieces[2] = pieces[2].chomp
         | 
| 98 | 
            +
                          metadata = pieces[1, 3].join("\n")
         | 
| 99 | 
            +
                          query_landing_page = pieces[4]
         | 
| 100 | 
            +
                        end
         | 
| 101 | 
            +
                        object_type['description'] = query_landing_page
         | 
| 102 | 
            +
                      end
         | 
| 103 | 
            +
                      opts = default_generator_options(type: object_type)
         | 
| 104 | 
            +
                      contents = @graphql_object_template.result(OpenStruct.new(opts).instance_eval { binding })
         | 
| 105 | 
            +
                      write_file('static', 'query', metadata + contents)
         | 
| 106 | 
            +
                    else
         | 
| 107 | 
            +
                      opts = default_generator_options(type: object_type)
         | 
| 108 | 
            +
                      contents = @graphql_object_template.result(OpenStruct.new(opts).instance_eval { binding })
         | 
| 109 | 
            +
                      write_file('object', object_type['name'], contents)
         | 
| 110 | 
            +
                    end
         | 
| 60 111 | 
             
                  end
         | 
| 61 112 | 
             
                end
         | 
| 62 113 |  | 
| @@ -131,6 +182,7 @@ module GraphQLDocs | |
| 131 182 | 
             
                      path = @options[:output_dir]
         | 
| 132 183 | 
             
                    else
         | 
| 133 184 | 
             
                      path = File.join(@options[:output_dir], name)
         | 
| 185 | 
            +
                      FileUtils.mkdir_p(path)
         | 
| 134 186 | 
             
                    end
         | 
| 135 187 | 
             
                  else
         | 
| 136 188 | 
             
                    path = File.join(@options[:output_dir], type, name.downcase)
         | 
| @@ -0,0 +1,9 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            title: Enums
         | 
| 3 | 
            +
            ---
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            # Enums
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Enums represent a possible set of values for a field. For example, the `Issue` object has a field called `state`. The state of an issue may be `OPEN` or `CLOSED`.
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            For more information, see [the GraphQL spec](https://facebook.github.io/graphql/#sec-Enums).
         | 
| @@ -0,0 +1,9 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            title: Input Objects
         | 
| 3 | 
            +
            ---
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            # Input Objects
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Input objects are best described as "composable objects" in that they contain a set of input fields that define a particular object. For example, the `AuthorInput` takes a field called `emails`. Providing a value for `emails` will transform the `AuthorInput` into a list of `User` objects which contain that email address/
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            For more information, see [the GraphQL spec](https://facebook.github.io/graphql/#sec-Input-Objects).
         | 
| @@ -0,0 +1,9 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            title: Interfaces
         | 
| 3 | 
            +
            ---
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            # Interfaces
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            GraphQL Interfaces are a sort of "parent object" from which other objects can "inherit" from. For example, `Stars` is considered an interface, because both `Repository` and `Gist` can be starred. An interface has its own list of named fields that are shared by implementing objects.
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            For more information, see [the GraphQL spec](https://facebook.github.io/graphql/#sec-Interfaces).
         | 
| @@ -0,0 +1,11 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            title: Mutations
         | 
| 3 | 
            +
            ---
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            # Mutations
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            Every GraphQL schema has a root type for both queries and mutations.
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            The mutation type defines how GraphQL operations change data. It is analogous to performing HTTP verbs such as `POST`, `PATCH`, and `DELETE`.
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            For more information, see [the GraphQL spec](https://facebook.github.io/graphql/#sec-Type-System).
         | 
| @@ -0,0 +1,8 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            title: Objects
         | 
| 3 | 
            +
            ---
         | 
| 4 | 
            +
            # Objects
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Objects in GraphQL represent the resources that you can access. Objects can contain a list of fields, which are specifically typed. For example, the `Repository` object has a field called `name`, which is a `String`.
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            For more information, see [the GraphQL spec](https://facebook.github.io/graphql/#sec-Objects).
         | 
| @@ -0,0 +1,9 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            title: Unions
         | 
| 3 | 
            +
            ---
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            # Unions
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            A union is a type of object that can represent one of many kinds of objects. For example, a field marked as a `ReactableUnion` could be a `CommitComment`, an `Issue`, an `IssueComment`, or a `PullRequestReviewComment`, because each of those objects can be reacted on.
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            For more information, see [the GraphQL spec](https://facebook.github.io/graphql/#sec-Unions).
         | 
| @@ -4,7 +4,7 @@ | |
| 4 4 | 
             
                <meta charset="utf-8">
         | 
| 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 | 
            -
                <title><%= name %></title>
         | 
| 7 | 
            +
                <title><%= title || name %></title>
         | 
| 8 8 | 
             
                <link rel="stylesheet" href="<%= base_url %>/assets/style.css">
         | 
| 9 9 | 
             
                <script src="https://cdnjs.cloudflare.com/ajax/libs/anchor-js/3.2.2/anchor.min.js"></script>
         | 
| 10 10 | 
             
                <script>
         | 
| @@ -1,10 +1,10 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            # <%= type['name'] %>
         | 
| 2 2 |  | 
| 3 3 | 
             
            <%= type['description'] %>
         | 
| 4 4 |  | 
| 5 5 | 
             
            <% unless type['interfaces'].empty? %>
         | 
| 6 6 |  | 
| 7 | 
            -
             | 
| 7 | 
            +
            ## Implements
         | 
| 8 8 |  | 
| 9 9 | 
             
            <ul>
         | 
| 10 10 | 
             
              <% type['interfaces'].each do |interface| %>
         | 
| @@ -16,7 +16,7 @@ | |
| 16 16 |  | 
| 17 17 | 
             
            <% unless type['connections'].empty? %>
         | 
| 18 18 |  | 
| 19 | 
            -
             | 
| 19 | 
            +
            ## Connections
         | 
| 20 20 |  | 
| 21 21 | 
             
            <%= include.('connections.html', connections: type['connections']) %>
         | 
| 22 22 |  | 
| @@ -24,7 +24,7 @@ | |
| 24 24 |  | 
| 25 25 | 
             
            <% unless type['fields'].empty? %>
         | 
| 26 26 |  | 
| 27 | 
            -
             | 
| 27 | 
            +
            ## Fields
         | 
| 28 28 |  | 
| 29 29 | 
             
            <%= include.('fields.html', fields: type['fields']) %>
         | 
| 30 30 |  | 
| @@ -10,12 +10,12 @@ | |
| 10 10 | 
             
                <p>Queries</p>
         | 
| 11 11 | 
             
                <ul class="menu-root">
         | 
| 12 12 | 
             
                  <li>
         | 
| 13 | 
            -
                    <a href="<%= base_url %>/ | 
| 14 | 
            -
                       | 
| 13 | 
            +
                    <a href="<%= base_url %>/query/" class="sidebar-link<% if title == "Query" %> current<% end %>">
         | 
| 14 | 
            +
                      Query
         | 
| 15 15 | 
             
                    </a>
         | 
| 16 16 | 
             
                  </li>
         | 
| 17 17 | 
             
                  <li>
         | 
| 18 | 
            -
                    <a href="<%= base_url %>/ | 
| 18 | 
            +
                    <a href="<%= base_url %>/mutation" class="sidebar-link<% if title == "Mutation" %> current<% end %>">
         | 
| 19 19 | 
             
                      Mutation
         | 
| 20 20 | 
             
                    </a>
         | 
| 21 21 | 
             
                  </li>
         | 
| @@ -23,7 +23,7 @@ | |
| 23 23 | 
             
              </li>
         | 
| 24 24 |  | 
| 25 25 | 
             
              <li>
         | 
| 26 | 
            -
                <p>Objects</p>
         | 
| 26 | 
            +
                <p><a href="<%= base_url %>/object">Objects</a></p>
         | 
| 27 27 | 
             
                <ul class="menu-root">
         | 
| 28 28 | 
             
                  <% graphql_object_types.().each do |type| %>
         | 
| 29 29 | 
             
                    <% @name = type["name"] %>
         | 
| @@ -32,13 +32,18 @@ | |
| 32 32 | 
             
                      <% next %>
         | 
| 33 33 | 
             
                    <% end %>
         | 
| 34 34 |  | 
| 35 | 
            +
                    <!-- skip mutation stuff -->
         | 
| 36 | 
            +
                    <% if @name == "Mutation" || @name.end_with?("Payload") %>
         | 
| 37 | 
            +
                      <% next %>
         | 
| 38 | 
            +
                    <% end %>
         | 
| 39 | 
            +
             | 
| 35 40 | 
             
                    <!-- skip metadata stuff -->
         | 
| 36 41 | 
             
                    <% if @name.start_with?("__") %>
         | 
| 37 42 | 
             
                      <% next %>
         | 
| 38 43 | 
             
                    <% end %>
         | 
| 39 44 |  | 
| 40 45 | 
             
                    <!-- skip root query stuff -->
         | 
| 41 | 
            -
                    <% if @name == " | 
| 46 | 
            +
                    <% if @name == "Query" %>
         | 
| 42 47 | 
             
                      <% next %>
         | 
| 43 48 | 
             
                    <% end %>
         | 
| 44 49 |  | 
| @@ -52,7 +57,25 @@ | |
| 52 57 | 
             
              </li>
         | 
| 53 58 |  | 
| 54 59 | 
             
              <li>
         | 
| 55 | 
            -
                <p> | 
| 60 | 
            +
                <p><a href="<%= base_url %>/mutation">Mutations</a></p>
         | 
| 61 | 
            +
                <ul class="menu-root">
         | 
| 62 | 
            +
                  <% graphql_mutation_types.().each do |type| %>
         | 
| 63 | 
            +
                  <% @name = type["name"] %>
         | 
| 64 | 
            +
                  <!-- skip metadata stuff -->
         | 
| 65 | 
            +
                  <% if @name.start_with?("__") %>
         | 
| 66 | 
            +
                    <% next %>
         | 
| 67 | 
            +
                  <% end %>
         | 
| 68 | 
            +
                  <li>
         | 
| 69 | 
            +
                    <a href="<%= base_url %>/mutation/<%= @name.downcase %>/" class="sidebar-link<% if title == @name %> current<% end %>">
         | 
| 70 | 
            +
                      <%= @name %>
         | 
| 71 | 
            +
                    </a>
         | 
| 72 | 
            +
                  </li>
         | 
| 73 | 
            +
                  <% end %>
         | 
| 74 | 
            +
                </ul>
         | 
| 75 | 
            +
              </li>
         | 
| 76 | 
            +
             | 
| 77 | 
            +
              <li>
         | 
| 78 | 
            +
                <p><a href="<%= base_url %>/interface">Interfaces</a></p>
         | 
| 56 79 | 
             
                <ul class="menu-root">
         | 
| 57 80 | 
             
                  <% graphql_interface_types.().each do |type| %>
         | 
| 58 81 | 
             
                    <% @name = type["name"] %>
         | 
| @@ -66,7 +89,7 @@ | |
| 66 89 | 
             
              </li>
         | 
| 67 90 |  | 
| 68 91 | 
             
              <li>
         | 
| 69 | 
            -
                <p>Enums</p>
         | 
| 92 | 
            +
                <p><a href="<%= base_url %>/enum">Enums</a></p>
         | 
| 70 93 | 
             
                <ul class="menu-root">
         | 
| 71 94 | 
             
                  <% graphql_enum_types.().each do |type| %>
         | 
| 72 95 | 
             
                  <% @name = type["name"] %>
         | 
| @@ -84,7 +107,7 @@ | |
| 84 107 | 
             
              </li>
         | 
| 85 108 |  | 
| 86 109 | 
             
              <li>
         | 
| 87 | 
            -
                <p>Unions</p>
         | 
| 110 | 
            +
                <p><a href="<%= base_url %>/union">Unions</a></p>
         | 
| 88 111 | 
             
                <ul class="menu-root">
         | 
| 89 112 | 
             
                  <% graphql_union_types.().each do |type| %>
         | 
| 90 113 | 
             
                  <% @name = type["name"] %>
         | 
| @@ -98,7 +121,7 @@ | |
| 98 121 | 
             
              </li>
         | 
| 99 122 |  | 
| 100 123 | 
             
              <li>
         | 
| 101 | 
            -
                <p>Input Objects</p>
         | 
| 124 | 
            +
                <p><a href="<%= base_url %>/input_object">Input Objects</a></p>
         | 
| 102 125 | 
             
                <ul class="menu-root">
         | 
| 103 126 | 
             
                  <% graphql_input_object_types.().each do |type| %>
         | 
| 104 127 | 
             
                  <% @name = type["name"] %>
         | 
| @@ -112,7 +135,7 @@ | |
| 112 135 | 
             
              </li>
         | 
| 113 136 |  | 
| 114 137 | 
             
              <li>
         | 
| 115 | 
            -
                <p>Scalars</p>
         | 
| 138 | 
            +
                <p><a href="<%= base_url %>/scalar">Scalars</a></p>
         | 
| 116 139 | 
             
                <ul class="menu-root">
         | 
| 117 140 | 
             
                  <% graphql_scalar_types.().each do |type| %>
         | 
| 118 141 | 
             
                  <% @name = type["name"] %>
         | 
| @@ -1,4 +1,5 @@ | |
| 1 1 | 
             
            require 'html/pipeline'
         | 
| 2 | 
            +
            require 'yaml'
         | 
| 2 3 | 
             
            require 'extended-markdown-filter'
         | 
| 3 4 |  | 
| 4 5 | 
             
            module GraphQLDocs
         | 
| @@ -34,12 +35,40 @@ module GraphQLDocs | |
| 34 35 | 
             
                end
         | 
| 35 36 |  | 
| 36 37 | 
             
                def render(type, name, contents)
         | 
| 38 | 
            +
                  opts = { base_url: @options[:base_url] }.merge({ type: type, name: name}).merge(helper_methods)
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  if has_yaml?(contents)
         | 
| 41 | 
            +
                    # Split data
         | 
| 42 | 
            +
                    pieces = yaml_split(contents)
         | 
| 43 | 
            +
                    if pieces.size < 4
         | 
| 44 | 
            +
                      raise RuntimeError.new(
         | 
| 45 | 
            +
                        "The file '#{content_filename}' appears to start with a metadata section (three or five dashes at the top) but it does not seem to be in the correct format.",
         | 
| 46 | 
            +
                      )
         | 
| 47 | 
            +
                    end
         | 
| 48 | 
            +
                    # Parse
         | 
| 49 | 
            +
                    begin
         | 
| 50 | 
            +
                      meta = YAML.load(pieces[2]) || {}
         | 
| 51 | 
            +
                      opts = opts.merge(meta)
         | 
| 52 | 
            +
                    rescue Exception => e # rubocop:disable Lint/RescueException
         | 
| 53 | 
            +
                      raise "Could not parse YAML for #{name}: #{e.message}"
         | 
| 54 | 
            +
                    end
         | 
| 55 | 
            +
                    contents = pieces[4]
         | 
| 56 | 
            +
                  end
         | 
| 57 | 
            +
             | 
| 37 58 | 
             
                  contents = @pipeline.to_html(contents)
         | 
| 38 59 | 
             
                  return contents if @graphql_default_layout.nil?
         | 
| 39 | 
            -
                  opts | 
| 60 | 
            +
                  opts[:content] = contents
         | 
| 40 61 | 
             
                  @graphql_default_layout.result(OpenStruct.new(opts).instance_eval { binding })
         | 
| 41 62 | 
             
                end
         | 
| 42 63 |  | 
| 64 | 
            +
                def has_yaml?(contents)
         | 
| 65 | 
            +
                  contents =~ /\A-{3,5}\s*$/
         | 
| 66 | 
            +
                end
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                def yaml_split(contents)
         | 
| 69 | 
            +
                  contents.split(/^(-{5}|-{3})[ \t]*\r?\n?/, 3)
         | 
| 70 | 
            +
                end
         | 
| 71 | 
            +
             | 
| 43 72 | 
             
                private
         | 
| 44 73 |  | 
| 45 74 | 
             
                def filter_key(s)
         | 
    
        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: 0. | 
| 4 | 
            +
              version: 0.5.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-05- | 
| 11 | 
            +
            date: 2017-05-22 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: faraday
         | 
| @@ -254,6 +254,15 @@ files: | |
| 254 254 | 
             
            - lib/graphql-docs/configuration.rb
         | 
| 255 255 | 
             
            - lib/graphql-docs/generator.rb
         | 
| 256 256 | 
             
            - lib/graphql-docs/helpers.rb
         | 
| 257 | 
            +
            - lib/graphql-docs/landing_pages/enum.md
         | 
| 258 | 
            +
            - lib/graphql-docs/landing_pages/index.md
         | 
| 259 | 
            +
            - lib/graphql-docs/landing_pages/input_object.md
         | 
| 260 | 
            +
            - lib/graphql-docs/landing_pages/interface.md
         | 
| 261 | 
            +
            - lib/graphql-docs/landing_pages/mutation.md
         | 
| 262 | 
            +
            - lib/graphql-docs/landing_pages/object.md
         | 
| 263 | 
            +
            - lib/graphql-docs/landing_pages/query.md
         | 
| 264 | 
            +
            - lib/graphql-docs/landing_pages/scalar.md
         | 
| 265 | 
            +
            - lib/graphql-docs/landing_pages/union.md
         | 
| 257 266 | 
             
            - lib/graphql-docs/layouts/assets/_sass/_api-box.scss
         | 
| 258 267 | 
             
            - lib/graphql-docs/layouts/assets/_sass/_content.scss
         | 
| 259 268 | 
             
            - lib/graphql-docs/layouts/assets/_sass/_fonts.scss
         | 
| @@ -302,7 +311,6 @@ files: | |
| 302 311 | 
             
            - lib/graphql-docs/layouts/includes/possible_types.html
         | 
| 303 312 | 
             
            - lib/graphql-docs/layouts/includes/sidebar.html
         | 
| 304 313 | 
             
            - lib/graphql-docs/layouts/includes/values.html
         | 
| 305 | 
            -
            - lib/graphql-docs/layouts/index.md
         | 
| 306 314 | 
             
            - lib/graphql-docs/parser.rb
         | 
| 307 315 | 
             
            - lib/graphql-docs/renderer.rb
         | 
| 308 316 | 
             
            - lib/graphql-docs/version.rb
         |