-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed merge conflicts with metalsmith.js
- Loading branch information
Showing
30 changed files
with
582 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "api-node"] | ||
path = api-node | ||
url = https://github.com/spark/api-node |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
'use strict'; | ||
|
||
var apidoc = require('apidoc'); | ||
var _ = require('lodash'); | ||
var fs = require('fs'); | ||
|
||
function nestParameters(allParams) { | ||
if (allParams) { | ||
_.each(allParams, function (params, key) { | ||
var indexedParameters = _.indexBy(allParams[key], 'field'); | ||
var nestedParams = []; | ||
params.forEach(function (param) { | ||
var nameParts = param.field.split('.'); | ||
if (nameParts.length > 1) { | ||
var parent = indexedParameters[nameParts[0]]; | ||
if (parent) { | ||
if (!parent.nestedParams) { | ||
parent.nestedParams = []; | ||
} | ||
param.field = nameParts.slice(1).join('.'); | ||
parent.nestedParams.push(param); | ||
nestedParams.push(param); | ||
} | ||
} | ||
}); | ||
allParams[key] = _.difference(allParams[key], nestedParams); | ||
}); | ||
} | ||
} | ||
|
||
module.exports = function(options) { | ||
return function(files, metalsmith, done) { | ||
options.parse = true; | ||
options.src = metalsmith.path(options.src); | ||
if (!fs.existsSync(options.src)) { | ||
return done(); | ||
} | ||
|
||
options.lineEnding = 'LF'; | ||
var apiReturn = apidoc.createDoc(options); | ||
if (!apiReturn) { | ||
return done(new Error('Error')); | ||
} | ||
|
||
var goodData = JSON.parse(apiReturn.data); | ||
goodData.forEach(function (route) { | ||
if (route.success) { | ||
nestParameters(route.success.fields); | ||
} | ||
}); | ||
apiReturn.data = _.groupBy(goodData, 'group'); | ||
|
||
var destFile = files[options.destFile]; | ||
if (destFile) { | ||
destFile.apiGroups = apiReturn.data; | ||
} | ||
return done(); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
.content ul.api-attributes { | ||
&::before { | ||
text-transform: uppercase; | ||
color: @another-gray; | ||
font-size: 12px; | ||
line-height: 30px; | ||
} | ||
|
||
div { | ||
font-size: 14px; | ||
padding: 10px; | ||
color: #555; | ||
} | ||
|
||
.api-field { | ||
text-align: right; | ||
width: 18%; | ||
float: left; | ||
color: @almost-black; | ||
} | ||
|
||
.field-desc { | ||
float: left; | ||
} | ||
|
||
.field-required { | ||
display: block; | ||
font-size: 12px; | ||
color: @spark-blue; | ||
} | ||
|
||
small { | ||
display: block; | ||
color: @another-gray; | ||
text-transform: lowercase; | ||
} | ||
|
||
li { | ||
border-top: 1px solid #ddd; | ||
clear: both; | ||
overflow: auto; | ||
list-style-type: none; | ||
font-weight: 400; | ||
margin: 0; | ||
line-height: 1.4; | ||
} | ||
|
||
li:last-child { | ||
border-bottom: 1px solid #ddd; | ||
} | ||
|
||
.nested-params { | ||
margin-left: 30px; | ||
padding: 0; | ||
|
||
li:first-child { | ||
border-top-width: 0; | ||
} | ||
li:last-child { | ||
border-bottom-width: 0; | ||
} | ||
} | ||
} | ||
|
||
.content ul.api-request { | ||
&::before { | ||
content: 'Request Arguments'; | ||
} | ||
} | ||
|
||
.content ul.api-response { | ||
&::before { | ||
content: 'Response Attributes'; | ||
} | ||
} | ||
|
||
.api-code { | ||
padding-top: 0 !important; | ||
background-color: @super-dark-gray; | ||
|
||
&::before { | ||
color: @another-gray; | ||
background-color: #272822; | ||
display: block; | ||
margin: 0 -40px; | ||
padding: 10px 40px; | ||
} | ||
|
||
code { | ||
margin: 20px 0 !important; | ||
} | ||
} | ||
|
||
.api-response-example { | ||
&::before { | ||
content: 'Example Response'; | ||
} | ||
} | ||
|
||
.api-definition { | ||
margin-top: -58px; | ||
|
||
&::before { | ||
content: 'Definition'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.