From bd08ab2f1249ba6a947ee1756feb4f17dec471d6 Mon Sep 17 00:00:00 2001 From: Brian Mock Date: Wed, 31 Dec 2014 12:53:16 -0800 Subject: [PATCH] Switch to Handelbars; generate from JSDocs --- .gitignore | 3 +- doc.yaml | 82 ------------------- docs/main.js | 19 ++--- .../docs.html.handlebars | 69 +++++++--------- .../index.html.handlebars | 12 ++- jsdoc-template/publish.js | 50 +++++++++-- less/hljs.less | 11 +++ less/layout.less | 59 ++++++++----- less/sidebar.less | 10 ++- package.json | 1 + 10 files changed, 151 insertions(+), 165 deletions(-) delete mode 100644 doc.yaml rename docs/index.html => jsdoc-template/docs.html.handlebars (59%) rename index.html => jsdoc-template/index.html.handlebars (67%) diff --git a/.gitignore b/.gitignore index 51b178cc9..c56c58984 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,5 @@ /test/bundle.js /bower_components/ /style.css -/docs/data.json +/docs/index.html +/index.html diff --git a/doc.yaml b/doc.yaml deleted file mode 100644 index d6c8921bc..000000000 --- a/doc.yaml +++ /dev/null @@ -1,82 +0,0 @@ -- name: all - category: List - sig: "(a -> Boolean) -> [a] -> Boolean" - params: - - name: fn - type: Function - description: The predicate function. - - name: list - type: Array - description: The array to consider. - returns: - type: Boolean - description: | - `true` if the predicate is satisfied by every element, `false` otherwise - description: | - Returns `true` if all elements of the list match the predicate, `false` if - there are any that don't. - example: | - var lessThan2 = R.flip(R.lt)(2); - var lessThan3 = R.flip(R.lt)(3); - var xs = R.range(1, 3); - xs; //=> [1, 2] - R.all(lessThan2)(xs); //=> false - R.all(lessThan3)(xs); //=> true -- name: foldl - category: List - sig: "(a, b -> a) -> a -> [b] -> a" - params: - - name: fn - type: Function - description: | - The iterator function. Receives two values, the accumulator and the - current element from the array. - - name: acc - type: any - description: The accumulator value. - - name: list - type: Array - description: The list to iterate over. - returns: - type: any - description: The final, accumulated value. - example: | - var numbers = [1, 2, 3]; - var add = function(a, b) { - return a + b; - }; - - R.foldl(add, 10, numbers); //=> 16 - description: | - Returns a single item by iterating through the list, successively calling - the iterator function and passing it an accumulator value and the current - value from the array, and then passing the result to the next call. - - The iterator function receives two values: *(acc, value)* - - Note: `R.foldl` does not skip deleted or unassigned indices (sparse arrays), - unlike the native `Array.prototype.reduce` method. For more details on this - behavior, see [the MDN page on Array.reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#Description). -- name: prop - category: Object - sig: "s -> {s: a} -> a" - params: - - name: p - type: String - description: The property name - - name: obj - type: Object - description: The object to query - returns: - type: any - description: The value at `obj.p` - description: | - Returns a function that when supplied an object returns the indicated - property of that object, if it exists. - example: | - R.prop('x', {x: 100}); //=> 100 - R.prop('x', {}); //=> undefined - - var fifth = R.prop(4); - var dwarfs = ['Bashful', 'Doc', 'Dopey', 'Grumpy', 'Happy', 'Sleepy', 'Sneezy']; - fifth(dwarfs); //=> 'Happy' diff --git a/docs/main.js b/docs/main.js index 772c1db00..852737923 100644 --- a/docs/main.js +++ b/docs/main.js @@ -1,19 +1,18 @@ console.time('load'); var root = {}; root.filter = ko.observable(''); -root.docs = ko.observableArray(); +root.docs = this.DOC_DATA || {}; root.filteredDocs = ko.computed(function() { - return root.docs().filter(function(d) { - var filter = root.filter().toLowerCase(); - return d.name.toLowerCase().indexOf(filter) >= 0 || - d.category.toLowerCase() === filter; + return root.docs.filter(function(d) { + return strIn(root.filter(), d.name); }); }); -function start(data) { - root.docs(data); - ko.applyBindings(root); - console.timeEnd('load'); +function strIn(a, b) { + a = a.toLowerCase(); + b = b.toLowerCase(); + return b.indexOf(a) >= 0; } -$.getJSON('data.json').then(start); +ko.applyBindings(root); +console.timeEnd('load'); diff --git a/docs/index.html b/jsdoc-template/docs.html.handlebars similarity index 59% rename from docs/index.html rename to jsdoc-template/docs.html.handlebars index b825f8646..7f918e239 100644 --- a/docs/index.html +++ b/jsdoc-template/docs.html.handlebars @@ -1,5 +1,5 @@ - + @@ -14,7 +14,7 @@