You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+38-40Lines changed: 38 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,21 +8,21 @@ Ruby library and CLI for easily generating beautiful documentation from your Gra
8
8
9
9
Add the gem to your project with this command:
10
10
11
-
```console
11
+
```console
12
12
bundle add graphql-docs
13
13
```
14
14
15
15
Or install it yourself as:
16
16
17
-
```console
17
+
```console
18
18
gem install graphql-docs
19
19
```
20
20
21
21
## Usage
22
22
23
23
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:
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.
83
+
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
84
85
85
It also uses [html-pipeline](https://github.com/jch/html-pipeline) to perform the rendering by default. You can override this by providing a custom rendering class.You must implement two methods:
86
86
87
-
*`initialize` - Takes two arguments, the parsed `schema` and the configuration `options`.
88
-
*`render` Takes the contents of a template page. It also takes two optional kwargs, the GraphQL `type` and its `name`. For example:
87
+
-`initialize` - Takes two arguments, the parsed `schema` and the configuration `options`.
88
+
-`render` Takes the contents of a template page. It also takes two optional kwargs, the GraphQL `type` and its `name`. For example:
89
89
90
-
```ruby
90
+
```ruby
91
91
classCustomRenderer
92
92
definitialize(parsed_schema, options)
93
93
@parsed_schema= parsed_schema
@@ -120,31 +120,31 @@ If you want to add additional variables for your landing pages, you can add defi
120
120
121
121
In your ERB layouts, there are several helper methods you can use. The helper methods are:
122
122
123
-
*`slugify(str)` - This slugifies the given string.
124
-
*`include(filename, opts)` - This embeds a template from your `includes` folder, passing along the local options provided.
125
-
*`markdownify(string)` - This converts a string into HTML via CommonMarker.
126
-
*`graphql_operation_types`, `graphql_mutation_types`, `graphql_object_types`, `graphql_interface_types`, `graphql_enum_types`, `graphql_union_types`, `graphql_input_object_types`, `graphql_scalar_types`, `graphql_directive_types` - Collections of the various GraphQL types.
123
+
-`slugify(str)` - This slugifies the given string.
124
+
-`include(filename, opts)` - This embeds a template from your `includes` folder, passing along the local options provided.
125
+
-`markdownify(string)` - This converts a string into HTML via CommonMarker.
126
+
-`graphql_operation_types`, `graphql_mutation_types`, `graphql_object_types`, `graphql_interface_types`, `graphql_enum_types`, `graphql_union_types`, `graphql_input_object_types`, `graphql_scalar_types`, `graphql_directive_types` - Collections of the various GraphQL types.
127
127
128
128
To call these methods within templates, you must use the dot notation, such as `<%= slugify.(text) %>`.
129
129
130
130
## Configuration
131
131
132
132
The following options are available:
133
133
134
-
| Option | Description | Default |
135
-
| :----- | :---------- | :------ |
136
-
|`filename`| The location of your schema's IDL file. |`nil`|
137
-
|`schema`| A string representing a schema IDL file. |`nil`|
138
-
|`output_dir`| The location of the output HTML. |`./output/`|
139
-
|`use_default_styles`| Indicates if you want to use the default styles. |`true`|
140
-
|`base_url`| Indicates the base URL to prepend for assets and links. |`""`|
141
-
|`delete_output`| Deletes `output_dir` before generating content. |`false`|
142
-
|`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. |
143
-
| `renderer` | The rendering class to use. | `GraphQLDocs::Renderer`
144
-
| `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
-
| `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/_.
146
-
| `classes` | Additional class names you can provide to certain elements. | The full list is available in _lib/graphql-docs/configuration.rb_.
147
-
|`notices`| A proc used to add notices to schema members. See *Customizing Notices* section below. |`nil`|
|`filename`| The location of your schema's IDL file. |`nil`|
137
+
|`schema`| A string representing a schema IDL file. |`nil`|
138
+
|`output_dir`| The location of the output HTML. |`./output/`|
139
+
|`use_default_styles`| Indicates if you want to use the default styles. |`true`|
140
+
|`base_url`| Indicates the base URL to prepend for assets and links. |`""`|
141
+
|`delete_output`| Deletes `output_dir` before generating content. |`false`|
142
+
|`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. |
143
+
|`renderer`| The rendering class to use. |`GraphQLDocs::Renderer`|
144
+
|`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
+
|`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/_.|
146
+
|`classes`| Additional class names you can provide to certain elements. | The full list is available in _lib/graphql-docs/configuration.rb_.|
147
+
|`notices`| A proc used to add notices to schema members. See _Customizing Notices_ section below. |`nil`|
148
148
149
149
### Customizing Notices
150
150
@@ -157,11 +157,11 @@ The proc will be called for each schema member and needs to return an array of n
157
157
158
158
A `notice` has the following options:
159
159
160
-
| Option | Description |
161
-
| :----- | :---------- |
162
-
|`body`| CommonMark body of the notice |
163
-
|`title`| Optional title of the notice |
164
-
|`class`| Optional CSS class for the wrapper `<div>` of the notice |
|`class`| Optional CSS class for the wrapper `<div>` of the notice|
165
165
|`title_class`| Optional CSS class for the `<span>` of the notice's title |
166
166
167
167
Example of a `notices` proc that adds a notice to the `TeamDiscussion` type:
@@ -197,9 +197,7 @@ The format of `schema_member_path` is a dot delimited path to the schema member.
197
197
198
198
## Supported Ruby Versions
199
199
200
-
The gem officially supports **Ruby 2.7 and newer**.
201
-
202
-
A note about Ruby 2.6: It works, but it requires activesupport to be set to a version less than 7 due to it dropping Ruby 2.6 support. Ruby 2.6 is no longer tested on CI.
200
+
The gem officially supports **Ruby 3.1 and newer**.
203
201
204
202
Any dropping of Ruby version support is considered a breaking change and means a major release for the gem.
0 commit comments