graphql-docs 5.2.0 → 6.0.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/.yardopts +9 -0
- data/CHANGELOG.md +76 -0
- data/README.md +404 -8
- data/bin/console +6 -7
- data/bin/setup +8 -5
- data/exe/graphql-docs +9 -9
- data/graphql-docs.gemspec +50 -38
- data/lib/graphql-docs/app.rb +488 -0
- data/lib/graphql-docs/configuration.rb +28 -11
- data/lib/graphql-docs/generator.rb +147 -42
- data/lib/graphql-docs/helpers.rb +132 -12
- data/lib/graphql-docs/layouts/assets/_sass/_api-box.scss +2 -2
- data/lib/graphql-docs/layouts/assets/_sass/_content.scss +20 -19
- data/lib/graphql-docs/layouts/assets/_sass/_deprecations.scss +7 -0
- data/lib/graphql-docs/layouts/assets/_sass/_fonts.scss +6 -21
- data/lib/graphql-docs/layouts/assets/_sass/_header.scss +8 -2
- data/lib/graphql-docs/layouts/assets/_sass/_mobile.scss +10 -3
- data/lib/graphql-docs/layouts/assets/_sass/_search.scss +32 -10
- data/lib/graphql-docs/layouts/assets/_sass/_sidebar.scss +22 -15
- data/lib/graphql-docs/layouts/assets/_sass/_syntax.scss +1 -1
- data/lib/graphql-docs/layouts/assets/css/screen.scss +54 -5
- data/lib/graphql-docs/layouts/default.html +75 -1
- data/lib/graphql-docs/layouts/includes/sidebar.html +4 -2
- data/lib/graphql-docs/parser.rb +89 -33
- data/lib/graphql-docs/renderer.rb +98 -31
- data/lib/graphql-docs/version.rb +2 -1
- data/lib/graphql-docs.rb +78 -12
- data/lib/tasks/graphql-docs.rake +57 -0
- metadata +74 -78
- data/.github/ISSUE_TEMPLATE/bug_report.md +0 -31
- data/.github/ISSUE_TEMPLATE/feature_request.md +0 -20
- data/.github/workflows/tests.yml +0 -21
- data/.gitignore +0 -15
- data/.rubocop.yml +0 -11
- data/CODE_OF_CONDUCT.md +0 -84
- data/CONTRIBUTING.md +0 -18
- data/Gemfile +0 -6
- data/Rakefile +0 -86
- data/lib/graphql-docs/layouts/assets/images/graphiql-headers.png +0 -0
- data/lib/graphql-docs/layouts/assets/images/graphiql-variables.png +0 -0
- data/lib/graphql-docs/layouts/assets/images/graphiql.png +0 -0
- data/lib/graphql-docs/layouts/assets/images/search.svg +0 -3
- data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_B_0.eot +0 -0
- data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_B_0.ttf +0 -0
- data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_B_0.woff +0 -0
- data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_B_0.woff2 +0 -0
- data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_C_0.eot +0 -0
- data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_C_0.ttf +0 -0
- data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_C_0.woff +0 -0
- data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_C_0.woff2 +0 -0
- data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_D_0.eot +0 -0
- data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_D_0.ttf +0 -0
- data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_D_0.woff +0 -0
- data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_D_0.woff2 +0 -0
- data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_E_0.eot +0 -0
- data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_E_0.ttf +0 -0
- data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_E_0.woff +0 -0
- data/lib/graphql-docs/layouts/assets/webfonts/2C4B9D_E_0.woff2 +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: '05484c53122d5965c4c25b622e097b8e6433ba851f714e33a0b6e7d2f81c5ba5'
|
|
4
|
+
data.tar.gz: 36217b7cadfecab247ea8b52eaf15913acb5a529c6e4d7f5934ef4a69a8e147e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 33d4632d6a2299c4ebff4c9865adabb28e53420013b843fc5cb6f237cfd883bd0fb959ab5406211412be417b76784b2464aaea530d51653c7bd5b1bd6f63ae33
|
|
7
|
+
data.tar.gz: 59b12439adae5c3269affccfceababd7b870e1d3a97abf08815f3a7080c84ca7170b8f4d9d1013373d3784f171267ec833a785a7781047261c78bc453456fff1
|
data/.yardopts
ADDED
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,82 @@ A concise overview of the public-facing changes to the gem from version to versi
|
|
|
4
4
|
|
|
5
5
|
## Unreleased
|
|
6
6
|
|
|
7
|
+
## v6.0.0 - 2026-01-22
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
- Add Rake task `graphql-docs:generate` for integration with Rails and other Ruby projects that use Rake. Supports both task arguments and environment variables for configuration. Can be used with `Rake::Task["assets:precompile"].enhance(["graphql-docs:generate"])` to generate docs as part of the build process.
|
|
12
|
+
- Add support for running as a Rack app for easy integration with existing web applications
|
|
13
|
+
- Add resizable sidebar for better UX
|
|
14
|
+
- Add Dark Mode styles support
|
|
15
|
+
- Render deprecation info for queries and mutations
|
|
16
|
+
|
|
17
|
+
### Improvements
|
|
18
|
+
|
|
19
|
+
- Replace jQuery with vanilla JavaScript for smaller bundle size and fewer dependencies
|
|
20
|
+
- Optimize packaged gem size and use system fonts for better performance
|
|
21
|
+
- Run CI against Ruby 4.0
|
|
22
|
+
|
|
23
|
+
### Breaking Changes
|
|
24
|
+
|
|
25
|
+
- **breaking:** Upgrade commonmarker, html-pipeline, and gemoji dependencies, see **BREAKING CHANGES** section below
|
|
26
|
+
|
|
27
|
+
### 🚨 BREAKING CHANGES
|
|
28
|
+
|
|
29
|
+
This release upgrades three major dependencies with significant breaking changes.
|
|
30
|
+
|
|
31
|
+
#### Dependency Upgrades
|
|
32
|
+
|
|
33
|
+
- **commonmarker**: `0.23.x` → `2.0.x` - Complete API rewrite with improved performance and standards compliance
|
|
34
|
+
- **html-pipeline**: `2.14.x` → `3.0.x` - Simplified architecture, filter API changed
|
|
35
|
+
- **gemoji**: `3.0.x` → `4.0.x` - Updated emoji mappings
|
|
36
|
+
- **Removed**: `extended-markdown-filter` (no longer maintained, incompatible with html-pipeline 3)
|
|
37
|
+
|
|
38
|
+
#### Breaking Changes for Advanced Users
|
|
39
|
+
|
|
40
|
+
1. **Custom html-pipeline filters no longer work**
|
|
41
|
+
- html-pipeline 3.x has a completely different filter API
|
|
42
|
+
- If you configured custom filters via `pipeline_config[:pipeline]`, they will not work
|
|
43
|
+
- **Migration**: Rewrite custom filters using html-pipeline 3.x API (see [html-pipeline migration guide](https://github.com/jch/html-pipeline/blob/main/CHANGELOG.md))
|
|
44
|
+
- The gem now handles markdown and emoji rendering directly
|
|
45
|
+
|
|
46
|
+
2. **Custom Renderer API changes**
|
|
47
|
+
- If you implemented a custom renderer that directly uses CommonMarker:
|
|
48
|
+
- **Old API**: `CommonMarker.render_html(string, :UNSAFE)`
|
|
49
|
+
- **New API**: `Commonmarker.parse(string).to_html(options: {render: {unsafe: true}})`
|
|
50
|
+
- Note the lowercase 'm' in `Commonmarker` in version 2.x
|
|
51
|
+
|
|
52
|
+
3. **Table of Contents filter removed from defaults**
|
|
53
|
+
- The default `TableOfContentsFilter` is no longer applied
|
|
54
|
+
- **Migration**: Implement a custom post-processing step if needed
|
|
55
|
+
|
|
56
|
+
#### What Still Works (and is Better!)
|
|
57
|
+
|
|
58
|
+
- ✅ GitHub Flavored Markdown (tables, strikethrough, autolinks, task lists)
|
|
59
|
+
- ✅ **Emoji rendering** - `:emoji:` syntax like `:smile:` works out of the box
|
|
60
|
+
- ✅ Header anchors (automatically generated with IDs)
|
|
61
|
+
- ✅ Safe and unsafe HTML rendering modes
|
|
62
|
+
- ✅ Code blocks with syntax highlighting
|
|
63
|
+
- ✅ All existing templates and layouts
|
|
64
|
+
- ✅ Faster markdown rendering
|
|
65
|
+
- ✅ More standards-compliant HTML output
|
|
66
|
+
|
|
67
|
+
#### Why Upgrade?
|
|
68
|
+
|
|
69
|
+
- **Security**: Updates to latest stable versions with security patches
|
|
70
|
+
- **Performance**: commonmarker 2.x is significantly faster and more standards-compliant
|
|
71
|
+
- **Maintainability**: All dependencies are actively maintained
|
|
72
|
+
- **Modern**: Uses current Ruby ecosystem standards
|
|
73
|
+
|
|
74
|
+
#### Migration Guide
|
|
75
|
+
|
|
76
|
+
For most users with default configuration, this upgrade should be seamless. Advanced users should check:
|
|
77
|
+
|
|
78
|
+
- [ ] Do you use custom `pipeline_config[:pipeline]` filters? → Rewrite for html-pipeline 3.x
|
|
79
|
+
- [ ] Do you have a custom `Renderer` subclass that calls CommonMarker directly? → Update API calls
|
|
80
|
+
- [ ] Run full test suite after upgrade
|
|
81
|
+
- [ ] Regenerate documentation and visually inspect output
|
|
82
|
+
|
|
7
83
|
## v5.2.0 - 2025-02-09
|
|
8
84
|
|
|
9
85
|
- Add search filter to sidebar. Thanks @denisahearn!
|
data/README.md
CHANGED
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Ruby library and CLI for easily generating beautiful documentation from your GraphQL schema.
|
|
4
4
|
|
|
5
|
-

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
Key links:
|
|
8
|
+
|
|
9
|
+
- **Demo**: [https://graphql-docs.bcodes.me](https://graphql-docs.bcodes.me).
|
|
10
|
+
- **Ruby documentation**: [https://rubydoc.info/github/brettchalupa/graphql-docs.git/main](https://rubydoc.info/github/brettchalupa/graphql-docs.git/main).
|
|
6
11
|
|
|
7
12
|
## Installation
|
|
8
13
|
|
|
@@ -20,6 +25,13 @@ gem install graphql-docs
|
|
|
20
25
|
|
|
21
26
|
## Usage
|
|
22
27
|
|
|
28
|
+
GraphQLDocs provides two ways to serve your documentation:
|
|
29
|
+
|
|
30
|
+
1. **Static Site Generator (SSG)** - Pre-generate all HTML files (default)
|
|
31
|
+
2. **Rack Application** - Serve documentation dynamically on-demand
|
|
32
|
+
|
|
33
|
+
### Static Site Generation (SSG)
|
|
34
|
+
|
|
23
35
|
GraphQLDocs can be used as a Ruby library to build the documentation website. Using it as a Ruby library allows for more control and using every supported option. Here's an example:
|
|
24
36
|
|
|
25
37
|
```ruby
|
|
@@ -50,6 +62,184 @@ See all of the supported CLI options with:
|
|
|
50
62
|
graphql-docs -h
|
|
51
63
|
```
|
|
52
64
|
|
|
65
|
+
### Rake Task
|
|
66
|
+
|
|
67
|
+
GraphQLDocs includes a Rake task for integration with Rails applications and other Ruby projects that use Rake. This allows you to generate documentation as part of your build process or hook it into other Rake tasks.
|
|
68
|
+
|
|
69
|
+
#### Basic Usage
|
|
70
|
+
|
|
71
|
+
Using task arguments (recommended):
|
|
72
|
+
|
|
73
|
+
```console
|
|
74
|
+
rake graphql-docs:generate[schema.graphql]
|
|
75
|
+
rake graphql-docs:generate[schema.graphql,./docs]
|
|
76
|
+
rake graphql-docs:generate[schema.graphql,./docs,/api-docs,true]
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Or using environment variables:
|
|
80
|
+
|
|
81
|
+
```console
|
|
82
|
+
GRAPHQL_SCHEMA_FILE=schema.graphql rake graphql-docs:generate
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
#### Available Arguments
|
|
86
|
+
|
|
87
|
+
Arguments are passed in order: `[schema_file, output_dir, base_url, delete_output]`
|
|
88
|
+
|
|
89
|
+
1. `schema_file` - Path to GraphQL schema file (required)
|
|
90
|
+
2. `output_dir` - Output directory (default: `./output/`)
|
|
91
|
+
3. `base_url` - Base URL for assets and links (default: `''`)
|
|
92
|
+
4. `delete_output` - Delete output directory before generating (`true`/`false`, default: `false`)
|
|
93
|
+
|
|
94
|
+
#### Available Environment Variables
|
|
95
|
+
|
|
96
|
+
- `GRAPHQL_SCHEMA_FILE` - Path to GraphQL schema file (required)
|
|
97
|
+
- `GRAPHQL_OUTPUT_DIR` - Output directory (default: `./output/`)
|
|
98
|
+
- `GRAPHQL_BASE_URL` - Base URL for assets and links (default: `''`)
|
|
99
|
+
- `GRAPHQL_DELETE_OUTPUT` - Delete output directory before generating (`true`/`false`)
|
|
100
|
+
|
|
101
|
+
Note: Task arguments take precedence over environment variables.
|
|
102
|
+
|
|
103
|
+
#### Example: Generate Docs Before Asset Compilation
|
|
104
|
+
|
|
105
|
+
In Rails, you can automatically generate documentation before compiling assets:
|
|
106
|
+
|
|
107
|
+
```ruby
|
|
108
|
+
# Rakefile or lib/tasks/docs.rake
|
|
109
|
+
Rake::Task["assets:precompile"].enhance(["graphql-docs:generate"])
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Then configure using environment variables:
|
|
113
|
+
|
|
114
|
+
```ruby
|
|
115
|
+
# config/application.rb or .env
|
|
116
|
+
ENV["GRAPHQL_SCHEMA_FILE"] = Rails.root.join("app/graphql/schema.graphql").to_s
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Or invoke with arguments in your custom task:
|
|
120
|
+
|
|
121
|
+
```ruby
|
|
122
|
+
# lib/tasks/custom_docs.rake
|
|
123
|
+
namespace :docs do
|
|
124
|
+
desc "Generate API documentation"
|
|
125
|
+
task :generate do
|
|
126
|
+
Rake::Task["graphql-docs:generate"].invoke(
|
|
127
|
+
"app/graphql/schema.graphql", # schema_file
|
|
128
|
+
"public/api-docs", # output_dir
|
|
129
|
+
"/api-docs", # base_url
|
|
130
|
+
"true" # delete_output
|
|
131
|
+
)
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# Hook into asset compilation
|
|
136
|
+
Rake::Task["assets:precompile"].enhance(["docs:generate"])
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Rack Application (Dynamic)
|
|
140
|
+
|
|
141
|
+
For more flexibility and control, you can serve documentation dynamically using the Rack application. This is useful for:
|
|
142
|
+
|
|
143
|
+
- Internal tools with frequently changing schemas
|
|
144
|
+
- Integration with existing Rails/Sinatra applications
|
|
145
|
+
- Adding authentication/authorization middleware
|
|
146
|
+
- Dynamic schema loading from databases or APIs
|
|
147
|
+
|
|
148
|
+
**Requirements**: The Rack application feature requires the `rack` gem (version 2.x or 3.x). Add it to your Gemfile:
|
|
149
|
+
|
|
150
|
+
```ruby
|
|
151
|
+
gem 'rack', '~> 3.0' # or '~> 2.0' for Rack 2.x
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
The gem is compatible with both Rack 2.x and 3.x, so you can use whichever version your application requires.
|
|
155
|
+
|
|
156
|
+
#### Standalone Rack App
|
|
157
|
+
|
|
158
|
+
Create a `config.ru` file:
|
|
159
|
+
|
|
160
|
+
```ruby
|
|
161
|
+
require 'graphql-docs'
|
|
162
|
+
|
|
163
|
+
schema = File.read('schema.graphql')
|
|
164
|
+
|
|
165
|
+
app = GraphQLDocs::App.new(
|
|
166
|
+
schema: schema,
|
|
167
|
+
options: {
|
|
168
|
+
base_url: '',
|
|
169
|
+
use_default_styles: true,
|
|
170
|
+
cache: true # Enable page caching
|
|
171
|
+
}
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
run app
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Then run with:
|
|
178
|
+
|
|
179
|
+
```console
|
|
180
|
+
rackup config.ru
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
Visit `http://localhost:9292` to view your docs.
|
|
184
|
+
|
|
185
|
+
#### Mounting in Rails
|
|
186
|
+
|
|
187
|
+
```ruby
|
|
188
|
+
# config/routes.rb
|
|
189
|
+
require 'graphql-docs'
|
|
190
|
+
|
|
191
|
+
Rails.application.routes.draw do
|
|
192
|
+
mount GraphQLDocs::App.new(schema: MyGraphQLSchema) => '/docs'
|
|
193
|
+
end
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
#### Mounting in Sinatra
|
|
197
|
+
|
|
198
|
+
```ruby
|
|
199
|
+
require 'sinatra'
|
|
200
|
+
require 'graphql-docs'
|
|
201
|
+
|
|
202
|
+
schema = File.read('schema.graphql')
|
|
203
|
+
docs_app = GraphQLDocs::App.new(schema: schema)
|
|
204
|
+
|
|
205
|
+
map '/docs' do
|
|
206
|
+
run docs_app
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
map '/' do
|
|
210
|
+
run Sinatra::Application
|
|
211
|
+
end
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
#### Rack App Features
|
|
215
|
+
|
|
216
|
+
- **On-demand generation** - Pages are generated when requested
|
|
217
|
+
- **Built-in caching** - Generated pages are cached in memory (disable with `cache: false`)
|
|
218
|
+
- **Schema reloading** - Update schema without restarting server:
|
|
219
|
+
|
|
220
|
+
```ruby
|
|
221
|
+
app = GraphQLDocs::App.new(schema: schema)
|
|
222
|
+
|
|
223
|
+
# Later, reload with new schema
|
|
224
|
+
new_schema = File.read('updated_schema.graphql')
|
|
225
|
+
app.reload_schema!(new_schema)
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
- **Asset serving** - CSS, fonts, and images served automatically
|
|
229
|
+
- **Error handling** - Friendly error pages for missing types
|
|
230
|
+
|
|
231
|
+
#### SSG vs Rack Comparison
|
|
232
|
+
|
|
233
|
+
| Feature | SSG | Rack App |
|
|
234
|
+
|---------|-----|----------|
|
|
235
|
+
| Setup complexity | Low | Medium |
|
|
236
|
+
| First page load | Instant | Fast (with caching) |
|
|
237
|
+
| Schema updates | Manual rebuild | Automatic/reload |
|
|
238
|
+
| Hosting | Any static host | Requires Ruby server |
|
|
239
|
+
| Memory usage | Minimal | Higher (cached pages) |
|
|
240
|
+
| Authentication | Separate layer | Built-in middleware |
|
|
241
|
+
| Best for | Public docs, open source | Internal tools, dynamic schemas |
|
|
242
|
+
|
|
53
243
|
## Breakdown
|
|
54
244
|
|
|
55
245
|
There are several phases going on the single `GraphQLDocs.build` call:
|
|
@@ -82,7 +272,7 @@ generator.generate
|
|
|
82
272
|
|
|
83
273
|
By default, the HTML generation process uses ERB to layout the content. There are a bunch of default options provided for you, but feel free to override any of these. The _Configuration_ section below has more information on what you can change.
|
|
84
274
|
|
|
85
|
-
It
|
|
275
|
+
It uses [Commonmarker](https://github.com/gjtorikian/commonmarker) (v2.x) to perform the Markdown rendering by default, with GitHub Flavored Markdown extensions enabled including automatic header anchors. Emoji shortcodes (like `:smile:`) are automatically converted to emoji characters using [gemoji](https://github.com/github/gemoji). You can override this by providing a custom rendering class. You must implement two methods:
|
|
86
276
|
|
|
87
277
|
- `initialize` - Takes two arguments, the parsed `schema` and the configuration `options`.
|
|
88
278
|
- `render` Takes the contents of a template page. It also takes two optional kwargs, the GraphQL `type` and its `name`. For example:
|
|
@@ -127,6 +317,81 @@ In your ERB layouts, there are several helper methods you can use. The helper me
|
|
|
127
317
|
|
|
128
318
|
To call these methods within templates, you must use the dot notation, such as `<%= slugify.(text) %>`.
|
|
129
319
|
|
|
320
|
+
## Dark Mode Support
|
|
321
|
+
|
|
322
|
+
GraphQLDocs includes built-in dark mode support that automatically adapts to the user's system preferences using the `prefers-color-scheme` media query. When a user has dark mode enabled on their operating system, the documentation will automatically display with a dark theme.
|
|
323
|
+
|
|
324
|
+
### Customizing Colors
|
|
325
|
+
|
|
326
|
+
The default styles use CSS custom properties (variables) for all colors, making it easy to customize the color scheme to match your brand. You can override these variables by providing a custom stylesheet.
|
|
327
|
+
|
|
328
|
+
The available CSS variables are:
|
|
329
|
+
|
|
330
|
+
**Light Mode (default):**
|
|
331
|
+
```css
|
|
332
|
+
:root {
|
|
333
|
+
--bg-primary: #fff; /* Main background color */
|
|
334
|
+
--bg-secondary: #f8f8f8; /* Secondary background (tables, etc.) */
|
|
335
|
+
--bg-tertiary: #fafafa; /* Tertiary background (API boxes) */
|
|
336
|
+
--bg-code: #eee; /* Inline code background */
|
|
337
|
+
--bg-code-block: #272822; /* Code block background */
|
|
338
|
+
--text-primary: #444; /* Primary text color */
|
|
339
|
+
--text-secondary: #999; /* Secondary text (categories, etc.) */
|
|
340
|
+
--text-link: #de4f4f; /* Link color */
|
|
341
|
+
--text-code: #525252; /* Inline code text color */
|
|
342
|
+
--border-color: #eee; /* Primary border color */
|
|
343
|
+
--border-color-secondary: #ddd; /* Secondary border color */
|
|
344
|
+
--shadow-color: rgba(0, 0, 0, 0.1); /* Shadow/hover effects */
|
|
345
|
+
}
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
**Dark Mode:**
|
|
349
|
+
```css
|
|
350
|
+
@media (prefers-color-scheme: dark) {
|
|
351
|
+
:root {
|
|
352
|
+
--bg-primary: #1a1a1a;
|
|
353
|
+
--bg-secondary: #252525;
|
|
354
|
+
--bg-tertiary: #2a2a2a;
|
|
355
|
+
--bg-code: #333;
|
|
356
|
+
--bg-code-block: #1e1e1e;
|
|
357
|
+
--text-primary: #e0e0e0;
|
|
358
|
+
--text-secondary: #888;
|
|
359
|
+
--text-link: #ff6b6b;
|
|
360
|
+
--text-code: #d4d4d4;
|
|
361
|
+
--border-color: #333;
|
|
362
|
+
--border-color-secondary: #444;
|
|
363
|
+
--shadow-color: rgba(255, 255, 255, 0.1);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### Example: Custom Color Scheme
|
|
369
|
+
|
|
370
|
+
To customize the colors, create a custom CSS file and load it after the default styles. You can override specific variables while keeping the rest of the defaults:
|
|
371
|
+
|
|
372
|
+
```css
|
|
373
|
+
/* custom-theme.css */
|
|
374
|
+
:root {
|
|
375
|
+
--text-link: #0066cc; /* Change link color to blue */
|
|
376
|
+
--bg-tertiary: #f0f0f0; /* Lighter API boxes */
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
@media (prefers-color-scheme: dark) {
|
|
380
|
+
:root {
|
|
381
|
+
--text-link: #66b3ff; /* Lighter blue for dark mode */
|
|
382
|
+
--bg-primary: #0d1117; /* GitHub-like dark background */
|
|
383
|
+
--bg-secondary: #161b22;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
Then reference it in your custom template by overriding the `default` template and adding a link to your stylesheet:
|
|
389
|
+
|
|
390
|
+
```html
|
|
391
|
+
<link rel="stylesheet" href="<%= base_url %>/assets/style.css" />
|
|
392
|
+
<link rel="stylesheet" href="<%= base_url %>/assets/custom-theme.css" />
|
|
393
|
+
```
|
|
394
|
+
|
|
130
395
|
## Configuration
|
|
131
396
|
|
|
132
397
|
The following options are available:
|
|
@@ -139,7 +404,7 @@ The following options are available:
|
|
|
139
404
|
| `use_default_styles` | Indicates if you want to use the default styles. | `true` |
|
|
140
405
|
| `base_url` | Indicates the base URL to prepend for assets and links. | `""` |
|
|
141
406
|
| `delete_output` | Deletes `output_dir` before generating content. | `false` |
|
|
142
|
-
| `pipeline_config` | Defines two sub-keys, `pipeline` and `context
|
|
407
|
+
| `pipeline_config` | Defines two sub-keys, `pipeline` and `context`. The `context` hash can contain an `unsafe` key to enable raw HTML rendering (needed for custom layouts). Note: In v6.0+, markdown and emoji rendering are handled directly by the gem, not via html-pipeline filters. | `pipeline` is empty. `context` has `gfm: false`, `unsafe: true`, and `asset_root` set to GitHub's CDN. |
|
|
143
408
|
| `renderer` | The rendering class to use. | `GraphQLDocs::Renderer` |
|
|
144
409
|
| `templates` | The templates to use when generating HTML. You may override any of the following keys: `default`, `includes`, `operations`, `objects`, `mutations`, `interfaces`, `enums`, `unions`, `input_objects`, `scalars`, `directives`. | The defaults are found in _lib/graphql-docs/layouts/_. |
|
|
145
410
|
| `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`, `directive`. | The defaults are found in _lib/graphql-docs/landing_pages/_. |
|
|
@@ -195,6 +460,57 @@ The format of `schema_member_path` is a dot delimited path to the schema member.
|
|
|
195
460
|
"Mutation.addLike" # a mutation
|
|
196
461
|
```
|
|
197
462
|
|
|
463
|
+
## Browser Support
|
|
464
|
+
|
|
465
|
+
The generated documentation sites work best on modern browsers. Browser requirements are determined by the CSS and JavaScript features used in the default templates.
|
|
466
|
+
|
|
467
|
+
### Fully Supported Browsers
|
|
468
|
+
|
|
469
|
+
All features work, including automatic dark mode based on system preferences:
|
|
470
|
+
|
|
471
|
+
- **Chrome/Edge**: 79+ (January 2020)
|
|
472
|
+
- **Firefox**: 67+ (May 2019)
|
|
473
|
+
- **Safari**: 12.1+ (March 2019)
|
|
474
|
+
- **Mobile Safari (iOS)**: 12.1+
|
|
475
|
+
- **Chrome for Android**: 79+
|
|
476
|
+
|
|
477
|
+
### Partial Support
|
|
478
|
+
|
|
479
|
+
The documentation will display correctly, but automatic dark mode will not work:
|
|
480
|
+
|
|
481
|
+
- **Chrome**: 49-78
|
|
482
|
+
- **Firefox**: 31-66
|
|
483
|
+
- **Safari**: 9.1-12.0
|
|
484
|
+
- **Edge**: 15-78
|
|
485
|
+
|
|
486
|
+
### Unsupported
|
|
487
|
+
|
|
488
|
+
- **Internet Explorer**: All versions (does not support CSS custom properties)
|
|
489
|
+
- **Browsers released before 2016**
|
|
490
|
+
|
|
491
|
+
### Technical Requirements
|
|
492
|
+
|
|
493
|
+
The default templates use the following modern web features:
|
|
494
|
+
|
|
495
|
+
**CSS Features:**
|
|
496
|
+
|
|
497
|
+
- CSS Custom Properties (CSS Variables) - Required for theming
|
|
498
|
+
- `@media (prefers-color-scheme: dark)` - Required for automatic dark mode
|
|
499
|
+
- Flexbox
|
|
500
|
+
- CSS Transforms and Transitions
|
|
501
|
+
|
|
502
|
+
**JavaScript Features:**
|
|
503
|
+
|
|
504
|
+
- ES6+ syntax (arrow functions, `const`/`let`, template literals)
|
|
505
|
+
- `sessionStorage` API - For sidebar resize persistence
|
|
506
|
+
- DOM APIs: `querySelector`, `addEventListener`, etc.
|
|
507
|
+
|
|
508
|
+
### Browser Support Policy
|
|
509
|
+
|
|
510
|
+
- The gem targets browsers released in 2019 or later for full feature support
|
|
511
|
+
- Graceful degradation ensures basic functionality on older browsers
|
|
512
|
+
- Any changes that drop support for currently supported browsers will be considered breaking changes and will require a major version release
|
|
513
|
+
|
|
198
514
|
## Supported Ruby Versions
|
|
199
515
|
|
|
200
516
|
The gem officially supports **Ruby 3.1 and newer**.
|
|
@@ -216,12 +532,70 @@ painless as possible.
|
|
|
216
532
|
Upcoming work for the project is organized publicly via [GitHub
|
|
217
533
|
Projects](https://github.com/users/brettchalupa/projects/7/views/1).
|
|
218
534
|
|
|
535
|
+
## API Documentation
|
|
536
|
+
|
|
537
|
+
This gem uses [YARD](https://yardoc.org/) for API documentation. All public classes and methods are documented with examples and detailed descriptions.
|
|
538
|
+
|
|
539
|
+
### Viewing the API Documentation
|
|
540
|
+
|
|
541
|
+
To generate and view the API documentation locally:
|
|
542
|
+
|
|
543
|
+
```console
|
|
544
|
+
bundle exec rake yard
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
This will generate HTML documentation in the `doc/` directory. Open `doc/index.html` in your browser to view it.
|
|
548
|
+
|
|
549
|
+
Alternatively, you can run a live documentation server with auto-reload:
|
|
550
|
+
|
|
551
|
+
```console
|
|
552
|
+
bundle exec rake yard:server
|
|
553
|
+
```
|
|
554
|
+
|
|
555
|
+
This starts a server at http://localhost:8808 that automatically reloads when you make changes to the code.
|
|
556
|
+
|
|
557
|
+
### Online Documentation
|
|
558
|
+
|
|
559
|
+
The API documentation is available online at [https://rubydoc.info/github/brettchalupa/graphql-docs.git/main](https://rubydoc.info/github/brettchalupa/graphql-docs.git/main).
|
|
560
|
+
|
|
561
|
+
### Documentation Coverage
|
|
562
|
+
|
|
563
|
+
The codebase maintains 100% documentation coverage for all public APIs. You can check documentation statistics with:
|
|
564
|
+
|
|
565
|
+
```console
|
|
566
|
+
bundle exec yard stats
|
|
567
|
+
```
|
|
568
|
+
|
|
219
569
|
## Development
|
|
220
570
|
|
|
221
571
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
|
222
572
|
`bin/rake test` to run the tests. You can also run `bin/console` for
|
|
223
573
|
an interactive prompt that will allow you to experiment.
|
|
224
574
|
|
|
575
|
+
### Code Style
|
|
576
|
+
|
|
577
|
+
This project uses [StandardRB](https://github.com/standardrb/standard) for Ruby code style enforcement. StandardRB is a zero-configuration formatter and linter based on RuboCop.
|
|
578
|
+
|
|
579
|
+
To check your code style:
|
|
580
|
+
|
|
581
|
+
```console
|
|
582
|
+
bundle exec rake standard
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
To automatically fix style issues:
|
|
586
|
+
|
|
587
|
+
```console
|
|
588
|
+
bundle exec rake standard:fix
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
The default rake task runs both StandardRB and the test suite:
|
|
592
|
+
|
|
593
|
+
```console
|
|
594
|
+
bundle exec rake
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
StandardRB checks are also run in CI, so make sure your code passes before opening a pull request.
|
|
598
|
+
|
|
225
599
|
### Releasing a new version of the gem
|
|
226
600
|
|
|
227
601
|
1. Update CHANGELOG.md
|
|
@@ -233,20 +607,42 @@ an interactive prompt that will allow you to experiment.
|
|
|
233
607
|
|
|
234
608
|
## Sample Site
|
|
235
609
|
|
|
236
|
-
Clone this repository and
|
|
610
|
+
Clone this repository and try out both modes:
|
|
237
611
|
|
|
238
|
-
|
|
612
|
+
### Static Site Generation
|
|
613
|
+
|
|
614
|
+
Generate the sample documentation to the `output` directory:
|
|
615
|
+
|
|
616
|
+
```console
|
|
239
617
|
bin/rake sample:generate
|
|
240
618
|
```
|
|
241
619
|
|
|
242
|
-
|
|
620
|
+
Then boot up a server to view the pre-generated files:
|
|
243
621
|
|
|
244
|
-
|
|
622
|
+
```console
|
|
623
|
+
bin/rake sample:serve
|
|
624
|
+
```
|
|
245
625
|
|
|
626
|
+
Visit `http://localhost:5050` to view the static documentation.
|
|
627
|
+
|
|
628
|
+
### Rack Application (Dynamic)
|
|
629
|
+
|
|
630
|
+
Run the sample docs as a dynamic Rack application:
|
|
631
|
+
|
|
632
|
+
```console
|
|
633
|
+
bin/rake sample:rack
|
|
246
634
|
```
|
|
247
|
-
|
|
635
|
+
|
|
636
|
+
Or use the config.ru directly:
|
|
637
|
+
|
|
638
|
+
```console
|
|
639
|
+
rackup config.ru
|
|
248
640
|
```
|
|
249
641
|
|
|
642
|
+
Visit `http://localhost:9292` to view the documentation served dynamically.
|
|
643
|
+
|
|
644
|
+
**Key Difference**: The SSG version pre-generates all pages (faster initial load, no runtime cost), while the Rack version generates pages on-demand (better for dynamic schemas, easier integration).
|
|
645
|
+
|
|
250
646
|
## Credits
|
|
251
647
|
|
|
252
648
|
Originally built by [gjtorikian](https://github.com/gjtorikian). Actively maintained by [brettchalupa](https://github.com/brettchalupa).
|
data/bin/console
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
#!/bin/
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
puts "===> Bundling..."
|
|
5
|
+
system("bin/setup", "--quiet") || exit(1)
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
bin/
|
|
7
|
-
|
|
8
|
-
echo "===> Launching..."
|
|
9
|
-
bin/rake console
|
|
7
|
+
puts "===> Launching..."
|
|
8
|
+
exec("bin/rake", "console")
|
data/bin/setup
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
2
|
-
|
|
3
|
-
IFS=$'\n\t'
|
|
4
|
-
set -vx
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
5
3
|
|
|
6
|
-
|
|
4
|
+
# Exit on any error
|
|
5
|
+
def run_command(*args)
|
|
6
|
+
system(*args) || exit(1)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
run_command("bundle", "install", *ARGV)
|
data/exe/graphql-docs
CHANGED
|
@@ -10,17 +10,17 @@ OptionParser.new do |parser|
|
|
|
10
10
|
parser.program_name = NAME
|
|
11
11
|
parser.banner = <<~EOS
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Generate GraphQL docs from the passed in schema file.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
Usage: graphql-docs SCHEMA
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
The only required argument is the path to the schema file to generate the site from.
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
Examples:
|
|
20
|
+
$ graphql-docs schema.graphql
|
|
21
|
+
$ graphql-docs schema.graphql -o _docs
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Options:
|
|
24
24
|
EOS
|
|
25
25
|
|
|
26
26
|
parser.version = GraphQLDocs::VERSION
|
|
@@ -51,7 +51,7 @@ verbose = opts.delete(:verbose)
|
|
|
51
51
|
|
|
52
52
|
puts("Generating site with the following options: #{opts}") if verbose
|
|
53
53
|
|
|
54
|
-
opts.transform_keys! { |k| k.to_s.
|
|
54
|
+
opts.transform_keys! { |k| k.to_s.tr("-", "_").to_sym }
|
|
55
55
|
GraphQLDocs.build(opts)
|
|
56
56
|
|
|
57
|
-
puts("Site successfully generated in: #{opts[:output_dir] ||
|
|
57
|
+
puts("Site successfully generated in: #{opts[:output_dir] || "output"}") if verbose
|