|
52 | 52 |
|
53 | 53 | # General information about the project. |
54 | 54 | project = "GraphQL-core 3" |
55 | | -copyright = "2025, Christoph Zwerschke" |
| 55 | +copyright = "2026, Christoph Zwerschke" |
56 | 56 | author = "Christoph Zwerschke" |
57 | 57 |
|
58 | 58 | # The version info for the project you're documenting, acts as replacement for |
|
95 | 95 | } |
96 | 96 | autosummary_generate = True |
97 | 97 |
|
98 | | -autodoc_type_aliases = { |
99 | | - "AwaitableOrValue": "graphql.pyutils.AwaitableOrValue", |
100 | | - "FormattedSourceLocation": "graphql.language.FormattedSourceLocation", |
101 | | - "Middleware": "graphql.execution.Middleware", |
102 | | - "TypeMap": "graphql.schema.TypeMap", |
103 | | -} |
104 | | - |
105 | 98 | # GraphQL-core top level modules with submodules that can be omitted. |
106 | 99 | # Sometimes autodoc cannot find classes since it is looking for the |
107 | 100 | # qualified form, but the documentation has the shorter form. |
|
123 | 116 | "validation": ["rules", "validation_context"], |
124 | 117 | } |
125 | 118 |
|
126 | | -# GraphQL-core classes that autodoc sometimes cannot find |
127 | | -# (e.g. where specified as string in type hints). |
128 | | -# We need to give autodoc a little help in this cases, too: |
129 | | -graphql_classes = { |
130 | | - "GraphQLAbstractType": "type", |
131 | | - "GraphQLFieldResolver": "type", |
132 | | - "GraphQLObjectType": "type", |
133 | | - "GraphQLOutputType": "type", |
134 | | - "GraphQLTypeResolver": "type", |
135 | | - "AwaitableOrValue": "execution", |
136 | | - "Middleware": "execution", |
137 | | - "Node": "language", |
138 | | - "Source": "language", |
139 | | - "SourceLocation": "language", |
140 | | -} |
141 | | - |
142 | | -# ignore the following undocumented or internal references: |
143 | | -ignore_references = { |
144 | | - "GNT", |
145 | | - "GT", |
146 | | - "KT", |
147 | | - "T", |
148 | | - "VT", |
149 | | - "TContext", |
150 | | - "Enum", |
151 | | - "traceback", |
152 | | - "TypeMap", |
153 | | - "AwaitableOrValue", |
154 | | - "CancellableStreamRecord", |
155 | | - "DeferredFragmentRecord", |
156 | | - "DeferredGroupedFieldSetRecord", |
157 | | - "DeferredGroupedFieldSetResult", |
158 | | - "DeferUsage", |
159 | | - "EnterLeaveVisitor", |
160 | | - "ExperimentalIncrementalExecutionResults", |
161 | | - "FieldGroup", |
162 | | - "FormattedCompletedResult", |
163 | | - "FormattedIncrementalResult", |
164 | | - "FormattedPendingResult", |
165 | | - "FormattedSourceLocation", |
166 | | - "GraphQLAbstractType", |
167 | | - "GraphQLCompositeType", |
168 | | - "GraphQLEnumValueMap", |
169 | | - "GraphQLErrorExtensions", |
170 | | - "GraphQLFieldResolver", |
171 | | - "GraphQLInputType", |
172 | | - "GraphQLLeafType", |
173 | | - "GraphQLNullableType", |
174 | | - "GraphQLOutputType", |
175 | | - "GraphQLTypeResolver", |
176 | | - "GraphQLWrappedResult", |
177 | | - "GroupedFieldSet", |
178 | | - "IncrementalContext", |
179 | | - "IncrementalDataRecord", |
180 | | - "IncrementalResult", |
181 | | - "Middleware", |
182 | | - "PendingResult", |
183 | | - "StreamItemRecord", |
184 | | - "StreamItemResult", |
185 | | - "StreamItemsResult", |
186 | | - "StreamRecord", |
187 | | - "SubsequentDataRecord", |
188 | | - "SubsequentResultRecord", |
189 | | - "UndefinedType", |
190 | | - "asyncio.events.AbstractEventLoop", |
191 | | - "collections.abc.MutableMapping", |
192 | | - "collections.abc.MutableSet", |
193 | | - "enum.Enum", |
194 | | - "graphql.execution.build_field_plan.FieldGroup", |
195 | | - "graphql.execution.build_field_plan.FieldPlan", |
196 | | - "graphql.execution.collect_fields.CollectedFields", |
197 | | - "graphql.execution.collect_fields.DeferUsage", |
198 | | - "graphql.execution.collect_fields.FieldDetails", |
199 | | - "graphql.execution.execute.GraphQLWrappedResult", |
200 | | - "graphql.execution.execute.IncrementalContext", |
201 | | - "graphql.execution.execute.StreamArguments", |
202 | | - "graphql.execution.execute.SubFieldPlan", |
203 | | - "graphql.execution.execute.StreamUsage", |
204 | | - "graphql.execution.incremental_publisher.IncrementalPublisher", |
205 | | - "graphql.execution.incremental_publisher.IncrementalPublisherContext", |
206 | | - "graphql.execution.map_async_iterable.map_async_iterable", |
207 | | - "graphql.execution.Middleware", |
208 | | - "graphql.execution.types.BareDeferredGroupedFieldSetResult", |
209 | | - "graphql.execution.types.BareStreamItemsResult", |
210 | | - "graphql.execution.types.CancellableStreamRecord", |
211 | | - "graphql.execution.types.CompletedResult", |
212 | | - "graphql.execution.types.DeferredFragmentRecord", |
213 | | - "graphql.execution.types.DeferredGroupedFieldSetRecord", |
214 | | - "graphql.execution.types.FormattedCompletedResult", |
215 | | - "graphql.execution.types.FormattedPendingResult", |
216 | | - "graphql.execution.types.NonReconcilableStreamItemsResult", |
217 | | - "graphql.execution.types.PendingResult", |
218 | | - "graphql.execution.types.ReconcilableStreamItemsResult", |
219 | | - "graphql.execution.types.StreamItemResult", |
220 | | - "graphql.execution.types.StreamRecord", |
221 | | - "graphql.execution.types.SubsequentResultRecord", |
222 | | - "graphql.execution.types.TerminatingStreamItemsResult", |
223 | | - "graphql.language.lexer.EscapeSequence", |
224 | | - "graphql.language.visitor.EnterLeaveVisitor", |
225 | | - "graphql.pyutils.ref_map.K", |
226 | | - "graphql.pyutils.ref_map.V", |
227 | | - "graphql.type.definition.GT_co", |
228 | | - "graphql.type.definition.GNT_co", |
229 | | - "graphql.type.definition.TContext", |
230 | | - "graphql.type.schema.InterfaceImplementations", |
231 | | - "graphql.validation.validation_context.VariableUsage", |
232 | | - "graphql.validation.rules.known_argument_names.KnownArgumentNamesOnDirectivesRule", |
233 | | - "graphql.validation.rules.provided_required_arguments.ProvidedRequiredArgumentsOnDirectivesRule", |
234 | | -} |
235 | | - |
236 | | -ignore_references.update(__builtins__) |
237 | | - |
238 | | - |
239 | | -def on_missing_reference(app, env, node, contnode): |
240 | | - """Fix or skip any missing references.""" |
241 | | - if node.get("refdomain") != "py": |
242 | | - return None |
243 | | - target = node.get("reftarget") |
244 | | - if not target: |
245 | | - return None |
246 | | - if target in ignore_references or target.endswith("Kwargs"): |
247 | | - return contnode |
248 | | - typ = node.get("reftype") |
249 | | - name = target.rsplit(".", 1)[-1] |
250 | | - if name in ("GT", "GNT", "KT", "T", "VT"): |
251 | | - return contnode |
252 | | - if ( |
253 | | - typ == "obj" |
254 | | - and target.startswith("typing.") |
255 | | - and name in ("Any", "Optional", "Union") |
256 | | - ): |
257 | | - return contnode |
258 | | - if typ != "class": |
259 | | - return None |
260 | | - if "." in target: # maybe too specific |
261 | | - base_module, target = target.split(".", 1) |
262 | | - if base_module == "graphql": |
263 | | - if "." not in target: |
264 | | - return None |
265 | | - base_module, target = target.split(".", 1) |
266 | | - if "." not in target: |
267 | | - return None |
268 | | - sub_modules = graphql_modules.get(base_module) |
269 | | - if not sub_modules: |
270 | | - return None |
271 | | - sub_module = target.split(".", 1)[0] |
272 | | - if sub_module not in sub_modules: |
273 | | - return None |
274 | | - target = "graphql." + base_module + "." + target.rsplit(".", 1)[-1] |
275 | | - else: # maybe not specific enough |
276 | | - base_module = graphql_classes.get(target) |
277 | | - if not base_module: |
278 | | - return None |
279 | | - target = "graphql." + base_module + "." + target |
280 | | - # replace target |
281 | | - if contnode.__class__.__name__ == "Text": |
282 | | - contnode = contnode.__class__(target) |
283 | | - elif contnode.__class__.__name__ == "literal": |
284 | | - if len(contnode.children) != 1: |
285 | | - return None |
286 | | - textnode = contnode.children[0] |
287 | | - contnode.children[0] = textnode.__class__(target) |
288 | | - else: |
289 | | - return None |
290 | | - node["reftarget"] = target |
291 | | - fromdoc = node.get("refdoc") |
292 | | - if not fromdoc: |
293 | | - doc_module = node.get("py:module") |
294 | | - if doc_module: |
295 | | - if doc_module.startswith("graphql."): |
296 | | - doc_module = doc_module.split(".", 1)[-1] |
297 | | - if doc_module not in graphql_modules and doc_module != "graphql": |
298 | | - doc_module = None |
299 | | - fromdoc = "modules/" + (doc_module or base_module) |
300 | | - # try resolving again with replaced target |
301 | | - return env.domains["py"].resolve_xref( |
302 | | - env, fromdoc, app.builder, typ, target, node, contnode |
303 | | - ) |
304 | | - |
305 | | - |
306 | | -def on_skip_member(_app, what, name, _obj, skip, _options): |
307 | | - if what == "class" and name == "__init__": |
308 | | - # we could set "special-members" to "__init__", |
309 | | - # but this gives an error when documenting modules |
310 | | - return False |
311 | | - return skip |
312 | | - |
313 | | - |
314 | | -def setup(app): |
315 | | - app.connect("missing-reference", on_missing_reference) |
316 | | - app.connect("autodoc-skip-member", on_skip_member) |
317 | | - |
318 | | - |
319 | 119 | # be nitpicky (handle all possible problems in on_missing_reference) |
320 | 120 | nitpicky = True |
| 121 | +nitpick_ignore = [ |
| 122 | + # TypeVars and internal types that can't be resolved |
| 123 | + ("py:obj", "graphql.pyutils.ref_map.K"), |
| 124 | + ("py:obj", "graphql.pyutils.ref_map.V"), |
| 125 | + ("py:obj", "graphql.type.definition.GT_co"), |
| 126 | + ("py:obj", "graphql.type.definition.GNT_co"), |
| 127 | + ("py:obj", "graphql.type.definition.TContext"), |
| 128 | +] |
| 129 | + |
| 130 | +suppress_warnings = ["ref.class", "ref.python"] |
321 | 131 |
|
322 | 132 |
|
323 | 133 | # The reST default role (used for this markup: `text`) to use for all |
|
0 commit comments