Skip to content

Commit

Permalink
allowing single render
Browse files Browse the repository at this point in the history
  • Loading branch information
justinbmeyer committed Nov 24, 2014
1 parent 0b8c22d commit 0ccfbff
Show file tree
Hide file tree
Showing 13 changed files with 258 additions and 115 deletions.
7 changes: 5 additions & 2 deletions lib/configured/configured_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,14 @@ describe("lib/configured", function(){
});

it("is able to import other tags", function(done){
this.timeout(10000);
// check that docObjects has a returns
var check = function(done){
open("test/tmp/custom_tags/_.keys.html",function(browser, close){
open("test/tmp/custom_tags/index.html",function(browser, close){

var rets = browser.window.document.getElementsByClassName("returns")

assert.ok(browser.window.docObject.returns, "has a returns object")
assert.ok(rets.length, "has a returns object")

close();
done();
Expand Down
4 changes: 3 additions & 1 deletion lib/configured/make_final_doc_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ module.exports = function finalizeDocConfig(docConfig, project, parent, options)
if(typeof siteConfig.tags === "string") {
siteConfig.tags = fsx.smartJoin(project.path, siteConfig.tags);
}

if(siteConfig["static"]) {
siteConfig["static"] = fsx.smartJoin(project.path, siteConfig["static"]);
}

// pageConfig - version of the project and a path to the docConfig
siteConfig.pageConfig = _.extend(siteConfig.pageConfig||{},{
Expand Down
4 changes: 3 additions & 1 deletion lib/configured/test/custom_tags/documentjs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
"custom_tags": {
"parent": "_",
"tags": "tags/tags",
"templates": "templates",
"static": "static",
"glob": "lodash-sample.js",
"dest": "../tmp/custom_tags",
"debug" : true
"singlePage": true
}
}

Expand Down
11 changes: 2 additions & 9 deletions lib/configured/test/custom_tags/lodash-sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,8 @@
* @returns {Array} Returns the array of property names.
* @example
*
* function Shape() {
* this.x = 0;
* this.y = 0;
* }
*
* Shape.prototype.z = 0;
*
* _.keys(new Shape);
* // => ['x', 'y'] (iteration order is not guaranteed)
* _.keys({ 'one': 1, 'two': 2, 'three': 3 });
* // → ['one', 'two', 'three'] (property order is not guaranteed across environments)
*/
var keys = !nativeKeys ? shimKeys : function(object) {
if (object) {
Expand Down
32 changes: 32 additions & 0 deletions lib/configured/test/custom_tags/static/styles/styles.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
html,body,h1,h2,p{margin:0;padding:0}
html{background:#d3d3d3;height:100%;color:#222;font-size:100%}body{background:#fff;width:60em;margin:0 auto;-webkit-box-shadow:0 0 2.5em #5d656c;-moz-box-shadow:0 0 2.5em #5d656c;box-shadow:0 0 2.5em #5d656c;font:1em/1.7 'Helvetica Neue',Helvetica,Arial,sans-serif;min-height:100%}code{font-family:Consolas,Courier New,monospace}pre{background:#0d152a;margin:1em 0;padding:.5em 20px;word-wrap:break-word}pre.intro{font-size:1.2em}pre,h1 span{color:#ddd}
h1,h2,h3,h4,p,ul,ol{font-weight:normal;padding:0 20px;word-wrap:break-word}
hgroup h1{display:inline}hgroup h2{font-size:1.38em}
h2,h3,h4{margin:0 0 .5em}h4{font-weight:bold}a{color:#222;border-bottom:1px solid #ddd;text-decoration:none}a:hover,a:focus{border-color:#222}a img{border:0}abbr[title]{border-bottom:1px dotted #ddd;cursor:help}hr{display:none}p{margin-bottom:1em}ul,ol{margin-left:2em}ul ul,ol ol{margin-left:1em;padding:0}footer{display:block;background:#eee;padding:1em 0 1em 0;text-align:center}
.description{word-wrap:break-word}.a-img{border:0}.a-img img{padding:.5em 0 0 0}.multiline-items li{padding-bottom:1em}.multiline-items li.last-item{padding-bottom:0}#docs{background:#fff}#docs body{font-size:.875em;width:100%}#docs a.alias{opacity:.5}#docs div div div{border:1px solid #d3d3d3;border-top:0;margin:0 .5em 1em .5em}#docs h1,#docs h2,#docs h3,#docs h4,#docs p,#docs ul,#docs ol{padding:0 10px}#docs pre{margin:0;padding:.5em 10px}#docs h1{padding:0 10px}#docs h2{margin:.5em 0 0 0}#docs h3{box-shadow:0 .25em .5em #d3d3d3;border-top:1px solid #d3d3d3;border-bottom:1px solid #d3d3d3;margin:.5em 0;padding:.75em 0 .75em 10px}#docs footer{height:3em;margin-top:1.5em;width:100%}

.kw1,.kw3{color:#006}
.kw2{color:#036}
.com{color:#060}
.co2{color:#096}
.pun{color:#090}
.sy0{color:#393;font-weight:bold}
.str{color:#36c}
.nu0{color:#c00}
.pln{color:#606}
pre .com{color:#aeaeae}
.es0,pre .str{color:#61ce3c}
pre .co2{color:#fff}
pre .lit,pre .kw2,pre .kw3{color:#fbde2d}
pre .pln{color:#8da6ce}
pre .pun,pre .sy0,pre .kw1{color:#ddd}

#social{height:20px}#social .twitter-follow-button{width:127px !important}#social .twitter-follow-button,.twitter-share-button{font-size:.8em;vertical-align:top}@media(max-width:959px){@viewport{width:80%}@-ms-viewport{width:80%}body{border:0;margin:0;-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none;width:auto}h1,h2,h3,h4,p,ul,ol{padding:0 10px}pre{padding:5px 10px !important}}@media(min-width:960px){@viewport{width:device-width}@-ms-viewport{width:device-width}#docs body{box-shadow:none;height:100%;margin:0}#docs .toc-container{background:#fff;bottom:0;left:0;overflow-y:scroll;overflow-x:hidden;position:fixed;top:3.5em;white-space:nowrap;width:20%;-webkit-overflow-scrolling:touch}#docs .toc-container h2,#docs .toc-container ul{margin-top:0;padding:0 10px}#docs .doc-container{background:#fff;bottom:0;position:fixed;overflow-y:scroll;overflow-x:hidden;right:0;top:3.5em;width:80%;-webkit-overflow-scrolling:touch}


#docs .doc-container .first-heading{margin-top:0}#docs a[href="#toc"],#docs footer{display:none}}@media(-ms-high-contrast:active) and (max-width:1280px),(-ms-high-contrast:none) and (max-width:1280px){#docs .toc-container,#docs .doc-container{position:relative;top:auto;width:100%}
#docs .doc-container .first-heading{margin-top:.5em}#docs a[href="#toc"]{display:inline}#docs footer{display:block}}

.parameters p, .returns p {display: inline; margin: 0px; padding: 0px;}
#docs .returns {border: none; padding: 0 10px; margin-bottom: 1em; margin-left: 0px;}

4 changes: 3 additions & 1 deletion lib/configured/test/custom_tags/tags/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ module.exports = function(existingTags){
curData.lines.push(line);
},
end: function(line, curData){
this.body += "```\n"+curData.lines.join("\n")+"\n```\n";
this.body += "```\n"+
curData.lines.join("\n").trim()+
"\n```\n";
}
},
"static": {
Expand Down
107 changes: 13 additions & 94 deletions lib/configured/test/custom_tags/templates/content.mustache
Original file line number Diff line number Diff line change
@@ -1,96 +1,15 @@
{{#unless hideContainer}}
<div class="container api">
{{/unless}}
{{#unless hideSidebar}}
<nav class="sidebar">
{{#if enableSearch}}
<div class="search-wrapper">
<div class="search">
<input type="text"/>
</div>
</div>
{{/if}}
{{> menu.mustache}}
</nav>
{{/unless}}

{{#unless hideArticle}}
<article class="content docs">
{{/unless}}

{{#unless hideTitle}}
<section class="title">
{{> title.mustache}}
</section>
{{/unless}}

{{#unless hideArticle}}
<section class="contents">
</section>
{{/unless}}

{{#if deprecated.length}}
<section class='warnings'>
{{#deprecated}}
<div class='deprecated warning'>
<h3>Deprecated {{version}}</h3>
<div class='signature-wrapper'>
{{{makeLinks description}}}
</div>
</div>
{{/deprecated}}
</section>
{{/if}}

{{#if description}}
<section class="description">
{{#eachCategory}}
<div>
<h2><code>“{{name}}” Methods</code></h2>
{{#eachDocObject name}}
<h3>
<a id="{{name}}"> </a>
<code class="prettyprint">{{{makeSignature code}}}</code>
</h3>
{{{makeLinks description}}}
</section>
{{/if}}

{{#if signatures}}
{{#signatures}}
<section class="signature">
{{> signature.mustache}}
</section>
{{/signatures}}
{{else}}
{{#if types}}
<section class='primary-options'>
{{> types.mustache}}
</section>
{{/if}}
{{/if}}

{{#ifAny params returns}}
<section class="signature">
{{> signature.mustache}}
</section>
{{/ifAny}}


{{#if body}}
<section class="comment">
{{> signature.mustache}}
<h4>Example</h4>
{{{makeLinks body}}}
</section>
{{/if}}
{{#if htmlBody}}
{{{htmlBody}}}
{{/if}}

{{#if api}}
<section class="api">
{{{makeApiSection}}}
</section>
{{/if}}

{{#unless hideArticle}}
</article>
{{/unless}}

{{#unless hideContainer}}
</div>
{{/unless}}



{{/eachDocObject}}
</div>
{{/eachCategory}}
54 changes: 54 additions & 0 deletions lib/configured/test/custom_tags/templates/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
var _ = require("lodash");


// theme/templates/helpers.js
module.exports = function(docMap, options, getCurrent){

var categories = {};
_.forEach(docMap, function(docObject, name){
var cat = docObject.category;
if(!cat) {
return;
}

if(!categories[cat]) {
categories[cat] = [];
}
var docs = categories[cat];
docs.push({
name: name,
docObject: docObject
});
if(docObject.alias) {
docs.push({
isAlias: true,
newName: name,
name: docObject.alias,
docObject: docObject
});
}

});
for(var name in categories) {
categories[name] = _.sortBy( categories[name], "name" );
}


return {
"eachCategory": function(options){
return _.map(categories, function(docs, name){
return options.fn({name: name});
}).join("");
},
"eachItem": function(name, options){
return _.map(categories[name], function(doc, i){
return options.fn(doc);
}).join("");
},
"eachDocObject": function(name, options){
return _.map(categories[name], function(doc, i){
return doc.isAlias ? "" : options.fn(doc.docObject);
}).join("");
},
};
};
65 changes: 65 additions & 0 deletions lib/configured/test/custom_tags/templates/layout.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html lang="en" id='docs'>

<head>
<meta charset="utf-8">
<title>Lo-Dash documentation</title>
<meta name="description" content="">
<meta name="author" content="">
{{^devBuild}}
<link rel="stylesheet" type="text/css" href="./static/bundles/static.css">
{{/devBuild}}
<!--[if lt IE 9]>
<script type="text/javascript" src="static/html5shiv.js"></script>
<!--<![endif]-->
</head>

<body>
<h1><a href="/">Lo-Dash</a> <span>v2.4.1</span></h1>
<div class='toc-container'>
{{#eachCategory}}
<div>
<h2><code>{{name}}</code></h2>
<ul>
{{#eachItem name}}
<li>
<a href="#{{url}}" {{#isAlias}}class="alias"{{/isAlias}}>
<code>_.<span class='mel'>{{name}}</span></code>
{{#isAlias}}
→ <code>{{newName}}</code>
{{/isAlias}}
</a>
</li>
{{/eachItem}}
</ul>
</div>
{{/eachCategory}}
</div>
<div class='doc-container'>
{{{content}}}
</div>
<script type="text/javascript">
var docObject = {{{docObjectString}}};
</script>

{{#if devBuild}}
<script type='text/javascript'
data-main="static"
data-config="./static/config.js"
src="./static/steal/steal.js"></script>
{{else}}
<script>
steal = {
instantiated: {
"bundles/static.css!$css" : null
}
}
</script>
<script type='text/javascript'
data-main="static"
src="./static/steal.production.js"
bundles-path="bundles"></script>
{{/if}}
</body>

</html>
63 changes: 63 additions & 0 deletions lib/configured/test/custom_tags/templates/signature.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{{#if params}}
<h4>Arguments</h4>

<ol class="parameters">
{{#params}}
<li>
<code>{{name}}{{#if defaultValue}}={{defaultValue}}{{/if}}</code>
<em>{{#if types}}{{{makeTypesString types}}}{{/if}}{{#if optional}}<span class="optional">Optional{{#if variable}} Variable{{/if}}</span>{{/if}}</em>:
{{{makeLinks description}}}

{{#types}}
{{#if options.length}}
<ul class="options">
{{#options}}
<li class="option">
<h5>{{name}}
{{#if types}}<code>{{{makeTypesString types}}}</code>{{/if}}
</h5>
<div class="description">
{{{makeLinks description}}}
</div>
</li>
{{/options}}
</ul>
{{/if}}
{{/types}}
</li>
{{/params}}
</ol>
{{/if}}
{{#if returns}}
<h4>Returns</h4>
<div class="returns">
<em>{{{makeTypesString returns.types}}}</em>:
{{{makeLinks returns.description}}}


{{#getTypesWithDescriptions returns.types}}
<ul class="options">
{{#types}}
<li class="option">
<h5>{{name}}
{{#if types}}<code>{{{makeTypesString types}}}</code>{{/if}}
</h5>
<div class="description">
{{{makeLinks description}}}
</div>
</li>
{{/types}}
</ul>
{{/getTypesWithDescriptions}}
</div>

{{/if}}
{{#if context}}
<h4>This</h4>
<div class="returns">
<h4><code>{{{makeTypesString context.types}}}</code></h4>
<div class="description">
{{{makeLinks context.description}}}
</div>
</div>
{{/if}}
Loading

0 comments on commit 0ccfbff

Please sign in to comment.