diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /lib/gitlab/graphql/docs/renderer.rb | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'lib/gitlab/graphql/docs/renderer.rb')
-rw-r--r-- | lib/gitlab/graphql/docs/renderer.rb | 54 |
1 files changed, 0 insertions, 54 deletions
diff --git a/lib/gitlab/graphql/docs/renderer.rb b/lib/gitlab/graphql/docs/renderer.rb deleted file mode 100644 index ae0898e6198..00000000000 --- a/lib/gitlab/graphql/docs/renderer.rb +++ /dev/null @@ -1,54 +0,0 @@ -# frozen_string_literal: true - -return if Rails.env.production? - -module Gitlab - module Graphql - module Docs - # Gitlab renderer for graphql-docs. - # Uses HAML templates to parse markdown and generate .md files. - # It uses graphql-docs helpers and schema parser, more information in https://github.com/gjtorikian/graphql-docs. - # - # Arguments: - # schema - the GraphQL schema definition. For GitLab should be: GitlabSchema - # 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 - - attr_reader :schema - - def initialize(schema, output_dir:, template:) - @output_dir = output_dir - @template = template - @layout = Haml::Engine.new(File.read(template)) - @parsed_schema = GraphQLDocs::Parser.new(schema.graphql_definition, {}).parse - @schema = schema - @seen = Set.new - end - - def contents - # Render and remove an extra trailing new line - @contents ||= @layout.render(self).sub!(/\n(?=\Z)/, '') - end - - def write - filename = File.join(@output_dir, 'index.md') - - FileUtils.mkdir_p(@output_dir) - File.write(filename, contents) - end - - private - - def seen_type?(name) - @seen.include?(name) - end - - def seen_type!(name) - @seen << name - end - end - end - end -end |