Documentation ¶
Overview ¶
Package doc contains a CommonMark documentation generator for GraphQL Documents.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Generator ¶
Generator generates CommonMark documentation for GraphQL Documents.
func (*Generator) Generate ¶
func (g *Generator) Generate(ctx context.Context, doc *ast.Document, opts map[string]interface{}) (err error)
Generate generates CommonMark documentation for the given document.
Example ¶
g := new(Generator) gqlSrc := `schema { query: Query } "Query represents the queries this example provides." type Query { hello: String }` doc, err := parser.ParseDoc(token.NewDocSet(), "example", strings.NewReader(gqlSrc), 0) if err != nil { return // Handle error } var b bytes.Buffer ctx := gen.WithContext(context.Background(), gen.TestCtx{Writer: &b}) // Pass in an actual err = g.Generate(ctx, doc, map[string]interface{}{"title": "Example Documentation"}) if err != nil { return // Handle err } fmt.Println(b.String())
Output: # Example Documentation *This was generated by gqlc.* ## Table of Contents - [Schema](#Schema) - [Objects](#Objects) * [Query](#Query) ## Schema *Root Operations*: - query **([Query](#Query))** ## Objects ### Query Query represents the queries this example provides. *Fields*: - hello **(String)**
Click to show internal directories.
Click to hide internal directories.