Home

Awesome

DociQL

npm downloads builds coverage Quality Gate Status

A nice fork of Spectacle

DociQL generates beautiful static HTML5 documentation from a GraphQL endpoint using the introspection query.

The goal of DociQL is help you "save time and look good" by providing an extensible platform for auto generating your API documentation. The default layout is a three column single page, similar to those employed by Stripe and Intercom.

See a demo of DociQL in action here: https://wayfair.github.io/dociql/


Demo Screenshot


Features

Usage

Install DociQL from npm:

npm install -g dociql

Define config.yml template to help generate beautiful docs:

# To fetch schema from
introspection: https://url-to-you-graphql-endpoint

servers: # same format as for OpenAPI Specification
  - url: https://dev-server.com
    description: Dev
  - url: https://prod-server.com
    description: Prod
    ...

info: # same format as for OpenAPI Specification
    title: Your API Title
    description: Markdown enabled description of your api.    
    ...

 # define your domains by providing a set of usecases
domains:
  - name: Top Level Menu Section # Name of the domain
    description: Description  # Description of the domain
    usecases:         
     - name: Fetch 'Some' field # Operation name
       description: Markdown enabled description for operation # Opearation description
       query: query.some # Query example - fetching single field
       select: field1 field2 # select only specific sub fields. By default - all are selected
       expand: field3(sub1, sub2, sub3),field4 # go deep by expanding specific fields.
     - name: Invoke Mutation # Mutation 
       description: Markdown enabled description for operation
       query: mutation.mutateSome # Mutation example - invoke mutation

Pass your config.yml document to generate your documentation:

dociql -d config.yml

Your generated documentation will be located in the public directory by default. You can either copy the generated HTML to your web server, or view your docs by pointing your browser to http://localhost:4400/.

Docker

Coming soon!

Configuration Options

The basic CLI options are detailed below:

$ dociql -h

  Usage: dociql [options] <dociql.yaml>

  Options:

    -h, --help                   output usage information
    -H, --header                 specify a custom auth token for the header (default: none)
    -V, --version                output the version number
    -C, --disable-css            omit CSS generation (default: false)
    -J, --disable-js             omit JavaScript generation (default: false)
    -e, --embeddable             omit the HTML <body/> and generate the documentation content only (default: false)
    -d, --development-mode       start HTTP server with the file watcher (default: false)
    -D, --development-mode-live  start HTTP server with the file watcher and live reload (default: false)
    -s, --start-server           start the HTTP server without any development features
    -p, --port <port>            the port number for the HTTP server to listen on (default: 4400)
    -P, --port-live <port>       the port number for the live reload to listen on (default: 4401)
    -t, --target-dir <dir>       the target build directory (default: public)
    -f, --target-file <file>     the target build HTML file (default: index.html)
    -a, --app-dir <dir>          the application source directory (default: app)
    -l, --logo-file <file>       specify a custom logo file (default: null)
    -1, --one-file               embed all resources (CSS and JS) into the same file (default: false)
    -u, --introspection-url <url>              specify a custom url to use for introspection (default: none)
    -c, --config-file <file>     specify a custom configuration file (default: app/lib/config.js)

Most options are self explanatory, but the following options warrant some further explanation:

Custom Builds

The best option for building your own custom functionality into DociQL is to fork DociQL on GitHub and make your own modifications in the source. This way, you can keep up-to-date by merging changes from the master branch and you can also contribute your updates back to master by creating a Pull Request, especially if you think they'll be an improvement for DociQL.

To fork DociQL go to https://github.com/wayfair/dociql and press the 'Fork' button. Now you can git clone git@github.com:<yourname>/dociql.git to make your own changes.

Alternatively, you can just copy the contents of app from the main repo which contains all of the source files such as templates, stylesheets, and JavaScripts. Now, just pass the path from your custom app path to the CLI like so: dociql -a dociql.json.

Optimizing Your Workflow

Using an API spec to generate your documentation has a number of great advantages, such as:

Development

Testing

Coming soon!

Testing is powered by Mocha/Chai and automated testing is run via CircleCI.

At this stage, unit tests have not been written for all parts of the codebase. However, new code should be tested, and unit tests for the existing code will be added in the future.

Run npm test on the repository to start the automated tests. Some parts of testing can be configured using environment variables.

Include environment variables before calling npm test. For example, OFFLINE mode can be enabled via OFFLINE=true npm test.

<!-- ## Contributors Thanks to all the great developers who make DociQL great! TODO -->

License

DociQL is licensed under the Apache License 2.0 – see the LICENSE.md for specific details.

More Information

More info is available on the DociQL homepage.

Please use the GitHub issue tracker if you have any ideas or bugs to report.

All contributions are welcome.

Good luck and enjoy DociQL!