mirror of
https://github.com/danbulant/api_docs
synced 2026-05-24 12:27:29 +00:00
Add multiple-tabs-per-language test
This commit is contained in:
parent
4352bd9f0c
commit
1fd867c2ff
4 changed files with 34 additions and 6 deletions
|
|
@ -17,6 +17,9 @@ set :fonts_dir, 'fonts'
|
||||||
|
|
||||||
# Activate the syntax highlighter
|
# Activate the syntax highlighter
|
||||||
activate :syntax
|
activate :syntax
|
||||||
|
ready do
|
||||||
|
require './lib/multilang.rb'
|
||||||
|
end
|
||||||
|
|
||||||
activate :sprockets
|
activate :sprockets
|
||||||
|
|
||||||
|
|
|
||||||
12
lib/multilang.rb
Normal file
12
lib/multilang.rb
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
module Multilang
|
||||||
|
def block_code(code, full_lang_name)
|
||||||
|
parts = full_lang_name.split('--')
|
||||||
|
rouge_lang_name = parts[0] || ""
|
||||||
|
super(code, rouge_lang_name).sub("highlight #{rouge_lang_name}") do |match|
|
||||||
|
match + " tab-" + full_lang_name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
require 'middleman-core/renderers/redcarpet'
|
||||||
|
Middleman::Renderers::MiddlemanRedcarpetHTML.send :include, Multilang
|
||||||
|
|
@ -5,7 +5,8 @@ language_tabs:
|
||||||
- shell
|
- shell
|
||||||
- ruby
|
- ruby
|
||||||
- python
|
- python
|
||||||
- javascript
|
- javascript--browser: Browser!
|
||||||
|
- javascript--node: Node!
|
||||||
|
|
||||||
toc_footers:
|
toc_footers:
|
||||||
- <a href='#'>Sign Up for a Developer Key</a>
|
- <a href='#'>Sign Up for a Developer Key</a>
|
||||||
|
|
@ -47,12 +48,16 @@ curl "api_endpoint_here"
|
||||||
-H "Authorization: meowmeowmeow"
|
-H "Authorization: meowmeowmeow"
|
||||||
```
|
```
|
||||||
|
|
||||||
```javascript
|
```javascript--browser
|
||||||
const kittn = require('kittn');
|
const kittn = require('kittn');
|
||||||
|
|
||||||
let api = kittn.authorize('meowmeowmeow');
|
let api = kittn.authorize('meowmeowmeow');
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```javascript--node
|
||||||
|
// node code here!
|
||||||
|
```
|
||||||
|
|
||||||
> Make sure to replace `meowmeowmeow` with your API key.
|
> 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 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).
|
||||||
|
|
@ -88,13 +93,17 @@ curl "http://example.com/api/kittens"
|
||||||
-H "Authorization: meowmeowmeow"
|
-H "Authorization: meowmeowmeow"
|
||||||
```
|
```
|
||||||
|
|
||||||
```javascript
|
```javascript--browser
|
||||||
const kittn = require('kittn');
|
const kittn = require('kittn');
|
||||||
|
|
||||||
let api = kittn.authorize('meowmeowmeow');
|
let api = kittn.authorize('meowmeowmeow');
|
||||||
let kittens = api.kittens.get();
|
let kittens = api.kittens.get();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```javascript--node
|
||||||
|
// node code here!
|
||||||
|
```
|
||||||
|
|
||||||
> The above command returns JSON structured like this:
|
> The above command returns JSON structured like this:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
|
@ -154,13 +163,17 @@ curl "http://example.com/api/kittens/2"
|
||||||
-H "Authorization: meowmeowmeow"
|
-H "Authorization: meowmeowmeow"
|
||||||
```
|
```
|
||||||
|
|
||||||
```javascript
|
```javascript--browser
|
||||||
const kittn = require('kittn');
|
const kittn = require('kittn');
|
||||||
|
|
||||||
let api = kittn.authorize('meowmeowmeow');
|
let api = kittn.authorize('meowmeowmeow');
|
||||||
let max = api.kittens.get(2);
|
let max = api.kittens.get(2);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```javascript--node
|
||||||
|
// node code here!
|
||||||
|
```
|
||||||
|
|
||||||
> The above command returns JSON structured like this:
|
> The above command returns JSON structured like this:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,10 @@ under the License.
|
||||||
$(".lang-selector a").removeClass('active');
|
$(".lang-selector a").removeClass('active');
|
||||||
$(".lang-selector a[data-language-name='" + language + "']").addClass('active');
|
$(".lang-selector a[data-language-name='" + language + "']").addClass('active');
|
||||||
for (var i=0; i < languages.length; i++) {
|
for (var i=0; i < languages.length; i++) {
|
||||||
$(".highlight." + languages[i]).hide();
|
$(".highlight.tab-" + languages[i]).hide();
|
||||||
$(".lang-specific." + languages[i]).hide();
|
$(".lang-specific." + languages[i]).hide();
|
||||||
}
|
}
|
||||||
$(".highlight." + language).show();
|
$(".highlight.tab-" + language).show();
|
||||||
$(".lang-specific." + language).show();
|
$(".lang-specific." + language).show();
|
||||||
|
|
||||||
global.toc.calculateHeights();
|
global.toc.calculateHeights();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue