Upgrade Slate sample to Slate 1.5

Closes gh-361
This commit is contained in:
Andy Wilkinson
2017-03-04 22:12:09 +00:00
parent 3a0f4ab68e
commit ca86e3ad8c
24 changed files with 10579 additions and 286 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

@@ -0,0 +1,20 @@
# Errors
<aside class="notice">This error section is stored in a separate file in `includes/_errors.md`. Slate allows you to optionally separate out your docs into many files...just save them to the `includes` folder and add them to the top of your `index.md`'s frontmatter. Files are included in the order listed.</aside>
The Kittn API uses the following error codes:
Error Code | Meaning
---------- | -------
400 | Bad Request -- Your request sucks
401 | Unauthorized -- Your API key is wrong
403 | Forbidden -- The kitten requested is hidden for administrators only
404 | Not Found -- The specified kitten could not be found
405 | Method Not Allowed -- You tried to access a kitten with an invalid method
406 | Not Acceptable -- You requested a format that isn't json
410 | Gone -- The kitten requested has been removed from our servers
418 | I'm a teapot
429 | Too Many Requests -- You're requesting too many kittens! Slow down!
500 | Internal Server Error -- We had a problem with our server. Try again later.
503 | Service Unavailable -- We're temporarily offline for maintenance. Please try again later.

View File

@@ -0,0 +1,189 @@
---
title: API Reference
language_tabs:
- shell
- ruby
- python
- javascript
toc_footers:
- <a href='#'>Sign Up for a Developer Key</a>
- <a href='https://github.com/tripit/slate'>Documentation Powered by Slate</a>
includes:
- errors
search: true
---
# Introduction
Welcome to the Kittn API! You can use our API to access Kittn API endpoints, which can get information on various cats, kittens, and breeds in our database.
We have language bindings in Shell, Ruby, and Python! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.
This example API documentation page was created with [Slate](https://github.com/tripit/slate). Feel free to edit it and use it as a base for your own API's documentation.
# Authentication
> To authorize, use this code:
```ruby
require 'kittn'
api = Kittn::APIClient.authorize!('meowmeowmeow')
```
```python
import kittn
api = kittn.authorize('meowmeowmeow')
```
```shell
# With shell, you can just pass the correct header with each request
curl "api_endpoint_here"
-H "Authorization: meowmeowmeow"
```
```javascript
const kittn = require('kittn');
let api = kittn.authorize('meowmeowmeow');
```
> Make sure to replace `meowmeowmeow` with your API key.
Kittn uses API keys to allow access to the API. You can register a new Kittn API key at our [developer portal](http://example.com/developers).
Kittn expects for the API key to be included in all API requests to the server in a header that looks like the following:
`Authorization: meowmeowmeow`
<aside class="notice">
You must replace <code>meowmeowmeow</code> with your personal API key.
</aside>
# Kittens
## Get All Kittens
```ruby
require 'kittn'
api = Kittn::APIClient.authorize!('meowmeowmeow')
api.kittens.get
```
```python
import kittn
api = kittn.authorize('meowmeowmeow')
api.kittens.get()
```
```shell
curl "http://example.com/api/kittens"
-H "Authorization: meowmeowmeow"
```
```javascript
const kittn = require('kittn');
let api = kittn.authorize('meowmeowmeow');
let kittens = api.kittens.get();
```
> The above command returns JSON structured like this:
```json
[
{
"id": 1,
"name": "Fluffums",
"breed": "calico",
"fluffiness": 6,
"cuteness": 7
},
{
"id": 2,
"name": "Max",
"breed": "unknown",
"fluffiness": 5,
"cuteness": 10
}
]
```
This endpoint retrieves all kittens.
### HTTP Request
`GET http://example.com/api/kittens`
### Query Parameters
Parameter | Default | Description
--------- | ------- | -----------
include_cats | false | If set to true, the result will also include cats.
available | true | If set to false, the result will include kittens that have already been adopted.
<aside class="success">
Remember — a happy kitten is an authenticated kitten!
</aside>
## Get a Specific Kitten
```ruby
require 'kittn'
api = Kittn::APIClient.authorize!('meowmeowmeow')
api.kittens.get(2)
```
```python
import kittn
api = kittn.authorize('meowmeowmeow')
api.kittens.get(2)
```
```shell
curl "http://example.com/api/kittens/2"
-H "Authorization: meowmeowmeow"
```
```javascript
const kittn = require('kittn');
let api = kittn.authorize('meowmeowmeow');
let max = api.kittens.get(2);
```
> The above command returns JSON structured like this:
```json
{
"id": 2,
"name": "Max",
"breed": "unknown",
"fluffiness": 5,
"cuteness": 10
}
```
This endpoint retrieves a specific kitten.
<aside class="warning">Inside HTML code blocks like this one, you can't use Markdown, so use <code>&lt;code&gt;</code> blocks to denote code.</aside>
### HTTP Request
`GET http://example.com/kittens/<ID>`
### URL Parameters
Parameter | Description
--------- | -----------
ID | The ID of the kitten to retrieve

View File

@@ -1,3 +1,5 @@
//= require ../lib/_jquery
/*
Copyright 2008-2013 Concur Technologies, Inc.
@@ -28,9 +30,11 @@ under the License.
$(".lang-selector a").removeClass('active');
$(".lang-selector a[data-language-name='" + language + "']").addClass('active');
for (var i=0; i < languages.length; i++) {
$(".highlight." + languages[i]).hide();
$(".highlight.tab-" + languages[i]).hide();
$(".lang-specific." + languages[i]).hide();
}
$(".highlight." + language).show();
$(".highlight.tab-" + language).show();
$(".lang-specific." + language).show();
global.toc.calculateHeights();

View File

@@ -1,4 +1,5 @@
//= require ../lib/_lunr
//= require ../lib/_jquery
//= require ../lib/_jquery.highlight
(function () {
'use strict';

View File

@@ -1,3 +1,4 @@
//= require ../lib/_jquery
//= require ../lib/_jquery_ui
//= require ../lib/_jquery.tocify
//= require ../lib/_imagesloaded.min
@@ -47,6 +48,7 @@
$(function() {
makeToc();
animate();
setupLanguages($('body').data('languages'));
$('.content').imagesLoaded( function() {
global.toc.calculateHeights();
});

File diff suppressed because it is too large Load Diff

View File

@@ -13,7 +13,7 @@ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
%>
<% language_tabs = current_page.data.language_tabs %>
<% language_tabs = current_page.data.language_tabs || [] %>
<!doctype html>
<html>
<head>
@@ -22,25 +22,19 @@ under the License.
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title><%= current_page.data.title || "API Documentation" %></title>
<style>
<%= Rouge::Themes::MonokaiSublime.render(:scope => '.highlight') %>
</style>
<%= stylesheet_link_tag :screen, media: :screen %>
<%= stylesheet_link_tag :print, media: :print %>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<% if current_page.data.search %>
<%= javascript_include_tag "all" %>
<% else %>
<%= javascript_include_tag "all_nosearch" %>
<% end %>
<% if language_tabs %>
<script>
$(function() {
setupLanguages(<%= language_tabs.map{ |lang| lang.is_a?(Hash) ? lang.keys.first : lang }.to_json %>);
});
</script>
<% end %>
</head>
<body class="<%= page_classes %>">
<body class="<%= page_classes %>" data-languages="<%=h language_tabs.map{ |lang| lang.is_a?(Hash) ? lang.keys.first : lang }.to_json %>">
<a href="#" id="nav-button">
<span>
NAV
@@ -49,7 +43,7 @@ under the License.
</a>
<div class="tocify-wrapper">
<%= image_tag "logo.png" %>
<% if language_tabs %>
<% if language_tabs.any? %>
<div class="lang-selector">
<% language_tabs.each do |lang| %>
<% if lang.is_a? Hash %>
@@ -85,7 +79,7 @@ under the License.
<% end %>
</div>
<div class="dark-box">
<% if language_tabs %>
<% if language_tabs.any? %>
<div class="lang-selector">
<% language_tabs.each do |lang| %>
<% if lang.is_a? Hash %>

View File

@@ -1,27 +0,0 @@
/*
Copyright 2008-2013 Concur Technologies, Inc.
Licensed under the Apache License, Version 2.0 (the "License"); you may
not use this file except in compliance with the License. You may obtain
a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
*/
@import 'variables';
<%= Rouge::Themes::Base16::Monokai.render(:scope => '.highlight') %>
.highlight .c, .highlight .cm, .highlight .c1, .highlight .cs {
color: #909090;
}
.highlight, .highlight .w {
background-color: $code-bg;
}

View File

@@ -23,46 +23,46 @@ under the License.
// BACKGROUND COLORS
////////////////////
$nav-bg: #393939;
$examples-bg: #393939;
$code-bg: #292929;
$code-annotation-bg: #1c1c1c;
$nav-subitem-bg: #262626;
$nav-active-bg: #2467af;
$lang-select-border: #000;
$lang-select-bg: #222;
$lang-select-active-bg: $examples-bg; // feel free to change this to blue or something
$lang-select-pressed-bg: #111; // color of language tab bg when mouse is pressed
$main-bg: #eaf2f6;
$aside-notice-bg: #8fbcd4;
$aside-warning-bg: #c97a7e;
$aside-success-bg: #6ac174;
$search-notice-bg: #c97a7e;
$nav-bg: #393939 !default;
$examples-bg: #393939 !default;
$code-bg: #292929 !default;
$code-annotation-bg: #1c1c1c !default;
$nav-subitem-bg: #262626 !default;
$nav-active-bg: #2467af !default;
$lang-select-border: #000 !default;
$lang-select-bg: #222 !default;
$lang-select-active-bg: $examples-bg !default; // feel free to change this to blue or something
$lang-select-pressed-bg: #111 !default; // color of language tab bg when mouse is pressed
$main-bg: #eaf2f6 !default;
$aside-notice-bg: #8fbcd4 !default;
$aside-warning-bg: #c97a7e !default;
$aside-success-bg: #6ac174 !default;
$search-notice-bg: #c97a7e !default;
// TEXT COLORS
////////////////////
$main-text: #333; // main content text color
$nav-text: #fff;
$nav-active-text: #fff;
$lang-select-text: #fff; // color of unselected language tab text
$lang-select-active-text: #fff; // color of selected language tab text
$lang-select-pressed-text: #fff; // color of language tab text when mouse is pressed
$main-text: #333 !default; // main content text color
$nav-text: #fff !default;
$nav-active-text: #fff !default;
$lang-select-text: #fff !default; // color of unselected language tab text
$lang-select-active-text: #fff !default; // color of selected language tab text
$lang-select-pressed-text: #fff !default; // color of language tab text when mouse is pressed
// SIZES
////////////////////
$nav-width: 230px; // width of the navbar
$examples-width: 50%; // portion of the screen taken up by code examples
$logo-margin: 20px; // margin between nav items and logo, ignored if search is active
$main-padding: 28px; // padding to left and right of content & examples
$nav-padding: 15px; // padding to left and right of navbar
$nav-v-padding: 10px; // padding used vertically around search boxes and results
$nav-indent: 10px; // extra padding for ToC subitems
$code-annotation-padding: 13px; // padding inside code annotations
$h1-margin-bottom: 21px; // padding under the largest header tags
$tablet-width: 930px; // min width before reverting to tablet size
$phone-width: $tablet-width - $nav-width; // min width before reverting to mobile size
$nav-width: 230px !default; // width of the navbar
$examples-width: 50% !default; // portion of the screen taken up by code examples
$logo-margin: 20px !default; // margin between nav items and logo, ignored if search is active
$main-padding: 28px !default; // padding to left and right of content & examples
$nav-padding: 15px !default; // padding to left and right of navbar
$nav-v-padding: 10px !default; // padding used vertically around search boxes and results
$nav-indent: 10px !default; // extra padding for ToC subitems
$code-annotation-padding: 13px !default; // padding inside code annotations
$h1-margin-bottom: 21px !default; // padding under the largest header tags
$tablet-width: 930px !default; // min width before reverting to tablet size
$phone-width: $tablet-width - $nav-width !default; // min width before reverting to mobile size
// FONTS
@@ -86,12 +86,12 @@ $phone-width: $tablet-width - $nav-width; // min width before reverting to mobil
// OTHER
////////////////////
$nav-active-shadow: #000;
$nav-footer-border-color: #666;
$nav-embossed-border-top: #000;
$nav-embossed-border-bottom: #939393;
$main-embossed-text-shadow: 0px 1px 0px #fff;
$search-box-border-color: #666;
$nav-active-shadow: #000 !default;
$nav-footer-border-color: #666 !default;
$nav-embossed-border-top: #000 !default;
$nav-embossed-border-bottom: #939393 !default;
$main-embossed-text-shadow: 0px 1px 0px #fff !default;
$search-box-border-color: #666 !default;
////////////////////////////////////////////////////////////////////////////////
@@ -100,10 +100,6 @@ $search-box-border-color: #666;
// These settings are probably best left alone.
%break-words {
word-break: break-all;
/* Non standard for webkit */
word-break: break-word;
hyphens: auto;
word-break: break-all;
hyphens: auto;
}

View File

@@ -1,6 +1,5 @@
@charset "utf-8";
@import 'normalize';
@import 'compass';
@import 'variables';
@import 'icon-font';
@@ -48,6 +47,12 @@ body {
font-size: 0.8em;
}
pre {
code {
border: 0;
}
}
pre {
padding: 1.3em;
}

View File

@@ -1,8 +1,6 @@
@charset "utf-8";
@import 'normalize';
@import 'compass';
@import 'variables';
@import 'syntax';
@import 'icon-font';
/*
@@ -84,6 +82,7 @@ html, body {
// This is the logo at the top of the ToC
&>img {
display: block;
max-width: 100%;
}
&>.search {
@@ -111,7 +110,7 @@ html, body {
}
}
img+.tocify {
img+.tocify, .lang-selector+.tocify {
margin-top: $logo-margin;
}
@@ -340,7 +339,7 @@ html, body {
padding: 0 $main-padding;
box-sizing: border-box;
display: block;
@include text-shadow($main-embossed-text-shadow);
text-shadow: $main-embossed-text-shadow;
@extend %left-col;
}
@@ -471,7 +470,7 @@ html, body {
aside {
padding-top: 1em;
padding-bottom: 1em;
@include text-shadow(0 1px 0 lighten($aside-notice-bg, 15%));
text-shadow: 0 1px 0 lighten($aside-notice-bg, 15%);
margin-top: 1.5em;
margin-bottom: 1.5em;
background: $aside-notice-bg;
@@ -479,12 +478,12 @@ html, body {
&.warning {
background-color: $aside-warning-bg;
@include text-shadow(0 1px 0 lighten($aside-warning-bg, 15%));
text-shadow: 0 1px 0 lighten($aside-warning-bg, 15%);
}
&.success {
background-color: $aside-success-bg;
@include text-shadow(0 1px 0 lighten($aside-success-bg, 15%));
text-shadow: 0 1px 0 lighten($aside-success-bg, 15%);
}
}
@@ -511,7 +510,7 @@ html, body {
margin: -2px;
border-radius: 4px;
border: 1px solid #F7E633;
@include text-shadow(1px 1px 0 #666);
text-shadow: 1px 1px 0 #666;
background: linear-gradient(to top left, #F7E633 0%, #F1D32F 100%);
}
}
@@ -534,7 +533,7 @@ html, body {
clear:right;
box-sizing: border-box;
@include text-shadow(0px 1px 2px rgba(0,0,0,0.4));
text-shadow: 0px 1px 2px rgba(0,0,0,0.4);
@extend %right-col;
@@ -618,3 +617,11 @@ html, body {
margin-top: $main-padding;
}
}
.highlight .c, .highlight .cm, .highlight .c1, .highlight .cs {
color: #909090;
}
.highlight, .highlight .w {
background-color: $code-bg;
}