Commit bcdf9090 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'move-graphql-docs-tooling' into 'master'

Move GraphQL docs renderer to tooling

See merge request gitlab-org/gitlab!63848
parents 941e229e ea6d5a9c
......@@ -3,11 +3,12 @@
return if Rails.env.production?
require 'graphql/rake_task'
require_relative '../../../tooling/graphql/docs/renderer'
namespace :gitlab do
OUTPUT_DIR = Rails.root.join("doc/api/graphql/reference")
TEMP_SCHEMA_DIR = Rails.root.join('tmp/tests/graphql')
TEMPLATES_DIR = 'lib/gitlab/graphql/docs/templates/'
TEMPLATES_DIR = 'tooling/graphql/docs/templates/'
# Make all feature flags enabled so that all feature flag
# controlled fields are considered visible and are output.
......@@ -110,7 +111,7 @@ namespace :gitlab do
desc 'GitLab | GraphQL | Generate GraphQL docs'
task compile_docs: [:environment, :enable_feature_flags] do
renderer = Gitlab::Graphql::Docs::Renderer.new(GitlabSchema, render_options)
renderer = Tooling::Graphql::Docs::Renderer.new(GitlabSchema, render_options)
renderer.write
......@@ -119,7 +120,7 @@ namespace :gitlab do
desc 'GitLab | GraphQL | Check if GraphQL docs are up to date'
task check_docs: [:environment, :enable_feature_flags] do
renderer = Gitlab::Graphql::Docs::Renderer.new(GitlabSchema, render_options)
renderer = Tooling::Graphql::Docs::Renderer.new(GitlabSchema, render_options)
doc = File.read(Rails.root.join(OUTPUT_DIR, 'index.md'))
......
# frozen_string_literal: true
require 'spec_helper'
require_relative '../../../../tooling/graphql/docs/renderer'
RSpec.describe Gitlab::Graphql::Docs::Renderer do
RSpec.describe Tooling::Graphql::Docs::Renderer do
describe '#contents' do
shared_examples 'renders correctly as GraphQL documentation' do
it 'contains the expected section' do
......@@ -12,7 +12,7 @@ RSpec.describe Gitlab::Graphql::Docs::Renderer do
end
end
let(:template) { Rails.root.join('lib/gitlab/graphql/docs/templates/default.md.haml') }
let(:template) { Rails.root.join('tooling/graphql/docs/templates/default.md.haml') }
let(:field_description) { 'List of objects.' }
let(:type) { ::GraphQL::INT_TYPE }
......
# frozen_string_literal: true
return if Rails.env.production?
require 'gitlab/utils/strong_memoize'
module Gitlab
module Tooling
module Graphql
module Docs
# We assume a few things about the schema. We use the graphql-ruby gem, which enforces:
......
# frozen_string_literal: true
return if Rails.env.production?
require_relative 'helper'
module Gitlab
module Tooling
module Graphql
module Docs
# Gitlab renderer for graphql-docs.
......@@ -14,7 +14,7 @@ module Gitlab
# output_dir: The folder where the markdown files will be saved
# template: The path of the haml template to be parsed
class Renderer
include Gitlab::Graphql::Docs::Helper
include Tooling::Graphql::Docs::Helper
attr_reader :schema
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment