Improved documentation pages.

This commit is contained in:
Syrus Akbary 2015-11-25 22:58:43 -08:00
parent aebafbc3c3
commit c4c3d0ef28
11 changed files with 78 additions and 61 deletions

View File

@ -32,7 +32,7 @@ install:
script: script:
- | - |
if [ "$TEST_TYPE" = build_website ]; then if [ "$TEST_TYPE" = build_website ]; then
if [ "$TRAVIS_BRANCH" = "docs" ] && [ "$TRAVIS_PULL_REQUEST" = false ]; then if [ "$TRAVIS_BRANCH" = "master" ] && [ "$TRAVIS_PULL_REQUEST" = false ]; then
echo "Building the web." echo "Building the web."
nvm install 4.0 nvm install 4.0

View File

@ -19,6 +19,9 @@ a, a:hover
a a
color rgb(42,93,173) color rgb(42,93,173)
p
margin-bottom 1em
html, body html, body
font-family "Helvetica Neue", Helvetica, Arial, sans-serif font-family "Helvetica Neue", Helvetica, Arial, sans-serif
font-weight 300 font-weight 300
@ -283,6 +286,10 @@ $title
border-radius 2px border-radius 2px
border 1px solid #CCC border 1px solid #CCC
color #000 color #000
p + p, p + ul
margin-top -.4em
p + ul
margin-top -.6em
code code
font-size 14px font-size 14px
line-height 20px line-height 20px
@ -295,16 +302,16 @@ $title
.title .title
background: #F9F9F9; background: #F9F9F9;
padding 54px 0 padding 48px 0
h1 h1
margin 0 auto margin 0 auto
@extend $wrapper @extend $wrapper
font-family: 'Raleway'; font-family: 'Raleway';
font-size: 42px; font-size: 40px;
font-weight 200 font-weight 200
color: #585858; color: #585858;
line-height: 49px; line-height: 50px;
.docs .docs
@extend $wrapper @extend $wrapper
@ -356,6 +363,7 @@ $title
.docs-content .docs-content
col(3/4) col(3/4)
margin-top 60px margin-top 60px
margin-bottom 20px
+below(600px) +below(600px)
margin-top 10px margin-top 10px
col(1) col(1)
@ -364,3 +372,8 @@ $title
margin 0 margin 0
@extend $title @extend $title
font-size 32px font-size 32px
.docs-next
float right
color #e05b49
font-weight 400

View File

@ -5,7 +5,7 @@ active_tab: community
description: The biggest GraphQL Community in Python description: The biggest GraphQL Community in Python
--- ---
Graphene is constantly developing thanks to an active volunteer community, There are many different places where you discuss Graphene, share your experiences or ask for help. Your feedback and participation are very welcome! Graphene is constantly developing thanks to an active volunteer community, There are many different places where you discuss Graphene, share your experiences or ask for help. **Your feedback and participation are very welcome**!
If you think working with Graphene is fun, there are many ways you can contribute to it. Please join us in the Slack community and help us shape the next generation APIs. If you think working with Graphene is fun, there are many ways you can contribute to it. Please join us in the Slack community and help us shape the next generation APIs.
@ -21,6 +21,11 @@ Django integration:
- **graphql-django-view**: [Source Code][5] - [PyPI package][6] - **graphql-django-view**: [Source Code][5] - [PyPI package][6]
- **django-graphiql**: [Source Code][7] - [PyPI package][8] - **django-graphiql**: [Source Code][7] - [PyPI package][8]
## Other related projects
- [Flask GraphQL Demo](https://github.com/amitsaha/flask-graphql-demo) by [@echorand](https://twitter.com/echorand)
[Source Code]: https://github.com/graphql-python/graphql-core [Source Code]: https://github.com/graphql-python/graphql-core
[PyPI package]: https://pypi.python.org/pypi/graphql-core [PyPI package]: https://pypi.python.org/pypi/graphql-core
[1]: https://github.com/graphql-python/graphql-relay [1]: https://github.com/graphql-python/graphql-relay

View File

@ -10,31 +10,41 @@ class Template extends React.Component {
render() { render() {
var docs = this.props.config.docs; var docs = this.props.config.docs;
var docs_index = _.indexBy(this.props.pages, 'path'); var docs_index = _.indexBy(this.props.pages, 'path');
return ( var pages = [];
<div className="docs"> var aside_links = Object.keys(docs).map((key) => {
<aside className="docs-aside"> let group = docs[key];
{Object.keys(docs).map((key) => { return <div className="docs-aside-group" key={key}>
let group = docs[key]; <h3>{group.name}</h3>
return <div className="docs-aside-group" key={key}> {group.pages.map((page) => {
<h3>{group.name}</h3> pages.push(page)
{group.pages.map((page) => { return <Link key={page} to={page}>{docs_index[page].data.title}</Link>
return <Link key={page} to={page}>{docs_index[page].data.title}</Link>
})}
</div>;
})} })}
<select className="docs-aside-navselect" onChange={this.goToPage.bind(this)}> </div>;
{Object.keys(docs).map((key) => { });
let group = docs[key]; var aside_options = Object.keys(docs).map((key) => {
return <optgroup key={key} label={group.name}> let group = docs[key];
{group.pages.map((page) => { return <optgroup key={key} label={group.name}>
return <option key={page} value={page}>{docs_index[page].data.title}</option> {group.pages.map((page) => {
})} return <option key={page} value={page}>{docs_index[page].data.title}</option>
</optgroup>; })}
})} </optgroup>;
</select> });
</aside> var next_page_index = pages.indexOf(this.props.page.path)+1;
<div className="docs-content"> var next_page = pages[next_page_index];
<RouteHandler {...this.props} docs={true}/> return (
<div>
<div className="title"><h1>Documentation</h1></div>
<div className="docs">
<aside className="docs-aside">
{aside_links}
<select className="docs-aside-navselect" onChange={this.goToPage.bind(this)}>
{aside_options}
</select>
</aside>
<div className="docs-content">
<RouteHandler {...this.props} docs={true}/>
{next_page?<Link className="docs-next" to={next_page}>Next - {docs_index[next_page].data.title} </Link>:null}
</div>
</div> </div>
</div> </div>
); );

View File

@ -62,29 +62,23 @@ class DateTime(Scalar):
This types if are mounted in a `ObjectType`, `Interface` or `Mutation`, This types if are mounted in a `ObjectType`, `Interface` or `Mutation`,
would act as `Field`s. would act as `Field`s.
So, the following examples will behave exactly the same:
```python ```python
class Person(graphene.ObjectType): class Person(graphene.ObjectType):
name = graphene.String() name = graphene.String()
```
and
```python # Is equivalent to:
class Person(graphene.ObjectType): class Person(graphene.ObjectType):
name = graphene.Field(graphene.String()) name = graphene.Field(graphene.String())
``` ```
## Mounting in Fields ## Mounting in Fields
If this types are mounted in a `Field`, would act as `Argument`s. If the types are mounted in a `Field`, would act as `Argument`s.
So, the following examples will behave exactly the same:
```python ```python
graphene.Field(graphene.String(), to=graphene.String()) graphene.Field(graphene.String(), to=graphene.String())
```
and
```python # Is equivalent to:
graphene.Field(graphene.String(), to=graphene.Argument(graphene.String())) graphene.Field(graphene.String(), to=graphene.Argument(graphene.String()))
``` ```

View File

@ -8,7 +8,7 @@ description: Walkthrough Interfaces
An Interface contains the essential fields that will be shared among multiple ObjectTypes. An Interface contains the essential fields that will be shared among multiple ObjectTypes.
The basics: The basics:
- Each Interface is a Python class that inherits from graphene.Interface. - Each Interface is a Python class that inherits from `graphene.Interface`.
- Each attribute of the Interface represents a GraphQL field. - Each attribute of the Interface represents a GraphQL field.
## Quick example ## Quick example

View File

@ -8,7 +8,7 @@ description: Walkthrough ObjectTypes
An ObjectType is the single, definitive source of information about your data. It contains the essential fields and behaviors of the data youre querying. An ObjectType is the single, definitive source of information about your data. It contains the essential fields and behaviors of the data youre querying.
The basics: The basics:
- Each ObjectType is a Python class that inherits graphene.ObjectType or inherits an implemented [Interface](/docs/interfaces/). - Each ObjectType is a Python class that inherits `graphene.ObjectType` or inherits an implemented [Interface](/docs/interfaces/).
- Each attribute of the ObjectType represents a GraphQL field. - Each attribute of the ObjectType represents a GraphQL field.
## Quick example ## Quick example

View File

@ -1,10 +1,14 @@
--- ---
title: Guide to Django title: Django Tutorial
description: A Quick guide to Graphene in Django description: A Quick guide to Graphene in Django
--- ---
# Django Tutorial
In our previous quickstart page we created a very simple schema. In our previous quickstart page we created a very simple schema.
Now we will adapt the schema to map automatically some Django models.
Now we will adapt the schema to map automatically some Django models,
and expose this schema in a `/graphql` API endpoint.
## Project setup ## Project setup
@ -54,7 +58,7 @@ from graphene.contrib.django import DjangoObjectType
from django.contrib.auth.models import User, Group from django.contrib.auth.models import User, Group
# Graphene will map automaticall the User model to UserType with # Graphene will map automatically the User model to UserType with
# the specified fields # the specified fields
class UserType(DjangoObjectType): class UserType(DjangoObjectType):
class Meta: class Meta:

View File

@ -3,6 +3,8 @@ title: Getting started
description: A Quick guide to Graphene description: A Quick guide to Graphene
--- ---
# Getting started
Let's build a basic GraphQL schema from scratch. Let's build a basic GraphQL schema from scratch.
@ -15,15 +17,6 @@ Let's build a basic GraphQL schema from scratch.
## Project setup ## Project setup
```bash ```bash
# Create the project directory
mkdir tutorial
cd tutorial
# Create a virtualenv to isolate our package dependencies locally
virtualenv env
source env/bin/activate # On Windows use `env\Scripts\activate`
# Install Graphene
pip install graphene pip install graphene
``` ```

View File

@ -3,12 +3,8 @@ path: /
--- ---
<div><a class="starwars-example" href="http://swapi.graphene-python.org/">Check our Django Starwars API example!</a></div> <div><a class="starwars-example" href="http://swapi.graphene-python.org/">Check our Django Starwars API example!</a></div>
## About Graphene ## Meet Graphene
Graphene is a Python library for building GraphQL schemas/types fast and easily. Graphene is a Python library for building GraphQL schemas/types fast and easily.
**What is GraphQL?** A GraphQL query is a string interpreted by a server that returns data in a specified format. **But, what is GraphQL?** A GraphQL query is a string interpreted by a server that returns data in a specified format. We believe *GraphQL* is the next big thing after peanut butter and *REST*.
- **Easy to use:** Graphene helps you use GraphQL in Python without effort.
- **Relay:** Graphene has builtin support for Relay
- **Django:** Automatic *Django model* mapping to Graphene Types.

View File

@ -12,12 +12,14 @@ class Markdown extends React.Component {
var showTitle = post.title && !this.props.docs; var showTitle = post.title && !this.props.docs;
return ( return (
<DocumentTitle title={`${post.title?post.title+' - ':''}${this.props.config.siteTitle}`}> <DocumentTitle title={`${post.title?post.title+' - ':''}${this.props.config.siteTitle}`}>
<div className="markdown"> <div>
{showTitle?<div className="title"> {showTitle?<div className="title">
<h1>{post.title}</h1> <h1>{post.title}</h1>
</div>:null} </div>:null}
<div className={!this.props.docs?"wrapper":null} dangerouslySetInnerHTML={{__html: post.body}}/> <div className="markdown">
<a href={documentUrl} className="improve-document-link">Edit page</a> <div className={!this.props.docs?"wrapper":null} dangerouslySetInnerHTML={{__html: post.body}}/>
<a href={documentUrl} className="improve-document-link">Edit page</a>
</div>
</div> </div>
</DocumentTitle> </DocumentTitle>
); );