From ecf1d0ff5c31e9424c5be13ffb24dbd58e71b570 Mon Sep 17 00:00:00 2001 From: Vossik Date: Sat, 15 May 2021 23:36:34 +0200 Subject: [PATCH 1/2] added copy current section link --- src/HtmlVisitor.php | 51 ++++++++++++++++++--------- src/theme/default.css | 8 ++++- tests/Integration/HtmlPrinterTest.php | 46 +++++++++++++++--------- 3 files changed, 71 insertions(+), 34 deletions(-) diff --git a/src/HtmlVisitor.php b/src/HtmlVisitor.php index a430fd3..cc2de5d 100644 --- a/src/HtmlVisitor.php +++ b/src/HtmlVisitor.php @@ -26,8 +26,10 @@ public function visitSchema(\Graphpinator\Type\Schema $schema) : string
{$this->printDescription($schema->getDescription())}
- schema  - { + + schema + +  {
@@ -59,8 +61,10 @@ public function visitType(\Graphpinator\Type\Type $type) : string
{$this->printDescription($type->getDescription())}
- type  - {$type->getName()} + + type  + {$type->getName()} + {$this->printImplements($type->getInterfaces())} {$this->printDirectiveUsages($type->getDirectiveUsages())}  { @@ -81,8 +85,10 @@ public function visitInterface(\Graphpinator\Type\InterfaceType $interface) : st
{$this->printDescription($interface->getDescription())}
- interface  - {$interface->getName()} + + interface  + {$interface->getName()} + {$this->printImplements($interface->getInterfaces())} {$this->printDirectiveUsages($interface->getDirectiveUsages())}  { @@ -111,8 +117,11 @@ public function visitUnion(\Graphpinator\Type\UnionType $union) : string
{$this->printDescription($union->getDescription())}
- union  - {$union->getName()} = {$types} + + union  + {$union->getName()} + +  = {$types}
EOL; @@ -124,8 +133,10 @@ public function visitInput(\Graphpinator\Type\InputType $input) : string
{$this->printDescription($input->getDescription())}
- input  - {$input->getName()} + + input  + {$input->getName()} + {$this->printDirectiveUsages($input->getDirectiveUsages())}  {
@@ -145,8 +156,10 @@ public function visitScalar(\Graphpinator\Type\ScalarType $scalar) : string
{$this->printDescription($scalar->getDescription())}
- scalar  - {$scalar->getName()} + + scalar  + {$scalar->getName()} +
EOL; @@ -158,9 +171,11 @@ public function visitEnum(\Graphpinator\Type\EnumType $enum) : string
{$this->printDescription($enum->getDescription())}
- enum  - {$enum->getName()}  - { + + enum  + {$enum->getName()} + +  {
{$this->printItems($enum->getItems())} @@ -186,8 +201,10 @@ public function visitDirective(\Graphpinator\Directive\Directive $directive) : s
{$this->printDescription($directive->getDescription())}
- directive  - @{$directive->getName()} + + directive  + @{$directive->getName()} + {$this->printArguments($directive)} {$repeatable} on {$locations}
diff --git a/src/theme/default.css b/src/theme/default.css index 1e324e5..2bb63e9 100644 --- a/src/theme/default.css +++ b/src/theme/default.css @@ -7,7 +7,7 @@ } .graphpinator-schema > .code { position: relative; - padding-left: 65px; + padding-left: 75px; } .keyword, .ampersand { color: rgb(102, 217, 239); @@ -94,3 +94,9 @@ section:target { .floating-button:not(:first-child) { margin-left: 5px; } +.self-link:hover:before { + content: "\01F517"; + margin-left: -16px; + font-size: 14px; + padding-right: 2px; +} diff --git a/tests/Integration/HtmlPrinterTest.php b/tests/Integration/HtmlPrinterTest.php index 72d4ea9..d4814e1 100644 --- a/tests/Integration/HtmlPrinterTest.php +++ b/tests/Integration/HtmlPrinterTest.php @@ -21,8 +21,10 @@ public function simpleDataProvider() : array
"""
- scalar  - Int + + scalar  + Int +
EOL, @@ -37,9 +39,11 @@ public function simpleDataProvider() : array
"""
- enum  - __TypeKind  - { + + enum  + __TypeKind + +  {
SCALAR
OBJECT
INTERFACE
UNION
ENUM
INPUT_OBJECT
LIST
NON_NULL
@@ -60,8 +64,10 @@ public function simpleDataProvider() : array
"""
- type  - __Schema + + type  + __Schema +   { @@ -127,8 +133,10 @@ public function simpleDataProvider() : array
"""
- type  - __Type + + type  + __Type +   { @@ -241,8 +249,10 @@ public function simpleDataProvider() : array
"""
- type  - __Directive + + type  + __Directive +   { @@ -297,8 +307,10 @@ public function simpleDataProvider() : array
- schema  - { + + schema + +  {
@@ -340,8 +352,10 @@ public function simpleDataProvider() : array
"""
- schema  - { + + schema + +  {
@@ -383,7 +397,7 @@ public function testSimple(\Graphpinator\Typesystem\Entity $type, string $print) public function testPrintSchema() : void { $expected = <<<'EOL' -
schema {
query: Query
mutation: null
subscription: null
}
 
interface ChildInterface implements ParentInterface {
name: String!
number: Int!
}
 
type ChildType implements ParentInterface & ChildInterface & SecondInterface {
name: String!
number: Int!
secondField: String!
}
 
"""
ComplexDefaultsInput description
"""
input ComplexDefaultsInput {
name: String = "default"
inner: ComplexDefaultsInput = {name:"innerDefault",inner:{name:"innerInnerDefault",inner:null,innerList:[]}}
innerList: [ComplexDefaultsInput] = [{name:"innerList1",inner:{name:"innerDefault",inner:{name:"innerInnerDefault",inner:null,innerList:[]}},innerList:[{name:"string",inner:{name:"innerDefault",inner:{name:"innerInnerDefault",inner:null,innerList:[]}},innerList:null},{name:"string",inner:{name:"innerDefault",inner:{name:"innerInnerDefault",inner:null,innerList:[]}},innerList:null}]},{name:"innerList2",inner:{name:"innerDefault",inner:{name:"innerInnerDefault",inner:null,innerList:[]}},innerList:[{name:"string2",inner:{name:"innerDefault",inner:{name:"innerInnerDefault",inner:null,innerList:[]}},innerList:null},{name:"string2",inner:{name:"innerDefault",inner:{name:"innerInnerDefault",inner:null,innerList:[]}},innerList:null}]}]
}
 
enum DescriptionEnum {
"single line description"
A
 
 
"""
multi line
description
"""
C
 
"single line description"
@deprecated(reason: "reason")
}
 
"""
ParentInterface Description
"""
interface ParentInterface {
name: String!
}
 
type Query {
field1: String
 
"Description to field"
fieldWithDescription: String
 
field2: String
}
 
interface SecondInterface {
secondField: String!
}
 
enum SimpleEnum {
A
B
C
D
}
 
input SimpleInput {
name: String!
number: [Int!]!
bool: Boolean
}
 
scalar SimpleScalar
 
"""
Description for SimpleType
"""
type SimpleType {
name: String!
}
 
union SimpleUnion = SimpleType | ChildType
 
directive @simpleDirective(
reason: String
) repeatable on FIELD | INLINE_FRAGMENT | FRAGMENT_SPREAD
+
query: Query
mutation: null
subscription: null
}
 
name: String!
number: Int!
}
 
name: String!
number: Int!
secondField: String!
}
 
"""
ComplexDefaultsInput description
"""
name: String = "default"
inner: ComplexDefaultsInput = {name:"innerDefault",inner:{name:"innerInnerDefault",inner:null,innerList:[]}}
innerList: [ComplexDefaultsInput] = [{name:"innerList1",inner:{name:"innerDefault",inner:{name:"innerInnerDefault",inner:null,innerList:[]}},innerList:[{name:"string",inner:{name:"innerDefault",inner:{name:"innerInnerDefault",inner:null,innerList:[]}},innerList:null},{name:"string",inner:{name:"innerDefault",inner:{name:"innerInnerDefault",inner:null,innerList:[]}},innerList:null}]},{name:"innerList2",inner:{name:"innerDefault",inner:{name:"innerInnerDefault",inner:null,innerList:[]}},innerList:[{name:"string2",inner:{name:"innerDefault",inner:{name:"innerInnerDefault",inner:null,innerList:[]}},innerList:null},{name:"string2",inner:{name:"innerDefault",inner:{name:"innerInnerDefault",inner:null,innerList:[]}},innerList:null}]}]
}
 
"single line description"
A
 
 
"""
multi line
description
"""
C
 
"single line description"
@deprecated(reason: "reason")
}
 
"""
ParentInterface Description
"""
name: String!
}
 
field1: String
 
"Description to field"
fieldWithDescription: String
 
field2: String
}
 
secondField: String!
}
 
A
B
C
D
}
 
name: String!
number: [Int!]!
bool: Boolean
}
 
 
"""
Description for SimpleType
"""
name: String!
}
 
 
reason: String
) repeatable on FIELD | INLINE_FRAGMENT | FRAGMENT_SPREAD
EOL; $printer = new \Graphpinator\Printer\Printer( From 72be420b18833002117b05303b7b11d0e5f96eea Mon Sep 17 00:00:00 2001 From: Vossik Date: Sat, 15 May 2021 23:39:40 +0200 Subject: [PATCH 2/2] removed padding-right from graphpinator-schema --- src/theme/default.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/theme/default.css b/src/theme/default.css index 2bb63e9..3b9f7ae 100644 --- a/src/theme/default.css +++ b/src/theme/default.css @@ -1,7 +1,7 @@ .graphpinator-schema { font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace; background: rgb(39, 40, 34); - padding: 10px; + padding: 10px 0 10px 10px; counter-reset: line; overflow-x: scroll; }