Skip to content

Commit c89f759

Browse files
committed
Add language code for Sphinx
1 parent e77ade4 commit c89f759

File tree

2 files changed

+110
-98
lines changed

2 files changed

+110
-98
lines changed

Diff for: docs/conf.py

+110-97
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,29 @@
3030
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3131
# ones.
3232
extensions = [
33-
'sphinx.ext.autodoc',
33+
"sphinx.ext.autodoc",
3434
]
3535

3636
# Add any paths that contain templates here, relative to this directory.
37-
templates_path = ['_templates']
37+
templates_path = ["_templates"]
3838

3939
# The suffix(es) of source filenames.
4040
# You can specify multiple suffix as a list of string:
4141
#
4242
# source_suffix = ['.rst', '.md']
43-
source_suffix = '.rst'
43+
source_suffix = ".rst"
4444

4545
# The encoding of source files.
4646
#
4747
# source_encoding = 'utf-8-sig'
4848

4949
# The master toctree document.
50-
master_doc = 'index'
50+
master_doc = "index"
5151

5252
# General information about the project.
53-
project = 'GraphQL-core 3'
54-
copyright = '2022, Christoph Zwerschke'
55-
author = 'Christoph Zwerschke'
53+
project = "GraphQL-core 3"
54+
copyright = "2022, Christoph Zwerschke"
55+
author = "Christoph Zwerschke"
5656

5757
# The version info for the project you're documenting, acts as replacement for
5858
# |version| and |release|, also used in various other places throughout the
@@ -61,14 +61,14 @@
6161
# The short X.Y version.
6262
# version = '3.2'
6363
# The full version, including alpha/beta/rc tags.
64-
version = release = '3.2.3'
64+
version = release = "3.2.3"
6565

6666
# The language for content autogenerated by Sphinx. Refer to documentation
6767
# for a list of supported languages.
6868
#
6969
# This is also used if you do content translation via gettext catalogs.
7070
# Usually you set "language" from the command line for these cases.
71-
language = None
71+
language = "en"
7272

7373
# There are two options for replacing |today|: either, you set today to some
7474
# non-false value, then it is used:
@@ -82,54 +82,62 @@
8282
# List of patterns, relative to source directory, that match files and
8383
# directories to ignore when looking for source files.
8484
# This patterns also effect to html_static_path and html_extra_path
85-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
85+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
8686

8787
# AutoDoc configuration
8888
autoclass_content = "class"
8989
autodoc_default_options = {
90-
'members': True,
91-
'inherited-members': True,
92-
'undoc-members': True,
93-
'show-inheritance': True
90+
"members": True,
91+
"inherited-members": True,
92+
"undoc-members": True,
93+
"show-inheritance": True,
9494
}
9595
autosummary_generate = True
9696

9797
autodoc_type_aliases = {
98-
'AwaitableOrValue': 'graphql.pyutils.AwaitableOrValue',
99-
'FormattedSourceLocation': 'graphql.language.FormattedSourceLocation',
100-
'Middleware': 'graphql.execution.Middleware',
101-
'TypeMap': 'graphql.schema.TypeMap'
98+
"AwaitableOrValue": "graphql.pyutils.AwaitableOrValue",
99+
"FormattedSourceLocation": "graphql.language.FormattedSourceLocation",
100+
"Middleware": "graphql.execution.Middleware",
101+
"TypeMap": "graphql.schema.TypeMap",
102102
}
103103

104104
# GraphQL-core top level modules with submodules that can be omitted.
105105
# Sometimes autodoc cannot find classes since it is looking for the
106106
# qualified form, but the documentation has the shorter form.
107107
# We need to give autodoc a little help in this cases.
108108
graphql_modules = {
109-
'error': ['graphql_error'],
110-
'execution': ['execute', 'middleware'],
111-
'language': ['ast', 'directive_locations', 'location',
112-
'source', 'token_kind', 'visitor'],
113-
'pyutils': ['simple_pub_sub', 'frozen_list', 'path'],
114-
'type': ['definition', 'directives', 'schema'],
115-
'utilities': ['find_breaking_changes', 'type_info'],
116-
'validation': ['rules', 'validation_context']}
109+
"error": ["graphql_error"],
110+
"execution": ["execute", "middleware"],
111+
"language": [
112+
"ast",
113+
"directive_locations",
114+
"location",
115+
"source",
116+
"token_kind",
117+
"visitor",
118+
],
119+
"pyutils": ["simple_pub_sub", "frozen_list", "path"],
120+
"type": ["definition", "directives", "schema"],
121+
"utilities": ["find_breaking_changes", "type_info"],
122+
"validation": ["rules", "validation_context"],
123+
}
117124

118125
# GraphQL-core classes that autodoc sometimes cannot find
119126
# (e.g. where specified as string in type hints).
120127
# We need to give autodoc a little help in this cases, too:
121128
graphql_classes = {
122-
'GraphQLAbstractType': 'type',
123-
'GraphQLObjectType': 'type',
124-
'GraphQLOutputType': 'type',
125-
'GraphQLTypeResolver': 'type',
126-
'Node': 'language',
127-
'Source': 'language',
128-
'SourceLocation': 'language'
129+
"GraphQLAbstractType": "type",
130+
"GraphQLObjectType": "type",
131+
"GraphQLOutputType": "type",
132+
"GraphQLTypeResolver": "type",
133+
"Node": "language",
134+
"Source": "language",
135+
"SourceLocation": "language",
129136
}
130137

131138
# ignore the following undocumented or internal references:
132-
ignore_references = set('''
139+
ignore_references = set(
140+
"""
133141
GNT GT KT T VT
134142
enum.Enum
135143
traceback
@@ -146,85 +154,87 @@
146154
graphql.validation.validation_context.VariableUsage
147155
graphql.validation.rules.known_argument_names.KnownArgumentNamesOnDirectivesRule
148156
graphql.validation.rules.provided_required_arguments.ProvidedRequiredArgumentsOnDirectivesRule
149-
'''.split())
157+
""".split()
158+
)
150159

151160
ignore_references.update(__builtins__.keys())
152161

153162

154163
def on_missing_reference(app, env, node, contnode):
155164
"""Fix or skip any missing references."""
156-
if node.get('refdomain') != 'py':
165+
if node.get("refdomain") != "py":
157166
return None
158-
target = node.get('reftarget')
167+
target = node.get("reftarget")
159168
if not target:
160169
return None
161-
if target in ignore_references or target.endswith('Kwargs'):
170+
if target in ignore_references or target.endswith("Kwargs"):
162171
return contnode
163-
typ = node.get('reftype')
164-
name = target.rsplit('.', 1)[-1]
165-
if name in ('GT', 'GNT', 'KT', 'T', 'VT'):
172+
typ = node.get("reftype")
173+
name = target.rsplit(".", 1)[-1]
174+
if name in ("GT", "GNT", "KT", "T", "VT"):
166175
return contnode
167-
if typ == 'obj':
168-
if target.startswith('typing.'):
169-
if name in ('Any', 'Optional', 'Union'):
176+
if typ == "obj":
177+
if target.startswith("typing."):
178+
if name in ("Any", "Optional", "Union"):
170179
return contnode
171-
if typ != 'class':
180+
if typ != "class":
172181
return None
173-
if '.' in target: # maybe too specific
174-
base_module, target = target.split('.', 1)
175-
if base_module == 'graphql':
176-
if '.' not in target:
182+
if "." in target: # maybe too specific
183+
base_module, target = target.split(".", 1)
184+
if base_module == "graphql":
185+
if "." not in target:
177186
return None
178-
base_module, target = target.split('.', 1)
179-
if '.' not in target:
187+
base_module, target = target.split(".", 1)
188+
if "." not in target:
180189
return None
181190
sub_modules = graphql_modules.get(base_module)
182191
if not sub_modules:
183192
return
184-
sub_module = target.split('.', 1)[0]
193+
sub_module = target.split(".", 1)[0]
185194
if sub_module not in sub_modules:
186195
return None
187-
target = 'graphql.' + base_module + '.' + target.rsplit('.', 1)[-1]
196+
target = "graphql." + base_module + "." + target.rsplit(".", 1)[-1]
188197
else: # maybe not specific enough
189198
base_module = graphql_classes.get(target)
190199
if not base_module:
191200
return None
192-
target = 'graphql.' + base_module + '.' + target
201+
target = "graphql." + base_module + "." + target
193202
# replace target
194-
if contnode.__class__.__name__ == 'Text':
203+
if contnode.__class__.__name__ == "Text":
195204
contnode = contnode.__class__(target)
196-
elif contnode.__class__.__name__ == 'literal':
205+
elif contnode.__class__.__name__ == "literal":
197206
if len(contnode.children) != 1:
198207
return None
199208
textnode = contnode.children[0]
200209
contnode.children[0] = textnode.__class__(target)
201210
else:
202211
return None
203-
node['reftarget'] = target
204-
fromdoc = node.get('refdoc')
212+
node["reftarget"] = target
213+
fromdoc = node.get("refdoc")
205214
if not fromdoc:
206-
doc_module = node.get('py:module')
215+
doc_module = node.get("py:module")
207216
if doc_module:
208-
if doc_module.startswith('graphql.'):
209-
doc_module = doc_module.split('.', 1)[-1]
210-
if doc_module not in graphql_modules and doc_module != 'graphql':
217+
if doc_module.startswith("graphql."):
218+
doc_module = doc_module.split(".", 1)[-1]
219+
if doc_module not in graphql_modules and doc_module != "graphql":
211220
doc_module = None
212-
fromdoc = 'modules/' + (doc_module or base_module)
221+
fromdoc = "modules/" + (doc_module or base_module)
213222
# try resolving again with replaced target
214-
return env.domains['py'].resolve_xref(
215-
env, fromdoc, app.builder, typ, target, node, contnode)
223+
return env.domains["py"].resolve_xref(
224+
env, fromdoc, app.builder, typ, target, node, contnode
225+
)
216226

217227

218228
def on_skip_member(_app, what, name, _obj, skip, _options):
219-
if what == 'class' and name == "__init__":
229+
if what == "class" and name == "__init__":
220230
# we could set "special-members" to "__init__",
221231
# but this gives an error when documenting modules
222232
return False
223233
return skip
224234

225235

226236
def setup(app):
227-
app.connect('missing-reference', on_missing_reference)
237+
app.connect("missing-reference", on_missing_reference)
228238
app.connect("autodoc-skip-member", on_skip_member)
229239

230240

@@ -252,7 +262,7 @@ def setup(app):
252262
# show_authors = False
253263

254264
# The name of the Pygments (syntax highlighting) style to use.
255-
pygments_style = 'sphinx'
265+
pygments_style = "sphinx"
256266

257267
# A list of ignored prefixes for module index sorting.
258268
# modindex_common_prefix = []
@@ -268,15 +278,13 @@ def setup(app):
268278
# The theme to use for HTML and HTML Help pages. See the documentation for
269279
# a list of builtin themes.
270280
#
271-
html_theme = 'sphinx_rtd_theme'
281+
html_theme = "sphinx_rtd_theme"
272282

273283
# Theme options are theme-specific and customize the look and feel of a theme
274284
# further. For a list of options available for each theme, see the
275285
# documentation.
276286
#
277-
html_theme_options = {
278-
'navigation_depth': 5
279-
}
287+
html_theme_options = {"navigation_depth": 5}
280288

281289
# Add any paths that contain custom themes here, relative to this directory.
282290
# html_theme_path = []
@@ -384,34 +392,36 @@ def setup(app):
384392
# html_search_scorer = 'scorer.js'
385393

386394
# Output file base name for HTML help builder.
387-
htmlhelp_basename = 'GraphQL-core-3-doc'
395+
htmlhelp_basename = "GraphQL-core-3-doc"
388396

389397
# -- Options for LaTeX output ---------------------------------------------
390398

391399
latex_elements = {
392-
# The paper size ('letterpaper' or 'a4paper').
393-
#
394-
# 'papersize': 'letterpaper',
395-
396-
# The font size ('10pt', '11pt' or '12pt').
397-
#
398-
# 'pointsize': '10pt',
399-
400-
# Additional stuff for the LaTeX preamble.
401-
#
402-
# 'preamble': '',
403-
404-
# Latex figure (float) alignment
405-
#
406-
# 'figure_align': 'htbp',
400+
# The paper size ('letterpaper' or 'a4paper').
401+
#
402+
# 'papersize': 'letterpaper',
403+
# The font size ('10pt', '11pt' or '12pt').
404+
#
405+
# 'pointsize': '10pt',
406+
# Additional stuff for the LaTeX preamble.
407+
#
408+
# 'preamble': '',
409+
# Latex figure (float) alignment
410+
#
411+
# 'figure_align': 'htbp',
407412
}
408413

409414
# Grouping the document tree into LaTeX files. List of tuples
410415
# (source start file, target name, title,
411416
# author, documentclass [howto, manual, or own class]).
412417
latex_documents = [
413-
(master_doc, 'GraphQL-core-3.tex', 'GraphQL-core 3 Documentation',
414-
'Christoph Zwerschke', 'manual'),
418+
(
419+
master_doc,
420+
"GraphQL-core-3.tex",
421+
"GraphQL-core 3 Documentation",
422+
"Christoph Zwerschke",
423+
"manual",
424+
),
415425
]
416426

417427
# The name of an image file (relative to this directory) to place at the top of
@@ -445,10 +455,7 @@ def setup(app):
445455

446456
# One entry per manual page. List of tuples
447457
# (source start file, name, description, authors, manual section).
448-
man_pages = [
449-
(master_doc, 'graphql-core', 'GraphQL-core 3 Documentation',
450-
[author], 1)
451-
]
458+
man_pages = [(master_doc, "graphql-core", "GraphQL-core 3 Documentation", [author], 1)]
452459

453460
# If true, show URL addresses after external links.
454461
#
@@ -461,9 +468,15 @@ def setup(app):
461468
# (source start file, target name, title, author,
462469
# dir menu entry, description, category)
463470
texinfo_documents = [
464-
(master_doc, 'GraphQL-core', 'GraphQL-core 3 Documentation',
465-
author, 'GraphQL-core 3', 'One line description of project.',
466-
'Miscellaneous'),
471+
(
472+
master_doc,
473+
"GraphQL-core",
474+
"GraphQL-core 3 Documentation",
475+
author,
476+
"GraphQL-core 3",
477+
"One line description of project.",
478+
"Miscellaneous",
479+
),
467480
]
468481

469482
# Documents to append as an appendix to all manuals.

Diff for: tox.ini

-1
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,3 @@ commands =
6363
# to run the benchmarks: tox -e py311 -- -k benchmarks --benchmark-enable
6464
py37,py38,py39,py310,py311,pypy39,pypy310: pytest tests {posargs}
6565
py312: pytest tests {posargs: --cov-report=term-missing --cov=graphql --cov=tests --cov-fail-under=100}
66-

0 commit comments

Comments
 (0)