Skip to content

Instantly share code, notes, and snippets.

@freezy
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save freezy/a291cec82d3c1aab784c to your computer and use it in GitHub Desktop.

Select an option

Save freezy/a291cec82d3c1aab784c to your computer and use it in GitHub Desktop.

Revisions

  1. freezy revised this gist Jun 3, 2014. 2 changed files with 162 additions and 147 deletions.
    229 changes: 124 additions & 105 deletions resource.jade
    Original file line number Diff line number Diff line change
    @@ -1,83 +1,57 @@
    - if (!resource) resource = mainResource;
    .panel.panel-white
    .panel-heading
    h4.panel-title
    a.block.collapsed(data-toggle='collapse', href='#panel_#{resource.uniqueId}')
    each method in resource.methods
    span.badge(class="badge_#{method.method}") #{method.method} #{helpers.lock(method.securedBy)}
    span.parent=resource.parentUrl
    | #{resource.relativeUri}
    .panel-collapse.collapse(id='panel_#{resource.uniqueId}')
    .panel-body
    .list-group
    each method in resource.methods
    a.list-group-item(href='#', data-toggle='modal', data-target='##{resource.uniqueId}_#{method.method}')
    span.badge(class='badge_#{method.method}') #{method.method} #{helpers.lock(method.securedBy)}
    span=resource.description
    mixin resource(resource)
    .panel.panel-white
    .panel-heading
    h4.panel-title
    a.block.collapsed(data-toggle='collapse', href='#panel_#{resource.uniqueId}')
    if resource.methods
    each method in resource.methods
    span.badge(id='#{method.method}_#{resource.uniqueId}', class="badge_#{method.method}") #{method.method} #{helpers.lock(method.securedBy)}
    span.parent=resource.parentUrl
    | #{resource.relativeUri}
    .panel-collapse.collapse(id='panel_#{resource.uniqueId}')
    .panel-body
    .list-group
    if resource.methods
    each method in resource.methods
    a.list-group-item(href='#', data-toggle='modal', data-target='##{resource.uniqueId}_#{method.method}')
    span.badge(class='badge_#{method.method}') #{method.method} #{helpers.lock(method.securedBy)}
    span!=helpers.md(resource.description)

    each method in resource.methods
    .modal.fade(id='#{resource.uniqueId}_#{method.method}')
    .modal-dialog
    .modal-content
    .modal-header
    button.close(type='button', data-dismiss='modal', aria-hidden='true') ×
    h4.modal-title
    span.badge(class='badge_#{method.method}') #{method.method} #{helpers.lock(method.securedBy)}
    span.parent=resource.parentUrl
    | #{resource.relativeUri}
    .modal-body
    .alert.alert-info!=helpers.md(method.description)
    if resource.methods
    each method in resource.methods
    .modal.fade(id='#{resource.uniqueId}_#{method.method}')
    .modal-dialog
    .modal-content
    .modal-header
    button.close(type='button', data-dismiss='modal', aria-hidden='true') ×
    h4.modal-title
    span.badge(class='badge_#{method.method}') #{method.method} #{helpers.lock(method.securedBy)}
    span.parent=resource.parentUrl
    | #{resource.relativeUri}
    .modal-body
    .alert.alert-info!=helpers.md(method.description)

    // Nav tabs
    ul.nav.nav-tabs
    li.active: a(href='##{resource.uniqueId}_#{method.method}_request', data-toggle='tab') Request
    if method.responses
    li: a(href='##{resource.uniqueId}_#{method.method}_response', data-toggle='tab') Response
    // Nav tabs
    ul.nav.nav-tabs
    li.active: a(href='##{resource.uniqueId}_#{method.method}_request', data-toggle='tab') Request
    if method.responses
    li: a(href='##{resource.uniqueId}_#{method.method}_response', data-toggle='tab') Response

    // Tab panes
    .tab-content
    .tab-pane.active(id='#{resource.uniqueId}_#{method.method}_request')
    if resource.allUriParameters
    h3 URI Parameters
    ul
    each param in resource.allUriParameters
    li: strong=param.displayName
    | #{param.type}

    if method.queryParameters
    h3 Query Parameters
    ul
    each param, key in method.queryParameters
    li
    strong=key
    em
    if param.required
    | required
    if param.enum
    | one of (#{param.enum})
    else
    | (#{param.type})

    | !{helpers.md(param.description)}
    if param.schema
    p: small
    strong Schema:
    code!=param.schema

    if param.example
    p: small
    strong Example:
    code!=param.example
    // Tab panes
    .tab-content
    .tab-pane.active(id='#{resource.uniqueId}_#{method.method}_request')
    if resource.allUriParameters
    h3 URI Parameters
    ul
    each param in resource.allUriParameters
    li: strong=param.displayName
    | #{param.type}

    if method.body
    h3 Body
    each b, key in method.body
    p: strong Type: #{key}
    if formParameters
    strong Form Parameters
    if method.queryParameters
    h3 Query Parameters
    ul
    each param in formParameters
    li
    each param, key in method.queryParameters
    li.markdown
    strong=key
    em
    if param.required
    @@ -86,44 +60,89 @@
    | one of (#{param.enum})
    else
    | (#{param.type})
    | !{helpers.md(description)}

    | !{helpers.md(param.description)}
    if param.schema
    p:small
    p: small
    strong Schema:
    code!=param.schema

    if param.example
    p: small
    strong Example:
    code!=param.example
    if b.schema
    strong Schema:
    pre!=helpers.highlight(b.schema)

    if b.example
    strong Example:
    pre!=helpers.highlight(b.example)

    if method.responses
    .tab-pane(id='#{resource.uniqueId}_#{method.method}_response')
    each response, key in method.responses
    h2 HTTP status code 
    a(href='http://httpstatus.es/#{key}', target='_blank')=key
    | !{helpers.md(response.description)}

    if response.headers
    if method.headers
    h3 Headers
    ul
    each header, headername in headers
    li: strong=headername
    | : #{header.type}
    if response.body
    each header, headername in method.headers
    li.markdown
    strong=(header.displayName ? header.displayName : headername)
    em
    if header.required
    | required
    if header.enum
    | one of (#{header.enum})
    else
    | (#{header.type})
    if header.description
    | !{helpers.md(header.description)}

    if method.body
    h3 Body
    each rb, contentType in response.body
    p
    strong Type: #{contentType}
    if rb && rb.schema
    strong Schema:
    pre!=helpers.highlight(rb.schema)
    if tb && rb.example
    strong Example:
    pre!=helpers.highlight(rb.example)
    each b, key in method.body
    p: strong Type: #{key}
    if formParameters
    strong Form Parameters
    ul
    each param in formParameters
    li.markdown
    strong=key
    em
    if param.required
    | required
    if param.enum
    | one of (#{param.enum})
    else
    | (#{param.type})
    | !{helpers.md(description)}
    if param.schema
    p:small
    strong Schema:
    code!=param.schema
    if param.example
    p: small
    strong Example:
    code!=param.example
    if b.schema
    strong Schema:
    pre!=helpers.highlight(b.schema)

    if b.example
    strong Example:
    pre!=helpers.highlight(b.example)

    if method.responses
    .tab-pane(id='#{resource.uniqueId}_#{method.method}_response')
    each response, key in method.responses
    h2 HTTP status code 
    a(href='http://httpstatus.es/#{key}', target='_blank')=key
    | !{helpers.md(response.description)}

    if response.headers
    h3 Headers
    ul
    each header, headername in response.headers
    li: strong=headername
    | : #{header.type}
    if response.body
    h3 Body
    each rb, contentType in response.body
    p
    strong Type: #{contentType}
    if rb && rb.schema
    strong Schema:
    pre!=helpers.highlight(rb.schema)
    if tb && rb.example
    strong Example:
    pre!=helpers.highlight(rb.example)
    80 changes: 38 additions & 42 deletions template.jade
    Original file line number Diff line number Diff line change
    @@ -1,44 +1,40 @@
    doctype html
    html
    head
    title #{title} API documentation
    meta(http-equiv='X-UA-Compatible', content='IE=edge')
    meta(http-equiv='Content-Type', content='text/html; charset=utf-8')
    link(rel="stylesheet", href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css")
    link(rel="stylesheet", href="http://yandex.st/highlightjs/8.0/styles/github.min.css")
    link(rel="stylesheet", href="/css/raml.css")
    script(type="text/javascript", src="http://code.jquery.com/jquery-1.11.0.min.js")
    script(type="text/javascript", src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js")
    body(data-spy='scroll', data-target='#sidebar')
    .container
    .row
    .col-md-9(role='main')
    .page-header
    h1
    | #{title} API documentation
    if version
    |  
    small version #{version}
    p=baseUri
    each doc in documentation
    h3=doc.title
    div=doc.content
    include resource.jade

    each mainResource in resources
    .panel.panel-default
    .panel-heading
    h3.panel-title(id=mainResource.uniqueId)=mainResource.displayName ? mainResource.displayName : mainResource.relativeUri
    .panel-body
    if mainResource.description
    .resource-description!=helpers.md(mainResource.description)
    .panel-group
    include resource.jade
    each resource in mainResource.resources
    include resource.jade
    .col-md-3
    #sidebar.hidden-print.affix(role='complementary')
    ul.nav.nav-pills.nav-stacked
    each resource in resources
    li
    a(href='##{resource.uniqueId}')=resource.displayName ? resource.displayName : resource.relativeUri
    extends ../layout

    block body
    .page-header
    h1
    | #{title} API documentation
    if version
    |  
    small version #{version}
    p=baseUri
    if documentation
    each doc in documentation
    h3=doc.title
    div=doc.content

    each mainResource in resources
    .panel.panel-default
    .panel-heading
    h3.panel-title(id=mainResource.uniqueId)=mainResource.displayName ? mainResource.displayName : mainResource.relativeUri
    .panel-body
    if mainResource.description
    .resource-description!=helpers.md(mainResource.description)
    .panel-group
    +resource(mainResource)
    if mainResource.resources
    each resource in mainResource.resources
    +resource(resource)

    block menu

    #sidebar.hidden-print.affix(role='complementary')
    h1 Resources
    hr
    ul.nav.nav-pills.nav-stacked
    each resource in resources
    li
    a(href='##{resource.uniqueId}')=resource.displayName ? resource.displayName : resource.relativeUri

  2. freezy revised this gist Jun 2, 2014. No changes.
  3. freezy created this gist Jun 2, 2014.
    85 changes: 85 additions & 0 deletions raml.css
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,85 @@
    .parent {
    color: #999;
    }
    .list-group-item > .badge {
    float: none;
    margin-right: 6px;
    }
    .panel-title > .block > .badge {
    float: right;
    margin-left: 5px;
    }
    .badge {
    border-radius: 0;
    text-transform: uppercase;
    width: 70px;
    font-weight: normal;
    color: #f3f3f6;
    line-height: normal;
    margin-right: 5px;
    }
    .block .badge {
    visibility: hidden;
    }
    .block.collapsed .badge {
    visibility: visible;
    }
    .badge_get {
    background-color: #63a8e2;
    }
    .badge_post {
    background-color: #6cbd7d;
    }
    .badge_put {
    background-color: #22bac4;
    }
    .badge_delete {
    background-color: #d26460;
    }
    .block {
    display: block;
    }
    .list-group, .panel-group {
    margin-bottom: 0;
    }
    .panel-group .panel+.panel-white {
    margin-top: 0;
    }
    .panel-group .panel-white {
    border-bottom: 1px solid #F5F5F5;
    border-radius: 0;
    }
    .panel-white:last-child {
    border-bottom-color: white;
    -webkit-box-shadow: none;
    box-shadow: none;
    }
    .panel-white .panel-heading {
    background: white;
    }
    .tab-pane ul {
    padding-left: 2em;
    }
    .tab-pane h2 {
    font-size: 1.2em;
    padding-bottom: 4px;
    border-bottom: 1px solid #ddd;
    }
    .tab-pane h3 {
    font-size: 1.1em;
    }
    .tab-content {
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    padding: 10px;
    }
    #sidebar {
    margin-top: 30px;
    }
    .resource-description {
    border-bottom: 1px solid #ddd;
    background: #fcfcfc;
    padding: 15px 15px 0 15px;
    margin: -15px -15px 10px -15px;
    }
    129 changes: 129 additions & 0 deletions resource.jade
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,129 @@
    - if (!resource) resource = mainResource;
    .panel.panel-white
    .panel-heading
    h4.panel-title
    a.block.collapsed(data-toggle='collapse', href='#panel_#{resource.uniqueId}')
    each method in resource.methods
    span.badge(class="badge_#{method.method}") #{method.method} #{helpers.lock(method.securedBy)}
    span.parent=resource.parentUrl
    | #{resource.relativeUri}
    .panel-collapse.collapse(id='panel_#{resource.uniqueId}')
    .panel-body
    .list-group
    each method in resource.methods
    a.list-group-item(href='#', data-toggle='modal', data-target='##{resource.uniqueId}_#{method.method}')
    span.badge(class='badge_#{method.method}') #{method.method} #{helpers.lock(method.securedBy)}
    span=resource.description

    each method in resource.methods
    .modal.fade(id='#{resource.uniqueId}_#{method.method}')
    .modal-dialog
    .modal-content
    .modal-header
    button.close(type='button', data-dismiss='modal', aria-hidden='true') ×
    h4.modal-title
    span.badge(class='badge_#{method.method}') #{method.method} #{helpers.lock(method.securedBy)}
    span.parent=resource.parentUrl
    | #{resource.relativeUri}
    .modal-body
    .alert.alert-info!=helpers.md(method.description)

    // Nav tabs
    ul.nav.nav-tabs
    li.active: a(href='##{resource.uniqueId}_#{method.method}_request', data-toggle='tab') Request
    if method.responses
    li: a(href='##{resource.uniqueId}_#{method.method}_response', data-toggle='tab') Response

    // Tab panes
    .tab-content
    .tab-pane.active(id='#{resource.uniqueId}_#{method.method}_request')
    if resource.allUriParameters
    h3 URI Parameters
    ul
    each param in resource.allUriParameters
    li: strong=param.displayName
    | #{param.type}

    if method.queryParameters
    h3 Query Parameters
    ul
    each param, key in method.queryParameters
    li
    strong=key
    em
    if param.required
    | required
    if param.enum
    | one of (#{param.enum})
    else
    | (#{param.type})

    | !{helpers.md(param.description)}
    if param.schema
    p: small
    strong Schema:
    code!=param.schema

    if param.example
    p: small
    strong Example:
    code!=param.example

    if method.body
    h3 Body
    each b, key in method.body
    p: strong Type: #{key}
    if formParameters
    strong Form Parameters
    ul
    each param in formParameters
    li
    strong=key
    em
    if param.required
    | required
    if param.enum
    | one of (#{param.enum})
    else
    | (#{param.type})
    | !{helpers.md(description)}
    if param.schema
    p:small
    strong Schema:
    code!=param.schema
    if param.example
    p: small
    strong Example:
    code!=param.example
    if b.schema
    strong Schema:
    pre!=helpers.highlight(b.schema)

    if b.example
    strong Example:
    pre!=helpers.highlight(b.example)

    if method.responses
    .tab-pane(id='#{resource.uniqueId}_#{method.method}_response')
    each response, key in method.responses
    h2 HTTP status code 
    a(href='http://httpstatus.es/#{key}', target='_blank')=key
    | !{helpers.md(response.description)}

    if response.headers
    h3 Headers
    ul
    each header, headername in headers
    li: strong=headername
    | : #{header.type}
    if response.body
    h3 Body
    each rb, contentType in response.body
    p
    strong Type: #{contentType}
    if rb && rb.schema
    strong Schema:
    pre!=helpers.highlight(rb.schema)
    if tb && rb.example
    strong Example:
    pre!=helpers.highlight(rb.example)
    44 changes: 44 additions & 0 deletions template.jade
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,44 @@
    doctype html
    html
    head
    title #{title} API documentation
    meta(http-equiv='X-UA-Compatible', content='IE=edge')
    meta(http-equiv='Content-Type', content='text/html; charset=utf-8')
    link(rel="stylesheet", href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css")
    link(rel="stylesheet", href="http://yandex.st/highlightjs/8.0/styles/github.min.css")
    link(rel="stylesheet", href="/css/raml.css")
    script(type="text/javascript", src="http://code.jquery.com/jquery-1.11.0.min.js")
    script(type="text/javascript", src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js")
    body(data-spy='scroll', data-target='#sidebar')
    .container
    .row
    .col-md-9(role='main')
    .page-header
    h1
    | #{title} API documentation
    if version
    |  
    small version #{version}
    p=baseUri
    each doc in documentation
    h3=doc.title
    div=doc.content

    each mainResource in resources
    .panel.panel-default
    .panel-heading
    h3.panel-title(id=mainResource.uniqueId)=mainResource.displayName ? mainResource.displayName : mainResource.relativeUri
    .panel-body
    if mainResource.description
    .resource-description!=helpers.md(mainResource.description)
    .panel-group
    include resource.jade
    each resource in mainResource.resources
    include resource.jade
    .col-md-3
    #sidebar.hidden-print.affix(role='complementary')
    ul.nav.nav-pills.nav-stacked
    each resource in resources
    li
    a(href='##{resource.uniqueId}')=resource.displayName ? resource.displayName : resource.relativeUri