Documenting Your Waxx App

Waxx has some nice documentation features built in to allow you to document your app.

You can view the docs for your app by viewing localhost:7777/waxx/desc.yaml or localhost:7777/waxx/desc.json

When you define a runs handler, the desc attribute will be included and the request method handlers and the corresponding arguments are included in the docs. ] For example, given a object definition like:

module App::Blog
  extend Waxx::Object

  runs(
    default: 'latest',
    latest: {
      desc: 'Show the 10 most recent blog posts. Optionally pass in a tag.',
      get: -> (x, tag=nil) {
        List.run(x, args: {tag: tag})
      }
    }
  )
end

Describe the app by calling https://example.com/waxx/desc/blog.yaml and the result will be:

---
blog:
  default: latest
  latest:
    desc: Show the 10 most recent blog posts. Optionally pass in a tag.
    get:
      x: req,
      tag: opt

Here is the output without specifying an app:

---
app_error:
  request:
    desc: Display a request error (400)
    get:
      x: req
      title: req
      message: opt
contact:
  default: us
  us:
    desc: Contact Us Form
    get:
      x: opt
      args: rest
    post:
      x: opt
      args: rest
content:
  default: :list
  record:
    desc: View, create, and edit a record
    acl: admin
    get:
      x: req
      id: req
      args: rest
    post:
      x: req
      id: req
      args: rest
  list:
    desc: View a list of content
    acl: admin
    get:
      x: req
      args: rest
email:
  send:
    desc: Send any emails that need to be sent
    get:
      x: req
      key: req
person:
  record:
    desc: View a person record
    run:
      x: opt
      person_id: opt
      args: rest
  update:
    desc: View a person record
    run:
      x: opt
      person_id: opt
      args: rest
  list:
    desc: View a person list
    run:
      x: opt
      args: rest
  create:
    desc: Create a person
    run:
      x: opt
      args: rest
  profile:
    desc: Edit profile
    acl: user
    run:
      x: req
      id: opt
  options:
    desc: The Person's Options
    acl: user
    get:
      x: req
  available:
    desc: Set the person's availability for a shift
    acl: user
    put:
      x: req
      person_id: opt
usr:
  default: list
  home:
    desc: The home page of a logged in usr
    acl: admin
    get:
      x: opt
      args: rest
  list:
    desc: List users
    acl:
    - admin
    get:
      x: req
  record:
    desc: Edit a usr record
    acl:
    - admin
    get:
      x: req
      id: req
      args: rest
    post:
      x: req
      id: req
      args: rest
  signup:
    desc: Create a usr account
    get:
      x: opt
      args: rest
    post:
      x: opt
      args: rest
  signin:
    desc: Login
    get:
      x: req
      args: rest
    post:
      x: req
      args: rest
  signout:
    desc: Logout of the app
    get:
      x: opt
  password_reset:
    desc: Send the user a password reset link.
    acl: not-used-in-this-app
    post:
      x: opt
      args: rest
  password:
    desc: Form to select a new password
    acl: not-used-in-this-app
    get:
      x: req
      id: opt
      key: opt
      args: rest
    post:
      x: req
      id: opt
      key: opt
      args: rest
  activate:
    desc: The user activates their account with a link
    get:
      x: req
      id: req
      key: req
website:
  default: page
  home:
    desc: Show the home page
    get:
      x: opt
      args: rest
    head:
      x: opt
      args: rest
  page:
    desc: View a website_page
    get:
      x: opt
      args: rest
  search:
    desc: View search results
    get:
      x: opt
      args: rest
website_page:
  default: list
  list:
    desc: List pages
    acl: admin
    get:
      x: opt
      id: opt
      args: rest
  record:
    desc: View, create, edit record
    acl: admin
    get:
      x: opt
      id: opt
      args: rest
    post:
      x: opt
      id: opt
      args: rest
waxx:
  ok:
    desc: Ping the app database to see if it is ok
    get:
      x: req
  sleep:
    desc: Sleep for seconds in args
    acl:
    - user
    run:
      x: req
      secs: opt
  error:
    desc: Raise an Error
    run:
      x: req
      args: rest
  env:
    desc: Output all the input variables
    run:
      x: req
      args: rest
  raw:
    desc: Output all the input variables
    run:
      x: req
      args: rest
  private:
    desc: A private page that requires login
    acl:
    - user
    run:
      x: req
  desc:
    desc: Describes all of the applications interfaces.
    acl: user
    get:
      x: req
      app: opt
  threads:
    desc: Show the status of all threads
    get:
      x: req
  params:
    desc: Golf demo
    get:
      x: req
    post:
      x: req
doc:
  default: not_found
  not_found:
    desc: Show the doc main page
    get:
      x: req
      args: rest

Given output like this you can easily parse the results to autodiscover functionality or audit for access control.