Skip to content

Commit

Permalink
Fix indentation issues causing incorrect rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
AWhetter committed Nov 12, 2023
1 parent 77297de commit 67d20da
Show file tree
Hide file tree
Showing 23 changed files with 236 additions and 42 deletions.
1 change: 1 addition & 0 deletions doc/changes/+c23554ff.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix indentation issues causing incorrect rendering
4 changes: 2 additions & 2 deletions src/autogqlschema/_templates/directive.rst.jinja
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.. gql:directive:: {{ signature }}

{% if description %}
{{ description }}
{{ description|indent(3) }}

{% endif %}
{% for arg, arg_description in args.items() %}
:argument {{ arg }}: {% if arg_description %}{{ arg_description }}{% endif +%}
:argument {{ arg }}: {% if arg_description %}{{ arg_description|indent(6) }}{% endif +%}
{% endfor %}
2 changes: 1 addition & 1 deletion src/autogqlschema/_templates/enum.rst.jinja
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. gql:enum:: {{ signature }}

{% if description %}
{{ description }}
{{ description|indent(3) }}

{% endif %}
{% for child in children %}
Expand Down
3 changes: 1 addition & 2 deletions src/autogqlschema/_templates/enum_value.rst.jinja
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.. gql:enum:value:: {{ signature }}

{% if description %}
{{ description }}
{{ description|indent(3) }}

{% endif %}

2 changes: 1 addition & 1 deletion src/autogqlschema/_templates/input.rst.jinja
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. gql:input:: {{ signature }}

{% if description %}
{{ description }}
{{ description|indent(3) }}

{% endif %}
{% for child in children %}
Expand Down
5 changes: 2 additions & 3 deletions src/autogqlschema/_templates/input_field.rst.jinja
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.. gql:input:field:: {{ signature }}

{% if description %}
{{ description }}
{{ description|indent(3) }}

{% endif %}

2 changes: 1 addition & 1 deletion src/autogqlschema/_templates/interface.rst.jinja
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. gql:interface:: {{ signature }}

{% if description %}
{{ description }}
{{ description|indent(3) }}

{% endif %}
{% for child in children %}
Expand Down
4 changes: 2 additions & 2 deletions src/autogqlschema/_templates/interface_field.rst.jinja
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.. gql:interface:field:: {{ signature }}

{% if description %}
{{ description }}
{{ description|indent(3) }}

{% endif %}
{% for arg, arg_description in args.items() %}
:argument {{ arg }}: {% if arg_description %}{{ arg_description }}{% endif +%}
:argument {{ arg }}: {% if arg_description %}{{ arg_description|indent(6) }}{% endif +%}
{% endfor %}
5 changes: 2 additions & 3 deletions src/autogqlschema/_templates/scalar.rst.jinja
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.. gql:scalar:: {{ signature }}

{% if description %}
{{ description }}
{{ description|indent(3) }}

{% endif %}

4 changes: 2 additions & 2 deletions src/autogqlschema/_templates/schema.rst.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
:name: {{ name }}

{% if description %}
{{ description }}
{{ description|indent(3) }}

{% endif %}
{% if query_type %}
Expand All @@ -14,7 +14,7 @@
{% if subscription_type %}
:optype {{ subscription_type }} subscription:
{% endif %}

{% for child in children %}
{{ renderer.render(child)|indent(3) }}
{% endfor %}
2 changes: 1 addition & 1 deletion src/autogqlschema/_templates/type.rst.jinja
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. gql:type:: {{ signature }}

{% if description %}
{{ description }}
{{ description|indent(3) }}

{% endif %}
{% for child in children %}
Expand Down
5 changes: 2 additions & 3 deletions src/autogqlschema/_templates/type_field.rst.jinja
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
.. gql:type:field:: {{ signature }}

{% if description %}
{{ description }}
{{ description|indent(3) }}

{% endif %}
{% for arg, arg_description in args.items() %}
:argument {{ arg }}: {% if arg_description %}{{ arg_description }}{% endif +%}
:argument {{ arg }}: {% if arg_description %}{{ arg_description|indent(6) }}{% endif +%}
{% endfor %}

5 changes: 2 additions & 3 deletions src/autogqlschema/_templates/union.rst.jinja
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.. gql:union:: {{ signature }}

{% if description %}
{{ description }}
{{ description|indent(3) }}

{% endif %}

6 changes: 5 additions & 1 deletion tests/fixtures/arguments.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ type TestArgumentType {
fieldA1(
"arg1 tests that arguments can be documented"
arg1: Int
"arg2 tests that arguments can be documented"
"""
arg2 tests that arguments can be documented.
It also tests that multiline docstrings are formatted correctly.
"""
arg2: input1
): String

Expand Down
10 changes: 9 additions & 1 deletion tests/fixtures/directives.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,18 @@ directive2 tests parsing with multiple type system directive locations
directive @directive2 on FIELD_DEFINITION | ARGUMENT_DEFINITION

"""
directive3 tests that arguments are parsed
directive3 tests that arguments are parsed.
It also tests that multiline docstrings are formatted correctly.
"""
directive @directive3(
"arg1 tests that arguments can be documented."
arg1: input1
"""
arg2 tests that arguments can be documented.
It also tests that multiline docstrings are formatted correctly.
"""
arg2: input1
) on SCALAR

10 changes: 8 additions & 2 deletions tests/fixtures/enums.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ enum enum1 {
}

"""
enum2 tests that directives are parsed
enum2 tests that directives are parsed.
It also tests that multiline docstrings are formatted correctly.
"""
enum enum2 @directiveA {
"enum2.value1 tests that directives are parsed"
"""
enum2.value1 tests that directives are parsed.
It also tests that multiline docstrings are formatted correctly.
"""
value1 @directiveA
}

10 changes: 8 additions & 2 deletions tests/fixtures/inputs.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ input input1 {
}

"""
input2 tests that directives are parsed
input2 tests that directives are parsed.
It also tests that multiline docstrings are formatted correctly.
"""
input input2 @directiveA {
"input2.field1 tests that directives are parsed"
"""
input2.field1 tests that directives are parsed.
It also tests that multiline docstrings are formatted correctly.
"""
field1: Int @directiveA
"input2.field2 tests that default values are parsed"
field2: String = "defaultvaluefield2"
Expand Down
12 changes: 10 additions & 2 deletions tests/fixtures/interfaces.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@ interface interface1 {
field1: String
}

"interface2 tests that directives are parsed"
"""
interface2 tests that directives are parsed.
It also tests that multiline docstrings are formatted correctly.
"""
interface interface2 @directive1 {
"interface2.field1 tests that directives are parsed"
"""
interface2.field1 tests that directives are parsed.
It also tests that multiline docstrings are formatted correctly.
"""
field1: Int @directive1
"interface2.field2 tests that arguments are parsed"
field2(
Expand Down
6 changes: 5 additions & 1 deletion tests/fixtures/scalars.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ directive @directive1 on SCALAR
"scalar1 tests parsing the simplest possible scalar definition"
scalar scalar1

"scalar2 tests that directives are parsed"
"""
scalar2 tests that directives are parsed.
It also tests that multiline docstrings are formatted correctly.
"""
scalar scalar2 @directive1
6 changes: 5 additions & 1 deletion tests/fixtures/schemas_directives.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ type MySubscriptionRootType {
field1: Int
}

"schema1 tests that directives are parsed, and operation types are rendered and linked."
"""
schema1 tests that directives are parsed, and operation types are rendered and linked.
It also tests that multiline docstrings are formatted correctly.
"""
schema @directive1 @directive2 {
query: MyQueryRootType
mutation: MyMutationRootType
Expand Down
18 changes: 15 additions & 3 deletions tests/fixtures/type_objects.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,26 @@ type type1 {

}

"type2 tests that directives are parsed"
"""
type2 tests that directives are parsed.
It also tests that multiline docstrings are formatted correctly.
"""
type type2 @directive1 {
"type2.field1 tests that directives are parsed"
"""
type2.field1 tests that directives are parsed.
It also tests that multiline docstrings are formatted correctly.
"""
field1: Int @directive1

"type2.field2 tests that arguments are parsed"
field2(
"arg1 tests that arguments can be documented."
"""
arg1 tests that arguments can be documented.
It also tests that multiline docstrings are formatted correctly.
"""
arg1: Int = 0
): String
}
6 changes: 5 additions & 1 deletion tests/fixtures/unions.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@ type type2 {
"union1 tests parsing the simplest possible union definition"
union union1 = type1 | type2

"union2 tests that directives are parsed"
"""
union2 tests that directives are parsed.
It also tests that multiline docstrings are formatted correctly.
"""
union union2 @directive1 = type1 | type2
Loading

0 comments on commit 67d20da

Please sign in to comment.