From 0ab1cf96e4a43d9e98ba5b128193f806504a6660 Mon Sep 17 00:00:00 2001 From: Kyle Gifford Date: Thu, 4 May 2017 15:08:58 -0600 Subject: [PATCH 1/7] upgrade to CanJS 3.0, Steal 0.16 --- .travis.yml | 2 - appveyor.yml | 2 +- examples/simple/components/tabs.js | 4 +- lib/configured/configured_test.js | 60 ++-- lib/generate/test/generate_test.js | 3 +- lib/generators/html/html_test.js | 2 +- lib/tags/alias.js | 2 +- lib/tags/deprecated.js | 2 +- lib/tags/helpers/typer_test.js | 48 ++-- lib/tags/plugin.js | 4 +- lib/tags/property_test.js | 6 +- lib/tags/signature.js | 4 +- package.json | 48 +--- site/default/static/build.js | 92 +++++- site/default/static/config.js | 15 +- site/default/static/content_list.js | 157 +++++----- site/default/static/demo_frame.js | 16 +- ...{demo_frame.mustache => demo_frame.stache} | 0 site/default/static/frame_helper.js | 69 ++--- site/default/static/map.js | 34 +++ site/default/static/static.js | 34 +-- site/default/static/versions.js | 267 +++++++++--------- site/default/templates/layout.mustache | 6 +- 23 files changed, 474 insertions(+), 403 deletions(-) rename site/default/static/{demo_frame.mustache => demo_frame.stache} (100%) create mode 100644 site/default/static/map.js diff --git a/.travis.yml b/.travis.yml index b61ea4704..1feabd548 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,5 @@ language: node_js node_js: - - "0.10" - - "0.12" - "node" script: npm test sudo: false diff --git a/appveyor.yml b/appveyor.yml index 4ee5c89ec..e1d8a3818 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ # Test against this version of Node.js environment: matrix: - - nodejs_version: "0.12" + - nodejs_version: "6.0" # Install scripts. (runs after repo cloning) install: diff --git a/examples/simple/components/tabs.js b/examples/simple/components/tabs.js index 88bc8d01a..d02c92f3b 100644 --- a/examples/simple/components/tabs.js +++ b/examples/simple/components/tabs.js @@ -1,4 +1,4 @@ -import can from 'can/'; +import CanComponent from 'can-component'; import tabsStache from './tabs.stache!'; /** * @module {function} components/tabs/ @@ -7,7 +7,7 @@ import tabsStache from './tabs.stache!'; * @signature `` * Creates a tabs component. */ -export default can.Component.extend({ +export default CanComponent.extend({ tag: "tabs", template: tabsStache, scope: { ... } diff --git a/lib/configured/configured_test.js b/lib/configured/configured_test.js index 3b7fc1c70..37b9b6496 100644 --- a/lib/configured/configured_test.js +++ b/lib/configured/configured_test.js @@ -122,7 +122,7 @@ describe("lib/configured", function(){ it(".geneateProject is able to read the documentjs.json without versions and build a site", function(done){ - this.timeout(10000); + this.timeout(30000); rmdir(path.join(__dirname,"test","api"), function(e){ if(e) { done(e); @@ -141,7 +141,7 @@ describe("lib/configured", function(){ }); it(".geneateProject is able to take a docObject instead of reading one", function(done){ - this.timeout(10000); + this.timeout(30000); rmdir(path.join(__dirname,"test","tmp","example_project"), function(e){ if(e) { done(e); @@ -176,15 +176,17 @@ describe("lib/configured", function(){ open("test/tmp/multiple_versions/1.0.0/api/index.html",function(browser, close){ var select = browser.window.document.getElementsByTagName("select")[0], $ = browser.window.$; - $(select).val("3.0.0").trigger("change"); - waitFor(browser, function(window){ - return window.location.href == "http://localhost:8081/test/tmp/multiple_versions/3.0.0/api/index.html" - }, function(){ - assert.ok(true,"updated page"); - close(); - next(); - }, close); + $(select).val("3.0.0"); + select.dispatchEvent(new browser.window.Event('change')); + + waitFor(browser, function(window){ + return window.location.href == "http://localhost:8081/test/tmp/multiple_versions/3.0.0/api/index.html" + }, function(){ + assert.ok(true,"updated page"); + close(); + next(); + }, close); },done); }; @@ -193,15 +195,17 @@ describe("lib/configured", function(){ open("test/tmp/multiple_versions/api/index.html",function(browser, close){ var select = browser.window.document.getElementsByTagName("select")[0], $ = browser.window.$; - $(select).val("3.0.0").trigger("change"); - waitFor(browser, function(window){ - return window.location.href == "http://localhost:8081/test/tmp/multiple_versions/3.0.0/api/index.html" - }, function(){ - assert.ok(true,"updated page"); - close(); - next(); - }, close); + $(select).val("3.0.0"); + select.dispatchEvent(new browser.window.Event('change')); + + waitFor(browser, function(window){ + return window.location.href == "http://localhost:8081/test/tmp/multiple_versions/3.0.0/api/index.html" + }, function(){ + assert.ok(true,"updated page"); + close(); + next(); + }, close); },done); }; @@ -210,15 +214,17 @@ describe("lib/configured", function(){ open("test/tmp/multiple_versions/3.0.0/api/index.html",function(browser, close){ var select = browser.window.document.getElementsByTagName("select")[0], $ = browser.window.$; - $(select).val("2.0.0").trigger("change"); - waitFor(browser, function(window){ - return window.location.href == "http://localhost:8081/test/tmp/multiple_versions/api/index.html" - }, function(){ - assert.ok(true,"updated page"); - close(); - next(); - }, close); + $(select).val("2.0.0"); + select.dispatchEvent(new browser.window.Event('change')); + + waitFor(browser, function(window){ + return window.location.href == "http://localhost:8081/test/tmp/multiple_versions/api/index.html" + }, function(){ + assert.ok(true,"updated page"); + close(); + next(); + }, close); },done); }; @@ -258,7 +264,7 @@ describe("lib/configured", function(){ it(".generateProject is able to build something without a documentjs.json", function(done){ - this.timeout(10000); + this.timeout(30000); rmdir(path.join(__dirname,"test","docs"), function(e){ if(e) { done(e); diff --git a/lib/generate/test/generate_test.js b/lib/generate/test/generate_test.js index 2b4259a30..1fc65b11b 100644 --- a/lib/generate/test/generate_test.js +++ b/lib/generate/test/generate_test.js @@ -39,7 +39,7 @@ var open = function(url, callback, done){ describe("documentjs/lib/generate/generate",function(){ it("works",function(done){ - this.timeout(30000); + this.timeout(10000); rmdir(__dirname+"/out",function(error){ generate({ @@ -62,6 +62,7 @@ describe("documentjs/lib/generate/generate",function(){ }); it("@outline works", function(done){ + this.timeout(30000); generate({ glob: __dirname+"/example/*.js", dest: __dirname+"/out", diff --git a/lib/generators/html/html_test.js b/lib/generators/html/html_test.js index aaffecf75..56bad8b0b 100644 --- a/lib/generators/html/html_test.js +++ b/lib/generators/html/html_test.js @@ -33,7 +33,7 @@ describe("documentjs/lib/generators/html",function(){ }, options)); }); html.generate(docMap,options).then(function(){ - if(!fs.existsSync(path.join(__dirname,"test","tmp","static","can","can.js"))) { + if(!fs.existsSync(path.join(__dirname,"test","tmp","static","can-control","can-control.js"))) { done(new Error("canjs does not exist")); } else if(fs.existsSync(path.join(__dirname,"test","tmp","static","bundles","static.js"))) { done(new Error("static build exists")); diff --git a/lib/tags/alias.js b/lib/tags/alias.js index 6f7e98438..233e30be3 100644 --- a/lib/tags/alias.js +++ b/lib/tags/alias.js @@ -21,7 +21,7 @@ var _default = require("./_default"), * /** * * @alias WidgetFactory * *| - * can.Class.extend("jQuery.Controller", + * CanClass.extend("jQuery.Controller", * ... * @codeend */ diff --git a/lib/tags/deprecated.js b/lib/tags/deprecated.js index fc327d167..ecd4dba2f 100644 --- a/lib/tags/deprecated.js +++ b/lib/tags/deprecated.js @@ -33,7 +33,7 @@ var tnd = require('./helpers/typeNameDescription') * /** * * @function * * @deprecated {1.0} This method has been replaced - * * by [can.Model.parseModel]. + * * by [CanModel.parseModel]. * * * * @param {String} name * *| diff --git a/lib/tags/helpers/typer_test.js b/lib/tags/helpers/typer_test.js index d344c05a4..088353150 100644 --- a/lib/tags/helpers/typer_test.js +++ b/lib/tags/helpers/typer_test.js @@ -5,9 +5,9 @@ var typer = require("./typer"), describe("documentjs/tags/helpers/typer", function(){ it("name",function(){ - assert.deepEqual( typer.type("can.Control"), { + assert.deepEqual( typer.type("CanControl"), { types: [{ - type: "can.Control" + type: "CanControl" }] }); }); @@ -43,11 +43,11 @@ describe("documentjs/tags/helpers/typer", function(){ }); it("union",function(){ - assert.deepEqual( typer.type("(can.Control|can.Model)"), { + assert.deepEqual( typer.type("(CanControl|CanModel)"), { types: [{ - type: "can.Control" + type: "CanControl" },{ - type: "can.Model" + type: "CanModel" }] }); }); @@ -67,16 +67,16 @@ describe("documentjs/tags/helpers/typer", function(){ }); it("nullable",function(){ - assert.deepEqual( typer.type("?can.Control"), { + assert.deepEqual( typer.type("?CanControl"), { types: [{ - type: "can.Control" + type: "CanControl" }], nullable: true }); - assert.deepEqual( typer.type("?can.Control"), { + assert.deepEqual( typer.type("?CanControl"), { types: [{ - type: "can.Control" + type: "CanControl" }], nullable: true }); @@ -85,9 +85,9 @@ describe("documentjs/tags/helpers/typer", function(){ it("nonnullable",function(){ - assert.deepEqual( typer.type("!can.Control"), { + assert.deepEqual( typer.type("!CanControl"), { types: [{ - type: "can.Control" + type: "CanControl" }], nonnull: true }); @@ -123,18 +123,18 @@ describe("documentjs/tags/helpers/typer", function(){ }); it("variable params",function(){ - assert.deepEqual( typer.type("...can.Control"), { + assert.deepEqual( typer.type("...CanControl"), { types: [{ - type: "can.Control" + type: "CanControl" }], variable: true }); }) it("variable params",function(){ - assert.deepEqual( typer.type("...can.Control"), { + assert.deepEqual( typer.type("...CanControl"), { types: [{ - type: "can.Control" + type: "CanControl" }], variable: true }); @@ -143,14 +143,14 @@ describe("documentjs/tags/helpers/typer", function(){ it("variable params",function(){ - assert.deepEqual( typer.type("function(...can.Observe){}"), { + assert.deepEqual( typer.type("function(...CanObserve){}"), { types: [{ type: "function", constructs: undefined, context: undefined, returns: {types: [{type: "undefined"}]}, params: [ - {types: [{type: "can.Observe"}], variable: true} + {types: [{type: "CanObserve"}], variable: true} ] }], }); @@ -159,9 +159,9 @@ describe("documentjs/tags/helpers/typer", function(){ // NON-STANDARD types ... it("optional",function(){ - assert.deepEqual( typer.type("can.Control="), { + assert.deepEqual( typer.type("CanControl="), { types: [{ - type: "can.Control" + type: "CanControl" }], optional: true }); @@ -178,17 +178,17 @@ describe("documentjs/tags/helpers/typer", function(){ }); it("parenthesis-less union", function(){ - assert.deepEqual( typer.type("can.Control|can.Model"), { + assert.deepEqual( typer.type("CanControl|CanModel"), { types: [{ - type: "can.Control" + type: "CanControl" },{ - type: "can.Model" + type: "CanModel" }] }); }) it("parenthesis-less union with function", function(){ - assert.deepEqual( typer.type("function|can.Model"), { + assert.deepEqual( typer.type("function|CanModel"), { types: [{ type: "function", type: "function", @@ -197,7 +197,7 @@ describe("documentjs/tags/helpers/typer", function(){ returns: {types: [{type: "undefined"}]}, params: [] },{ - type: "can.Model" + type: "CanModel" }] }); }); diff --git a/lib/tags/plugin.js b/lib/tags/plugin.js index 572c777f7..e8309be30 100644 --- a/lib/tags/plugin.js +++ b/lib/tags/plugin.js @@ -12,8 +12,8 @@ * * @codestart * /** - * * @@page can.Construct.super - * * @@parent can.Construct.plugins + * * @@page CanConstruct.super + * * @@parent CanConstruct.plugins * * @@plugin can/construct/super * * @@test can/construct/super/qunit.html * *| diff --git a/lib/tags/property_test.js b/lib/tags/property_test.js index 4d51b0896..7bcc50801 100644 --- a/lib/tags/property_test.js +++ b/lib/tags/property_test.js @@ -27,8 +27,8 @@ describe("documentjs/lib/tags/property",function(){ var obj = {}; var docMap = {Foo: {name: "Foo", type: "constructor"}} - property.add.call(obj,"@property {can.Map|Object|function} bar a description",null,docMap.Foo, docMap ); - option.add.call(obj,"@option {can.Map} can.Map description"); + property.add.call(obj,"@property {CanMap|Object|function} bar a description",null,docMap.Foo, docMap ); + option.add.call(obj,"@option {CanMap} CanMap description"); option.add.call(obj,"@option {Object} Object description"); option.add.call(obj,"@option {function(String)} Function description"); @@ -37,7 +37,7 @@ describe("documentjs/lib/tags/property",function(){ name: "Foo.bar", type: "property", types: [ - {type: "can.Map", description: "can.Map description"}, + {type: "CanMap", description: "CanMap description"}, {type: "Object", description: "Object description", options: []}, { constructs: undefined, diff --git a/lib/tags/signature.js b/lib/tags/signature.js index 20b8cf068..49d27df41 100644 --- a/lib/tags/signature.js +++ b/lib/tags/signature.js @@ -10,9 +10,9 @@ * @codestart javascript * /** * * Capitalizes a string. - * * @@signature `can.capitalize(s)` Example: + * * @@signature `CanCapitalize(s)` Example: * * - * * can.capitalize("foo") //-> "Bar" + * * CanCapitalize("foo") //-> "Bar" * * * * @@param {String} s the string to be lowercased. * * @@return {String} a string with the first character capitalized, diff --git a/package.json b/package.json index e51195f9d..d7278375c 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ }, "scripts": { "test": "mocha test.js --reporter spec", - "postinstall": "install-engine-dependencies", "publish": "git push origin && git push origin --tags", "release:prerelease": "npm version prerelease && npm publish", "release:patch": "npm version patch && npm publish", @@ -23,18 +22,21 @@ "release:major": "npm version major && npm publish" }, "devDependencies": { + "connect": "^2.14.4", "mocha": ">= 1.18.0", "qunit-mocha-ui": "*", "rimraf": "2.1", - "connect": "^2.14.4" + "zombie": "^4.2.1" }, "dependencies": { "async": "~0.2.7", - "can": "2.3.8", + "can-control": "3.0.10", + "can-map": "3.0.7", + "can-stache": "3.0.24", + "can-util": "3.6.1", "chokidar": "^1.0.0-rc5", "cross-spawn-async": "^2.1.9", "documentjs-github-download": "^0.3.0", - "engine-dependencies": "^0.2.0", "esprima": "~2.5.0", "fs-extra": "^0.24.0", "glob": "~6.0.3", @@ -45,43 +47,13 @@ "md5": "^2.0.0", "minimatch": "~1.0.0", "q": "~1.0.1", - "steal": "0.13.X", - "steal-tools": "0.13.X", + "steal": "0.16.X", + "steal-stache": "3.0.7", + "steal-tools": "0.16.X", "yargs": "^1.3.1" }, - "engineDependencies": { - "node": { - "0.10.x": { - "devDependencies": { - "zombie": "^3.1.1" - } - }, - "0.12.x": { - "devDependencies": { - "zombie": "^3.1.1" - } - }, - "^4.0.0": { - "devDependencies": { - "zombie": "^4.2.1" - } - }, - "^5.0.0": { - "devDependencies": { - "zombie": "^4.2.1" - } - } - }, - "iojs": { - "^3.0.0": { - "devDependencies": { - "zombie": "^4.1.0" - } - } - } - }, "system": { - "npmDependencies": [] + "npmAlgorithm": "flat" }, "homepage": "http://documentjs.com", "repository": { diff --git a/site/default/static/build.js b/site/default/static/build.js index 0a4323902..46a78d3ac 100644 --- a/site/default/static/build.js +++ b/site/default/static/build.js @@ -19,26 +19,95 @@ module.exports = function(options, folders){ if(options.devBuild) { var promise = Q.all([ fsx.copy(path.join(folders.build), path.join(folders.dist) ), - fsx.copy(path.join("node_modules","steal"), path.join(folders.dist,"steal") ), - fsx.copy(path.join("node_modules","can"), path.join(folders.dist,"can") ), - fsx.copy(path.join("node_modules","jquery"), path.join(folders.dist,"jquery") ) + fsx.copy(path.join("node_modules"), path.join(folders.dist) ), ]); // copy everything and steal.js return promise; } else { + // manually configure Can/Steal packages for Steal build + // if can-* or steal-* packages are updated, this list will also likely need to be updated + // TODO this should be automated first + + // root packages + var npmPackages = [ + 'can-cid', + 'can-compute', + 'can-construct', + 'can-control', + 'can-event', + 'can-map', + 'can-namespace', + 'can-observation', + 'can-simple-map', + 'can-stache', + 'can-stache-bindings', + 'can-types', + 'can-view-callbacks', + 'can-view-import', + 'can-view-live', + 'can-view-model', + 'can-view-nodelist', + 'can-view-parser', + 'can-view-scope', + 'can-view-target', + 'steal-stache', + ]; + + // conditional map + var map = { + 'can-compute': { + 'proto-compute': 'can-compute/proto-compute', + }, + 'can-map': { + 'bubble': 'can-map/bubble', + 'map-helpers': 'can-map/map-helpers', + }, + 'can-stache': { + 'helpers/core': 'can-stache/helpers/core', + 'helpers/converter': 'can-stache/helpers/converter', + 'src/html_section': 'can-stache/src/html_section', + 'src/intermediate_and_imports': 'can-stache/src/intermediate_and_imports', + 'src/mustache_core': 'can-stache/src/mustache_core', + 'src/text_section': 'can-stache/src/text_section', + }, + 'can-view-live': { + 'lib/attr': 'can-view-live/lib/attr', + 'lib/attrs': 'can-view-live/lib/attrs', + 'lib/core': 'can-view-live/lib/core', + 'lib/html': 'can-view-live/lib/html', + 'lib/list': 'can-view-live/lib/list', + 'lib/text': 'can-view-live/lib/text', + }, + 'can-view-scope': { + 'compute_data': 'can-view-scope/compute_data', + 'reference-map': 'can-view-scope/reference-map', + }, + 'steal-stache': { + 'add-bundles': 'steal-stache/add-bundles', + }, + }; + var paths = { + 'jquery': path.relative(__dirname, require.resolve('jquery')), + 'can-util/*': path.dirname(path.relative(__dirname, require.resolve('can-util'))) + '/*.js', + 'steal-stache': path.relative(__dirname, require.resolve('steal-stache')) + }; + + // generate the remaining paths + npmPackages.forEach(function(pkg) { + paths[pkg + '/*'] = path.dirname(path.relative(__dirname, require.resolve(pkg))) + '/*.js'; + paths[pkg] = path.relative(__dirname, require.resolve(pkg)); + }); - var jQueryRelative = path.relative( __dirname, require.resolve("jquery") ); - var canJSRelative = path.dirname( path.relative( __dirname, require.resolve("can") ) )+"/*.js"; - // makes sure can is not added to the global so we can build nicely. global.GLOBALCAN = false; return stealTools.build({ main: "static", - config: __dirname+"/config.js", + config: __dirname + "/config.js", bundlesPath: __dirname+"/bundles", - paths: { - "jquery": jQueryRelative, - "can/*": canJSRelative + paths: paths, + map: map, + ext: { + 'stache': 'steal-stache' } },{ minify: options.minifyBuild === false ? false : true, @@ -65,7 +134,4 @@ module.exports = function(options, folders){ }); } - - - }; diff --git a/site/default/static/config.js b/site/default/static/config.js index f41da0e2d..c555c92e4 100644 --- a/site/default/static/config.js +++ b/site/default/static/config.js @@ -1,23 +1,17 @@ (function () { + var map = require('./map'); var isClient = typeof window !== "undefined"; var configData = { - map: { - "jquery/jquery": "jquery", - "can/util/util": "can/util/jquery/jquery", - "benchmark/benchmark": "benchmark", - "mustache": "can/view/mustache/system" + map: map, + ext: { + 'stache': 'steal-stache' }, meta: { jquery: { exports: "jQuery" }, prettify: {format: "global"} - }, - ext: { - ejs: "can/view/ejs/system", - mustache: "can/view/mustache/system", - stache: "can/view/stache/system" } }; @@ -29,6 +23,7 @@ }; } + System.config(configData); })(); diff --git a/site/default/static/content_list.js b/site/default/static/content_list.js index 9e152e10a..682c0e231 100644 --- a/site/default/static/content_list.js +++ b/site/default/static/content_list.js @@ -1,85 +1,86 @@ -steal("can/control","jquery","can/observe",function(Control, $){ +var CanControl = require("can-control"); +var $ = require("jquery"); +require("can-map"); - var contentList = function(sections, tag){ - var element = $("<"+tag+">"); - $.each(sections, function(i, section){ - $li = $("
  • "); - $a = $("").attr("href","#"+section.id).text(section.text); - element.append( $li.append($a) ); - - if(section.sections && section.sections.length) { - $li.append( contentList(section.sections, tag) ); - } +var contentList = function(sections, tag){ + var element = $("<"+tag+">"); + $.each(sections, function(i, section){ + $li = $("
  • "); + $a = $("").attr("href","#"+section.id).text(section.text); + element.append( $li.append($a) ); + + if(section.sections && section.sections.length) { + $li.append( contentList(section.sections, tag) ); + } + }); + return element; +}; + +module.exports = CanControl.extend({ + init: function() { + var sections = []; + this.$element = $(this.element); + + this.collectSignatures().each(function(ix) { + var h2 = $('h2', this); + this.id = 'sig_' + h2.text().replace(/\s/g,"").replace(/[^\w]/g,"_"); + //this.id = encodeURIComponent(h2.text()); + sections.push({id: this.id, text: h2.text()}); }); - return element; - }; - return can.Control.extend({ - init: function() { - var sections = []; - - this.collectSignatures().each(function(ix) { - var h2 = $('h2', this); - this.id = 'sig_' + h2.text().replace(/\s/g,"").replace(/[^\w]/g,"_"); - //this.id = encodeURIComponent(h2.text()); - sections.push({id: this.id, text: h2.text()}); - }); - - var headingStack = [], - last = function(){ - return headingStack[ headingStack.length -1 ] - }; - - var ch = this.collectHeadings().each(function(ix) { - var el = $(this); - this.id = 'section_' + el.text().replace(/\s/g,"").replace(/[^\w]/g,"_"); - var num = +this.nodeName.substr(1); - var section = { - id: this.id, - text: el.text(), - num: num, - sections: [] - }; - - while(last() && (last().num >= num) ) { - headingStack.pop(); - } - - if(!headingStack.length) { - sections.push(section); - headingStack.push(section); - } else { - last().sections.push(section); - headingStack.push(section); - } - }); - - this.element.html( contentList(sections, - ( ( window.docObject.outline && window.docObject.outline.tag ) || "ul" ).toLowerCase() ) ); - - if(window.location.hash.length) { - var id = window.location.hash.replace('#', ''), - anchor = document.getElementById(id); + var headingStack = [], + last = function(){ + return headingStack[ headingStack.length -1 ] + }; + + var ch = this.collectHeadings().each(function(ix) { + var el = $(this); + this.id = 'section_' + el.text().replace(/\s/g,"").replace(/[^\w]/g,"_"); + var num = +this.nodeName.substr(1); + var section = { + id: this.id, + text: el.text(), + num: num, + sections: [] + }; + + while(last() && (last().num >= num) ) { + headingStack.pop(); + } - if(anchor) { - anchor.scrollIntoView(true); - } + if(!headingStack.length) { + sections.push(section); + headingStack.push(section); + } else { + last().sections.push(section); + headingStack.push(section); } - }, - collectSignatures: function() { - var cloned = $('.content .signature').clone(); - // remove release numbers - cloned.find(".release").remove(); - return cloned; - }, - collectHeadings: function() { - var depth = ( window.docObject.outline && window.docObject.outline.depth ) || 1; - var headings = []; - for(var i = 0; i < depth; i++) { - headings.push("h"+(i+2)); + }); + + this.$element.html( contentList(sections, + ( ( window.docObject.outline && window.docObject.outline.tag ) || "ul" ).toLowerCase() ) ); + + if(window.location.hash.length) { + var id = window.location.hash.replace('#', ''), + anchor = document.getElementById(id); + + if(anchor) { + anchor.scrollIntoView(true); } - return $('.content .comment').find(headings.join(",")); } - }); - -}); \ No newline at end of file + }, + collectSignatures: function() { + var cloned = $('.content .signature').clone(); + // remove release numbers + cloned.find(".release").remove(); + return cloned; + }, + collectHeadings: function() { + var depth = ( window.docObject.outline && window.docObject.outline.depth ) || 1; + var headings = []; + for(var i = 0; i < depth; i++) { + headings.push("h"+(i+2)); + } + return $('.content .comment').find(headings.join(",")); + } +}); diff --git a/site/default/static/demo_frame.js b/site/default/static/demo_frame.js index 2274b1978..9bdb2fde2 100644 --- a/site/default/static/demo_frame.js +++ b/site/default/static/demo_frame.js @@ -1,13 +1,15 @@ -steal("can/control","./demo_frame.mustache!","jquery","can/observe","./prettify.js",function(Control,demoFrameMustache,$){ - - +var CanControl = require("can-control"); +var demoFrameTemplate = require("./demo_frame.stache!"); +var $ = require("jquery"); +require("can-map"); +require("./prettify"); -return can.Control.extend({ +module.exports = CanControl.extend({ init: function() { - var docConfig = window.docConfig || {}; + this.element = $(this.element); // Render out the demo container. - this.element.html(demoFrameMustache( {demoSrc: (docConfig.demoSrcRoot || ".." )+'/' + this.element.data('demoSrc')})); + this.element.html(demoFrameTemplate( {demoSrc: (docConfig.demoSrcRoot || ".." )+'/' + this.element.data('demoSrc')})); // Start with the demo tab showing. this.showTab('demo'); @@ -85,5 +87,3 @@ return can.Control.extend({ return prettyPrintOne(unescaped.replace(/ - $('.iframe_wrapper', this.element).each(function() { - var wrapper = $(this), - iframe = $('