Skip to content

Commit

Permalink
Fixed merge conflicts with metalsmith.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jme783 committed Jul 17, 2015
2 parents ec6a31b + 160e39b commit 0b6e92d
Show file tree
Hide file tree
Showing 30 changed files with 582 additions and 242 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
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
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
language: node_js
node_js:
- '0.12'
git:
submodules: false
before_install:
- echo -e "machine github.com\n login $CI_USER_TOKEN" >> ~/.netrc
- '[ "${TRAVIS_PULL_REQUEST}" = "false" ] && git submodule update --init --recursive && cd api-node && git fetch && git merge origin/master && cd ..'
before_script: npm test
script: npm run build
deploy:
Expand Down
1 change: 1 addition & 0 deletions api-node
Submodule api-node added at a93b4e
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"build": "node ./scripts/build.js"
},
"dependencies": {
"apidoc": "^0.13.1",
"async": "^1.2.1",
"cheerio": "^0.16.0",
"handlebars": "^3.0.1",
Expand Down
59 changes: 59 additions & 0 deletions scripts/apidoc.js
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();
};
};
12 changes: 8 additions & 4 deletions scripts/metalsmith.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ var lunr_ = require('lunr');
var fileMetadata = require('metalsmith-filemetadata');
var msIf = require('metalsmith-if');
var precompile = require('./precompile');

var marked = require('marked');
var renderer = new marked.Renderer();

var apidoc = require('./apidoc');

var environment;

Expand All @@ -55,6 +52,12 @@ exports.metalsmith = function() {
.use(cleanCSS({
files: '**/*.css'
}))
.use(apidoc({
src: '../api-node/',
config: '../api-node/',
destFile: 'content/reference/apigen.md',
includeFilters: '.*[vV]iews[^.]*\\.js$'
}))
.use(partials({
directory: '../templates/partials'
}))
Expand Down Expand Up @@ -179,6 +182,7 @@ exports.server = function(callback) {
"../templates/reference.hbs": "content/reference/*.md",
"../templates/guide.hbs": "content/guide/**/*.md",
"../templates/datasheet.hbs": "content/datasheets/*.md",
"../templates/support.hbs": "content/support/*.md",
"${source}/assets/js/*.js" : true
},
livereload: true
Expand Down
106 changes: 106 additions & 0 deletions src/assets/less/api.less
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';
}
}
62 changes: 30 additions & 32 deletions src/assets/less/footnote.less
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@media screen and (min-width: @xlarge-size) {
@media screen and (min-width: 1360px) {

.footnoteLink {
border-bottom: 1px solid #00adef;
Expand All @@ -7,8 +7,8 @@

.footnote {
background-color: #ffffff;
border-top: 2px solid #00adef;
border-bottom: 2px solid #00adef;
border-top: 2px solid #00adef;
border-bottom: 2px solid #00adef;
font-weight: normal;
height: auto;
left: -140px;
Expand All @@ -32,50 +32,50 @@

}

@media screen and (max-width: @large-size) and (mid-width: @medium-size) {
@media screen and (max-width: 1360px) and (min-width: @small-size) {
.footnoteLink {
border-bottom: 1px solid #00adef;
cursor: pointer;
}

.footnote {
background-color: @almost-black;
border-radius:5px;
border: 2px solid #00adef;
font-weight:normal;
left: 25%;
right: 50%;
opacity: 0;
visibility: hidden;
width: 100%;
z-index: 1;
-webkit-transition: opacity .25s, visibility .25s;
-moz-transition: opacity .25s, visibility .25s;
transition: opacity .25s, visibility .25s;
font-size: 12 px;
max-width: 320px;
max-height: 320 px;
position: absolute;
transform: translateY(-50%);
display:block;
}
background-color: #ffffff;
border-top: 2px solid #00adef;
border-bottom: 2px solid #00adef;
font-weight: normal;
height: auto;
line-height: 1.4;
margin-top: -20px;
min-height: 20px;
opacity: 0;
position: absolute;
width: 320 px;
visibility: hidden;
z-index: 1;
transition: opacity .25s, visibility .25s;
font-size: 10 px;
transform: translateY(-50%);
padding: 15px;
border: 2px solid #00adef;
border-radius: 10px;
display: block;
}

.footnoteLink:hover .footnote {
visibility: visible;
opacity: 1;
}
.footnoteLink:hover .footnote {
visibility: visible;
opacity: 1;
}

}

@media screen and (max-width: @medium-size) and (min-width: 0) {
@media screen and (max-width: @small-size) and (min-width: 0) {
.footnoteLink {
border-bottom: 1px solid #00adef;
cursor: pointer;
}

.footnote {
background-color: #ffffff;
border-radius:2px;
border: 2px solid #00adef;
font-weight:normal;
height: auto;
Expand All @@ -98,8 +98,6 @@
visibility: visible;
opacity: 1;
}
.footnote:after {content: "— release to close —"; color: #a0a0a0; display: block; padding: 8px 0px 8px 0px;
font-size: 1.18rem; }
}


Expand Down

0 comments on commit 0b6e92d

Please sign in to comment.