Skip to content

Commit 72bc96d

Browse files
committed
Fix issues with Sphinx docs and add docs test
1 parent 3ca6d64 commit 72bc96d

36 files changed

+280
-114
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ language: python
22

33
matrix:
44
include:
5-
- env: TOXENV=black,flake8,mypy
5+
- env: TOXENV=black,flake8,mypy,docs
66
python: 3.7
77
dist: xenial
88
sudo: true

docs/conf.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@
115115
# If true, `todo` and `todoList` produce output, else they produce nothing.
116116
todo_include_todos = False
117117

118-
119118
# -- Options for HTML output ----------------------------------------------
120119

121120
# The theme to use for HTML and HTML Help pages. See the documentation for

docs/intro.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ Now you can start using GraphQL-core-next by importing from the top-level
4141
:mod:`graphql` package. Nearly everything defined in the sub-packages
4242
can also be imported directly from the top-level package.
4343

44+
.. currentmodule:: graphql
45+
4446
For instance, using the types defined in the :mod:`graphql.type` package,
4547
you can define a GraphQL schema, like this simple one::
4648

docs/modules/error.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Error
22
=====
33

4+
.. currentmodule:: graphql.error
5+
46
.. automodule:: graphql.error
57

68
.. autoexception:: GraphQLError
@@ -10,6 +12,4 @@ Error
1012
.. autofunction:: print_error
1113
.. autofunction:: format_error
1214

13-
The :mod:`graphql.error` module also contains the :const:`INVALID` singleton that is
14-
used to describe invalid or undefined values and corresponds to the ``undefined``
15-
value in GraphQL.js.
15+
.. autodata:: INVALID

docs/modules/execution.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Execution
22
=========
33

4+
.. currentmodule:: graphql.execution
5+
46
.. automodule:: graphql.execution
57

68
.. autofunction:: execute

docs/modules/graphql.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Reference
22
=========
33

4+
.. currentmodule:: graphql
5+
46
.. automodule:: graphql
57

68
.. _top-level-functions:

docs/modules/language.rst

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,25 @@ Visitor
9999
.. autoclass:: ParallelVisitor
100100
.. autoclass:: TypeInfoVisitor
101101

102-
The module also exports the constants :const:`BREAK`, :const:`SKIP`, :const:`REMOVE` and
103-
:const:`IDLE` that are used as special return values in the :class:`Visitor` methods.
102+
The module also exports the following special symbols which can be used as
103+
return values in the :class:`Visitor` methods to signal particular actions:
104+
105+
.. data:: BREAK
106+
:annotation: = True
107+
108+
This return value signals that no further nodes shall be visited.
109+
110+
.. data:: SKIP
111+
:annotation: = False
112+
113+
This return value signals that the current node shall be skipped.
114+
115+
.. data:: REMOVE
116+
:annotation: = Ellipsis
117+
118+
This return value signals that the current node shall be deleted.
119+
120+
.. data:: IDLE
121+
:annotation: = None
122+
123+
This return value signals that no additional action shall take place.

docs/modules/pyutils.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
PyUtils
22
=======
33

4+
.. currentmodule:: graphql.pyutils
5+
46
.. automodule:: graphql.pyutils
57

68
.. autofunction:: camel_to_snake
@@ -18,5 +20,6 @@ PyUtils
1820
.. autofunction:: or_list
1921
.. autofunction:: quoted_or_list
2022
.. autofunction:: suggestion_list
21-
.. autofunction:: ReadOnlyError
22-
.. autofunction:: ReadOnlyList
23+
.. autoclass:: ReadOnlyError
24+
.. autoclass:: ReadOnlyList
25+
.. autoclass:: ReadOnlyDict

docs/modules/subscription.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Subscription
22
============
33

4+
.. currentmodule:: graphql.subscription
5+
46
.. automodule:: graphql.subscription
57

68
.. autofunction:: subscribe

docs/modules/type.rst

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
Type
22
====
33

4+
.. currentmodule:: graphql.type
5+
46
.. automodule:: graphql.type
57

8+
69
Definition
710
----------
811

@@ -99,6 +102,7 @@ Resolvers
99102
.. autoclass:: GraphQLTypeResolver
100103
.. autoclass:: ResponsePath
101104

105+
102106
Directives
103107
----------
104108

@@ -116,11 +120,13 @@ Definitions
116120
.. autoclass:: GraphQLSkipDirective
117121
.. autoclass:: GraphQLDeprecatedDirective
118122

119-
The list of all specified directives is available as
120-
:data:`specified_directives`.
123+
.. autodata:: specified_directives
124+
125+
.. data:: DEFAULT_DEPRECATION_REASON
126+
:annotation: = 'No longer supported'
127+
128+
String constant that can be used as the default value for ``deprecation_reason``.
121129

122-
The module also exports the constant :const:`DEFAULT_DEPRECATION_REASON`
123-
that can be used as the default value for :obj:`deprecation_reason`.
124130

125131
Introspection
126132
-------------
@@ -130,7 +136,6 @@ Predicates
130136

131137
.. autofunction:: is_introspection_type
132138

133-
134139
Definitions
135140
^^^^^^^^^^^
136141

@@ -139,8 +144,8 @@ Definitions
139144
.. autoclass:: TypeNameMetaFieldDef
140145
.. autoclass:: SchemaMetaFieldDef
141146

142-
The list of all introspection types is available as
143-
:data:`introspection_types`.
147+
.. autodata:: introspection_types
148+
144149

145150
Scalars
146151
-------
@@ -162,6 +167,7 @@ Definitions
162167
The list of all specified directives is available as
163168
:data:`specified_directives`.
164169

170+
165171
Schema
166172
------
167173

@@ -184,7 +190,6 @@ Functions:
184190

185191
.. autofunction:: validate_schema
186192

187-
188193
Assertions
189194
^^^^^^^^^^
190195

docs/modules/utilities.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Utilities
22
=========
33

4+
.. currentmodule:: graphql.utilities
5+
46
.. automodule:: graphql.utilities
57

68
The GraphQL query recommended for a full schema introspection:

docs/modules/validation.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
11
Validation
22
==========
33

4+
.. currentmodule:: graphql.validation
5+
46
.. automodule:: graphql.validation
57

68
.. autofunction:: validate
79

10+
.. autoclass:: ASTValidationContext
11+
12+
.. autoclass:: ASTValidationRule
13+
14+
.. autoclass:: SDLValidationContext
15+
16+
.. autoclass:: SDLValidationRule
17+
818
.. autoclass:: ValidationContext
919

20+
.. autoclass:: ValidationRule
21+
22+
1023
Rules
1124
-----
1225

@@ -15,6 +28,7 @@ rules in this list has been adjusted to lead to the most clear output when encou
1528
multiple validation errors:
1629

1730
.. autodata:: specified_rules
31+
:annotation: = ReadOnlyList([...])
1832

1933
Spec Section: "Executable Definitions"
2034

@@ -119,4 +133,3 @@ Spec Section: "Variables are Input Types"
119133
Spec Section: "All Variable Usages Are Allowed"
120134

121135
.. autoclass:: VariablesInAllowedPositionRule
122-

docs/usage/methods.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,6 @@ In a similar vein, you can also attach resolvers as methods to the resolved obje
5252
deeper levels than the root of the query. In that case, instead of resolving to
5353
dictionaries with keys for all the fields, as we did above, you would resolve to objects
5454
with attributes for all the fields. For instance, you would define a class ``Human``
55-
with a method :meth:`friends` for resolving the friends of a human. You can also make
55+
with a method ``friends()`` for resolving the friends of a human. You can also make
5656
use of inheritance in this case. The ``Human`` class and a ``Droid`` class could inherit
5757
from a ``Character`` class and use its methods as resolvers for common fields.

docs/usage/other.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
Subscriptions
22
-------------
33

4+
.. currentmodule:: graphql.subscription
5+
46
Sometimes you need to not only query data from a server, but you also want to push data
57
from the server to the client. GraphQL-core-next has you also covered here, because it
68
implements the "Subscribe" algorithm described in the GraphQL spec. To execute a GraphQL
7-
subscription, you must use the :func:`graphql.subscribe` method from the
9+
subscription, you must use the :func:`subscribe` method from the
810
:mod:`graphql.subscription` module. Instead of a single ``ExecutionResult``, this
911
function returns an asynchronous iterator yielding a stream of those, unless there was
1012
an immediate error. Of course you will then also need to maintain a persistent channel

docs/usage/parser.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Parsing GraphQL Queries and Schema Notation
22
-------------------------------------------
33

4+
.. currentmodule:: graphql.language
5+
46
When executing GraphQL queries, the first step that happens under the hood is parsing
57
the query. But GraphQL-core-next also exposes the parser for direct usage via the
68
:func:`graphql.language.parse` function. When you pass this function a GraphQL source
@@ -58,12 +60,12 @@ This will give the same result as manually creating the AST document::
5860
])
5961

6062

61-
When parsing with `no_location=False` (the default), the AST nodes will also have a
62-
:attr:`loc` attribute carrying the information on the source code location corresponding
63+
When parsing with ``no_location=False`` (the default), the AST nodes will also have a
64+
``loc`` attribute carrying the information on the source code location corresponding
6365
to the AST nodes.
6466

6567
When there is a syntax error in the GraphQL source code, then the :func:`parse` function
66-
will raise a :exc:`GraphQLSyntaxError`.
68+
will raise a :exc:`graphql.error.GraphQLSyntaxError`.
6769

6870
The parser can not only be used to parse GraphQL queries, but also to parse the GraphQL
6971
schema definition language. This will result in another way of representing a GraphQL

docs/usage/queries.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Executing Queries
22
-----------------
33

4+
.. currentmodule:: graphql.execution
5+
46
Now that we have defined the schema and breathed life into it with our resolver
57
functions, we can execute arbitrary query against the schema.
68

@@ -36,8 +38,8 @@ should get the expected result::
3638
data={'droid': {'name': 'R2-D2', 'primaryFunction': 'Astromech'}},
3739
errors=None)
3840

39-
The :class:`execution.ExecutionResult` has a :attr:`data` attribute with the actual
40-
result, and an :attr:`errors` attribute with a list of errors if there were any.
41+
The :class:`ExecutionResult` has a ``data`` attribute with the actual result, and an
42+
``errors`` attribute with a list of errors if there were any.
4143

4244
If all your resolvers work synchronously, as in our case, you can also use the
4345
:func:`graphql.graphql_sync` function to query the result in ordinary synchronous code::
@@ -118,7 +120,7 @@ Finally, let's see what happens when we try to access the secret backstory of ou
118120

119121
While we get the name of the hero, the secret backstory fields remains empty, since its
120122
resolver function raises an error. However, we get the error that has been raised by the
121-
resolver in the :attr:`errors` attribute of the result::
123+
resolver in the ``errors`` attribute of the result::
122124

123125
ExecutionResult(
124126
data={'hero': {'name': 'Luke Skywalker', 'secretBackstory': None}},

docs/usage/resolvers.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ Note that the resolver functions get the current object as first argument. For a
8181
on the root Query type this is often not used, but a root object can also be defined
8282
when executing the query. As the second argument, they get an object containing
8383
execution information, as defined in the :class:`graphql.type.GraphQLResolveInfo` class.
84-
This object also has a :attr:`context` attribute that can be used to provide every
85-
resolver with contextual information like the currently logged in user, or a database
86-
session. In our simple example we don't authenticate users and use static data instead
87-
of a database, so we don't make use of it here. In addition to these two arguments,
84+
This object also has a ``context`` attribute that can be used to provide every resolver
85+
with contextual information like the currently logged in user, or a database session.
86+
In our simple example we don't authenticate users and use static data instead of a
87+
database, so we don't make use of it here. In addition to these two arguments,
8888
resolver functions optionally get the defined for the field in the schema, using the
8989
same names (the names are not translated from GraphQL naming conventions to Python
9090
naming conventions).

docs/usage/schema.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Building a Type Schema
22
----------------------
33

4+
.. currentmodule:: graphql.type
5+
46
Using the classes in the :mod:`graphql.type` sub-package as building blocks, you can
57
build a complete GraphQL type schema.
68

docs/usage/validator.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
Validating GraphQL Queries
22
--------------------------
33

4+
.. currentmodule:: graphql.validation
5+
46
When executing GraphQL queries, the second step that happens under the hood after
57
parsing the source code is a validation against the given schema using the rules of the
68
GraphQL specification. You can also run the validation step manually by calling the
@@ -33,8 +35,9 @@ In this case, we will get::
3335
" sub selection of subfields. Did you mean 'friends { ... }'?",
3436
locations=[SourceLocation(line=6, column=9)])]
3537

36-
These rules are implemented in the :mod:`graphql.validation.rules` module. Instead of
37-
the default rules, you can also use a subset or create custom rules. The rules are based
38-
on the :class:`graphql.validation.ValidationRule` class which is based on the
38+
These rules are available in the :data:`specified_rules` list and implemented in the
39+
``graphql.validation.rules`` subpackage. Instead of the default rules,
40+
you can also use a subset or create custom rules. The rules are
41+
based on the :class:`graphql.validation.ValidationRule` class which is based on the
3942
:class:`graphql.language.Visitor` class which provides a way of walking through an AST
4043
document using the visitor pattern.

graphql/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
- :mod:`graphql.error`: Creating and formatting GraphQL errors.
3535
- :mod:`graphql.utilities`:
3636
Common useful computations upon the GraphQL language and type objects.
37-
- :mod:`graphql/subscription`: Subscribe to data updates.
37+
- :mod:`graphql.subscription`: Subscribe to data updates.
3838
"""
3939

4040
__version__ = "1.0.4"

graphql/error/format_error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
def format_error(error: "GraphQLError") -> Dict[str, Any]:
11-
"""Format a GraphQL error
11+
"""Format a GraphQL error.
1212
1313
Given a GraphQLError, format it according to the rules described by the "Response
1414
Format, Errors" section of the GraphQL Specification.

graphql/error/invalid.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ def __ne__(self, other):
2222

2323
# Used to indicate invalid values (like "undefined" in GraphQL.js):
2424
INVALID = InvalidType()
25+
26+
INVALID.__doc__ = """Symbol for invalid or undefined values
27+
28+
This singleton object is used to describe invalid or undefined values.
29+
It corresponds to the ``undefined`` value in GraphQL.js.
30+
"""

0 commit comments

Comments
 (0)