|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | | -require 'bundler/gem_tasks' |
4 | | -require 'rake/testtask' |
| 3 | +require "bundler/gem_tasks" |
| 4 | +require "rake/testtask" |
5 | 5 |
|
6 | | -require 'rubocop/rake_task' |
7 | | - |
8 | | -RuboCop::RakeTask.new(:rubocop) |
| 6 | +require "standard/rake" |
9 | 7 |
|
10 | 8 | Rake::TestTask.new(:test) do |t| |
11 | | - t.libs << 'test' |
12 | | - t.libs << 'lib' |
| 9 | + t.libs << "test" |
| 10 | + t.libs << "lib" |
13 | 11 | t.warning = false |
14 | | - t.test_files = FileList['test/**/*_test.rb'] |
| 12 | + t.test_files = FileList["test/**/*_test.rb"] |
15 | 13 | end |
16 | 14 |
|
17 | | -task default: :test |
| 15 | +task default: [:standard, :test] |
18 | 16 |
|
19 | | -desc 'Invoke HTML-Proofer' |
| 17 | +desc "Invoke HTML-Proofer" |
20 | 18 | task :html_proofer do |
21 | 19 | Rake::Task[:generate_sample] |
22 | | - require 'html-proofer' |
23 | | - output_dir = File.join(File.dirname(__FILE__), 'output') |
| 20 | + require "html-proofer" |
| 21 | + output_dir = File.join(File.dirname(__FILE__), "output") |
24 | 22 |
|
25 | | - proofer_options = { disable_external: true, assume_extension: true } |
| 23 | + proofer_options = {disable_external: true, assume_extension: true} |
26 | 24 | HTMLProofer.check_directory(output_dir, proofer_options).run |
27 | 25 | end |
28 | 26 |
|
29 | | -desc 'Set up a console' |
| 27 | +desc "Set up a console" |
30 | 28 | task :console do |
31 | | - require 'graphql-docs' |
| 29 | + require "graphql-docs" |
32 | 30 |
|
33 | 31 | def reload! |
34 | 32 | files = $LOADED_FEATURES.select { |feat| feat =~ %r{/graphql-docs/} } |
35 | 33 | files.each { |file| load file } |
36 | 34 | end |
37 | 35 |
|
38 | | - require 'irb' |
| 36 | + require "irb" |
39 | 37 | ARGV.clear |
40 | 38 | IRB.start |
41 | 39 | end |
42 | 40 |
|
43 | 41 | namespace :yard do |
44 | | - desc 'Generate YARD documentation' |
| 42 | + desc "Generate YARD documentation" |
45 | 43 | task :doc do |
46 | | - sh 'bundle exec yard doc' |
| 44 | + sh "bundle exec yard doc" |
47 | 45 | end |
48 | 46 |
|
49 | | - desc 'Run YARD documentation server' |
| 47 | + desc "Run YARD documentation server" |
50 | 48 | task :server do |
51 | 49 | puts "Starting YARD server at http://localhost:8808" |
52 | 50 | puts "Press Ctrl+C to stop" |
53 | | - sh 'bundle exec yard server --reload --bind 0.0.0.0 --port 8808' |
| 51 | + sh "bundle exec yard server --reload --bind 0.0.0.0 --port 8808" |
54 | 52 | end |
55 | 53 | end |
56 | 54 |
|
57 | 55 | # Alias for convenience |
58 | | -desc 'Generate YARD documentation' |
59 | | -task yard: 'yard:doc' |
| 56 | +desc "Generate YARD documentation" |
| 57 | +task yard: "yard:doc" |
60 | 58 |
|
61 | 59 | namespace :sample do |
62 | | - desc 'Generate the sample documentation' |
| 60 | + desc "Generate the sample documentation" |
63 | 61 | task :generate do |
64 | | - require 'graphql-docs' |
| 62 | + require "graphql-docs" |
65 | 63 |
|
66 | 64 | options = {} |
67 | 65 | options[:delete_output] = true |
68 | | - options[:base_url] = ENV.fetch('GQL_DOCS_BASE_URL', '') |
69 | | - options[:filename] = File.join(File.dirname(__FILE__), 'test', 'graphql-docs', 'fixtures', 'gh-schema.graphql') |
| 66 | + options[:base_url] = ENV.fetch("GQL_DOCS_BASE_URL", "") |
| 67 | + options[:filename] = File.join(File.dirname(__FILE__), "test", "graphql-docs", "fixtures", "gh-schema.graphql") |
70 | 68 |
|
71 | 69 | puts "Generating sample docs" |
72 | 70 | GraphQLDocs.build(options) |
73 | 71 | end |
74 | 72 |
|
75 | | - desc 'Generate the documentation and run a web server' |
| 73 | + desc "Generate the documentation and run a web server" |
76 | 74 | task serve: [:generate] do |
77 | | - require 'webrick' |
78 | | - PORT = "5050" |
79 | | - puts "Navigate to http://localhost:#{PORT} to view the sample docs" |
80 | | - server = WEBrick::HTTPServer.new Port: PORT |
81 | | - server.mount '/', WEBrick::HTTPServlet::FileHandler, 'output' |
82 | | - trap('INT') { server.stop } |
| 75 | + require "webrick" |
| 76 | + port = "5050" |
| 77 | + puts "Navigate to http://localhost:#{port} to view the sample docs" |
| 78 | + server = WEBrick::HTTPServer.new Port: port |
| 79 | + server.mount "/", WEBrick::HTTPServlet::FileHandler, "output" |
| 80 | + trap("INT") { server.stop } |
83 | 81 | server.start |
84 | 82 | end |
85 | 83 | task server: :serve |
86 | 84 |
|
87 | | - desc 'Run the sample docs as a Rack application (dynamic, on-demand generation)' |
| 85 | + desc "Run the sample docs as a Rack application (dynamic, on-demand generation)" |
88 | 86 | task :rack do |
89 | | - require 'rack' |
90 | | - require 'graphql-docs' |
| 87 | + require "rack" |
| 88 | + require "graphql-docs" |
91 | 89 |
|
92 | | - schema_path = File.join(File.dirname(__FILE__), 'test', 'graphql-docs', 'fixtures', 'gh-schema.graphql') |
| 90 | + schema_path = File.join(File.dirname(__FILE__), "test", "graphql-docs", "fixtures", "gh-schema.graphql") |
93 | 91 | schema = File.read(schema_path) |
94 | 92 |
|
95 | | - app = GraphQLDocs::App.new( |
| 93 | + GraphQLDocs::App.new( |
96 | 94 | schema: schema, |
97 | 95 | options: { |
98 | | - base_url: '', |
| 96 | + base_url: "", |
99 | 97 | use_default_styles: true, |
100 | 98 | cache: true |
101 | 99 | } |
102 | 100 | ) |
103 | 101 |
|
104 | | - PORT = ENV.fetch('PORT', '9292') |
| 102 | + port = ENV.fetch("PORT", "9292") |
105 | 103 | puts "Starting Rack server in dynamic mode (on-demand generation)" |
106 | | - puts "Navigate to http://localhost:#{PORT} to view the sample docs" |
| 104 | + puts "Navigate to http://localhost:#{port} to view the sample docs" |
107 | 105 | puts "Press Ctrl+C to stop" |
108 | 106 | puts "" |
109 | 107 | puts "NOTE: This serves documentation dynamically - pages are generated on request" |
110 | 108 | puts " Compare with 'rake sample:serve' which serves pre-generated static files" |
111 | 109 | puts "" |
112 | 110 |
|
113 | 111 | # Use rackup for Rack 3.x compatibility |
114 | | - sh "rackup config.ru -p #{PORT}" |
| 112 | + sh "rackup config.ru -p #{port}" |
115 | 113 | end |
116 | 114 | end |
0 commit comments