Skip to content

Commit

Permalink
add experimental @LiVe tag for tonicdev live examples
Browse files Browse the repository at this point in the history
  • Loading branch information
lipp committed Mar 2, 2016
1 parent 81a812b commit f684ff2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
6 changes: 6 additions & 0 deletions lib/structure.js
Expand Up @@ -27,6 +27,12 @@ var rawRootFromGitHubUrl = function (branch) {
return '/raw/' + branch + '/'
}

module.exports.hasLiveExamples = function (doclet) {
if (doclet.tags) {
return _.findWhere(doclet.tags, {title: 'live'}) !== undefined
}
}

module.exports.addUrlToDoclets = function (doclets, githubUrl, branch) {
var fileBaseUrl = githubUrl + fileRootFromGitHubUrl(branch)
_.each(doclets, function (doclet) {
Expand Down
1 change: 1 addition & 0 deletions lib/view-params.js
Expand Up @@ -113,6 +113,7 @@ module.exports.getApiParams = function (doclet) {
return {
doclet: doclet,
childs: structure.childs,
hasLiveExamples: structure.hasLiveExamples,
'_': _,
tools: tools,
versionsPath: './',
Expand Down
15 changes: 11 additions & 4 deletions views/details.jade
@@ -1,7 +1,14 @@
mixin examples(examplesArray)
- var exampleIndex = 0
mixin examples(examplesArray, live)
each example in examplesArray
pre.example
code= example
if live
- exampleIndex++
- id = 'example-' + exampleIndex
script(src='https://embed.tonicdev.com' data-element-id=id, defer=true)
div.live(id=id)= example
else
pre.example
code= example


mixin see(seeArray)
Expand Down Expand Up @@ -106,7 +113,7 @@ mixin details(doclet)
//p= JSON.stringify(doclet.properties)
if doclet.examples
h4 Example code:
+examples(doclet.examples)
+examples(doclet.examples, hasLiveExamples(doclet))
if doclet.see
+see(doclet.see)

Expand Down

0 comments on commit f684ff2

Please sign in to comment.