From 48f0957dde728b050e2d8f76db81cbf12cffd42a Mon Sep 17 00:00:00 2001 From: Martin Staffa Date: Sun, 20 Aug 2017 15:44:01 +0200 Subject: [PATCH 1/5] revert: chore(docs-app): load example files based on active deployment This reverts commit d91a6bdbc66098ff7bbf8fa435ae5652fe6a795f. The runnable examples cannot rely on the CDN for loading the common files, because the CDN push does not happen at the same time as the docs are generated, which means the doc examples are non-functional for an unforeseeable time. --- docs/app/src/app.js | 1 - docs/app/src/examples.js | 8 +------- docs/config/index.js | 12 +----------- docs/config/processors/index-page.js | 10 ---------- docs/config/services/deployments/debug.js | 1 - docs/config/services/deployments/default.js | 1 - docs/config/services/deployments/jquery.js | 1 - docs/config/services/deployments/production.js | 1 - .../templates/examples/runnableExample.template.html | 2 +- 9 files changed, 3 insertions(+), 34 deletions(-) diff --git a/docs/app/src/app.js b/docs/app/src/app.js index 20e351ae97e1..df6272b0bf0b 100644 --- a/docs/app/src/app.js +++ b/docs/app/src/app.js @@ -14,7 +14,6 @@ angular.module('docsApp', [ 'search', 'tutorials', 'versions', - 'deployment', 'ui.bootstrap.dropdown' ]) diff --git a/docs/app/src/examples.js b/docs/app/src/examples.js index c9ffb20f016a..b5b21c5393fa 100644 --- a/docs/app/src/examples.js +++ b/docs/app/src/examples.js @@ -18,13 +18,7 @@ angular.module('examples', []) return { restrict: 'C', scope : true, - controller : ['$scope', 'DEPLOYMENT', function($scope, DEPLOYMENT) { - var exampleIndexFile = (DEPLOYMENT === 'default' ? 'index' : 'index-' + DEPLOYMENT) + '.html'; - - $scope.getExampleIndex = function(basePath) { - return basePath + '/' + exampleIndexFile; - }; - + controller : ['$scope', function($scope) { $scope.setTab = function(index) { var tab = $scope.tabs[index]; $scope.activeTabIndex = index; diff --git a/docs/config/index.js b/docs/config/index.js index e228fc34b72e..ab5e45a3f8dc 100644 --- a/docs/config/index.js +++ b/docs/config/index.js @@ -112,10 +112,6 @@ module.exports = new Package('angularjs', [ docTypes: ['indexPage'], pathTemplate: '.', outputPathTemplate: '${id}.html' - }, { - docTypes: ['deploymentData'], - pathTemplate: '.', - outputPathTemplate: 'js/${id}.js' }); computePathsProcessor.pathTemplates.push({ @@ -129,14 +125,8 @@ module.exports = new Package('angularjs', [ outputPathTemplate: 'partials/${area}/${moduleName}/${groupType}.html' }); - computePathsProcessor.pathTemplates.push({ - docTypes: ['example'], - pathTemplate: 'examples/${example.id}', - outputPathTemplate: 'examples/${example.id}/index${deploymentQualifier}.html' - }); - computeIdsProcessor.idTemplates.push({ - docTypes: ['overview', 'tutorial', 'e2e-test', 'indexPage', 'deploymentData'], + docTypes: ['overview', 'tutorial', 'e2e-test', 'indexPage'], getId: function(doc) { return doc.fileInfo.baseName; }, getAliases: function(doc) { return [doc.id]; } }); diff --git a/docs/config/processors/index-page.js b/docs/config/processors/index-page.js index 3a7c8d210e47..102e3f53db50 100644 --- a/docs/config/processors/index-page.js +++ b/docs/config/processors/index-page.js @@ -35,17 +35,7 @@ module.exports = function generateIndexPagesProcessor() { indexDoc.id = 'index' + (deployment.name === 'default' ? '' : '-' + deployment.name); - var deploymentDoc = { - docType: 'deploymentData', - id: 'deployment-data-' + deployment.name, - template: 'angular-service.template.js', - ngModuleName: 'deployment', - serviceName: 'DEPLOYMENT', - serviceValue: deployment.name - }; - docs.push(indexDoc); - docs.push(deploymentDoc); }); } }; diff --git a/docs/config/services/deployments/debug.js b/docs/config/services/deployments/debug.js index b2b9da22b842..39cd327496e8 100644 --- a/docs/config/services/deployments/debug.js +++ b/docs/config/services/deployments/debug.js @@ -26,7 +26,6 @@ module.exports = function debugDeployment(getVersion) { 'js/all-versions-data.js', 'js/pages-data.js', 'js/nav-data.js', - 'js/deployment-data-debug.js', 'js/docs.js' ], stylesheets: [ diff --git a/docs/config/services/deployments/default.js b/docs/config/services/deployments/default.js index eb1778a91903..181994f1e740 100644 --- a/docs/config/services/deployments/default.js +++ b/docs/config/services/deployments/default.js @@ -26,7 +26,6 @@ module.exports = function defaultDeployment(getVersion) { 'js/all-versions-data.js', 'js/pages-data.js', 'js/nav-data.js', - 'js/deployment-data-default.js', 'js/docs.min.js' ], stylesheets: [ diff --git a/docs/config/services/deployments/jquery.js b/docs/config/services/deployments/jquery.js index 592de9dffabb..67263832e4f2 100644 --- a/docs/config/services/deployments/jquery.js +++ b/docs/config/services/deployments/jquery.js @@ -30,7 +30,6 @@ module.exports = function jqueryDeployment(getVersion) { 'js/all-versions-data.js', 'js/pages-data.js', 'js/nav-data.js', - 'js/deployment-data-jquery.js', 'js/docs.min.js' ], stylesheets: [ diff --git a/docs/config/services/deployments/production.js b/docs/config/services/deployments/production.js index 859c490388ba..8f6742b0be1c 100644 --- a/docs/config/services/deployments/production.js +++ b/docs/config/services/deployments/production.js @@ -43,7 +43,6 @@ module.exports = function productionDeployment(getVersion) { 'https://code.angularjs.org/snapshot/docs/js/all-versions-data.js', 'js/pages-data.js', 'js/nav-data.js', - 'js/deployment-data-production.js', 'js/docs.min.js' ], stylesheets: [ diff --git a/docs/config/templates/examples/runnableExample.template.html b/docs/config/templates/examples/runnableExample.template.html index 41a7a3502671..26d689c10ad5 100644 --- a/docs/config/templates/examples/runnableExample.template.html +++ b/docs/config/templates/examples/runnableExample.template.html @@ -18,7 +18,7 @@ {% endfor %} - + From 307293818636efc3f7f81903f6a2255447e67a77 Mon Sep 17 00:00:00 2001 From: Martin Staffa Date: Sun, 20 Aug 2017 16:47:51 +0200 Subject: [PATCH 2/5] chore(doc-gen): include source files from code.angularjs.org for production plnkr examples --- docs/app/e2e/app.scenario.js | 19 ++++++++++++++++++ .../config/services/deployments/production.js | 20 +++++++++---------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/docs/app/e2e/app.scenario.js b/docs/app/e2e/app.scenario.js index 823f1408c2e4..1333870eff4d 100644 --- a/docs/app/e2e/app.scenario.js +++ b/docs/app/e2e/app.scenario.js @@ -49,6 +49,25 @@ describe('docs.angularjs.org', function() { }); + it('should include the files for the embedded examples from the same domain', function() { + browser.get('build/docs/index-production.html#!api/ng/directive/ngClick'); + + var origin = browser.executeScript('return document.location.origin;'); + + var exampleIFrame = element(by.name('example-ng-click')); + + // This is technically an implementation detail, but if this changes, then there's a good + // chance the deployment process changed + expect(exampleIFrame.getAttribute('src')).toContain('examples/example-ng-click/index.html'); + + browser.switchTo().frame('example-ng-click'); + + var scriptEl = element(by.tagName('script')); + + // Ensure the included file is from the same domain + expect(scriptEl.getAttribute('src')).toContain(origin); + }); + it('should be resilient to trailing slashes', function() { browser.get('build/docs/index-production.html#!/api/ng/function/angular.noop/'); diff --git a/docs/config/services/deployments/production.js b/docs/config/services/deployments/production.js index 8f6742b0be1c..7d92001e2e1d 100644 --- a/docs/config/services/deployments/production.js +++ b/docs/config/services/deployments/production.js @@ -7,24 +7,24 @@ var angularCodeUrl = '//code.angularjs.org/'; var cdnUrl = googleCdnUrl + versionInfo.cdnVersion; -// The plnkr examples must use the code.angularjs.org repo for the snapshot, -// and the cdn for the tagged version and, if the build is not tagged, the currentVersion. -// -// The currentVersion may not be available on the cdn (e.g. if built locally, or hasn't been pushed -// yet). This will lead to a 404, but this is preferable to loading a version with which the example -// might not work (possibly in subtle ways). -var examplesCdnUrl = versionInfo.currentVersion.isSnapshot ? +// The "examplesCdnUrl" here applies to the examples when they are opened in plnkr.co. +// The embedded examples instead always include the files from the *default* deployment, +// to ensure that the source files are always available. +// The plnkr examples must always use the code.angularjs.org source files. +// We cannot rely on the CDN files here, because they are not deployed by the time +// docs.angularjs.org and code.angularjs.org need them. +var examplesDependencyPath = versionInfo.currentVersion.isSnapshot ? (angularCodeUrl + 'snapshot') : - (googleCdnUrl + (versionInfo.currentVersion.version || versionInfo.currentVersion)); + (angularCodeUrl + (versionInfo.currentVersion.version || versionInfo.currentVersion.version)); module.exports = function productionDeployment(getVersion) { return { name: 'production', examples: { commonFiles: { - scripts: [examplesCdnUrl + '/angular.min.js'] + scripts: [examplesDependencyPath + '/angular.min.js'] }, - dependencyPath: examplesCdnUrl + '/' + dependencyPath: examplesDependencyPath }, scripts: [ cdnUrl + '/angular.min.js', From 66dff7cf5f8dc2827fd8cb7dff4a0eb57ce317f5 Mon Sep 17 00:00:00 2001 From: Martin Staffa Date: Tue, 22 Aug 2017 12:16:04 +0200 Subject: [PATCH 3/5] chore(docs.angularjs.org): fix docs deploy for source file changes Since the embedded examples in the docs app now include the local source files instead of CDN files, we need to include the source files into the folder that is deployed to Firebase hosting --- .travis.yml | 3 ++- Gruntfile.js | 35 +++++++++++++++++++++++++++++++---- firebase.json | 4 ++-- scripts/travis/build.sh | 3 +-- 4 files changed, 36 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index b0b909f33c9d..4f4841e9bc03 100644 --- a/.travis.yml +++ b/.travis.yml @@ -78,6 +78,7 @@ jobs: keep_alive & deploy: - provider: firebase + # the upload folder for firebase is configured in /firebase.json skip_cleanup: true token: secure: $FIREBASE_TOKEN @@ -92,7 +93,7 @@ jobs: secret_access_key: secure: tHIFdSq55qkyZf9zT/3+VkhUrTvOTMuswxXU3KyWaBrSieZqG0UnUDyNm+n3lSfX95zEl/+rJAWbfvhVSxZi13ndOtvRF+MdI1cvow2JynP0aDSiPffEvVrZOmihD6mt2SlMfhskr5FTduQ69kZG6DfLcve1PPDaIwnbOv3phb8= bucket: code-angularjs-org-338b8.appspot.com - local-dir: upload + local-dir: uploadCode detect_encoding: true # detects gzip compression on: repo: angular/angular.js diff --git a/Gruntfile.js b/Gruntfile.js index 8de52bca501f..0808eb468fe7 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -311,7 +311,29 @@ module.exports = function(grunt) { copy: { i18n: { files: [ - { src: 'src/ngLocale/**', dest: 'build/i18n/', expand: true, flatten: true } + { + src: 'src/ngLocale/**', + dest: 'build/i18n/', + expand: true, + flatten: true + } + ] + }, + deployFirebaseDocs: { + files: [ + // The source files are needed by the embedded examples in the docs app. + { + src: 'build/angular*.{js.map,min.js}', + dest: 'uploadDocs/', + expand: true, + flatten: true + }, + { + cwd: 'build/docs', + src: '**', + dest: 'uploadDocs/', + expand: true + } ] } }, @@ -326,14 +348,14 @@ module.exports = function(grunt) { dot: true, dest: dist + '/' }, - firebaseCodeDeploy: { + deployFirebaseCode: { options: { mode: 'gzip' }, src: ['**'], cwd: 'build', expand: true, - dest: 'upload/' + deployVersion + '/' + dest: 'uploadCode/' + deployVersion + '/' } }, @@ -427,7 +449,7 @@ module.exports = function(grunt) { 'collect-errors', 'write', 'docs', - 'copy', + 'copy:i18n', 'compress:build' ]); grunt.registerTask('ci-checks', [ @@ -435,6 +457,11 @@ module.exports = function(grunt) { 'merge-conflict', 'eslint' ]); + grunt.registerTask('prepareFirebaseDeploy', [ + 'package', + 'compress:deployFirebaseCode', + 'copy:deployFirebaseDocs' + ]); grunt.registerTask('default', ['package']); }; diff --git a/firebase.json b/firebase.json index 3427962f39bd..bbf70bed2a9f 100644 --- a/firebase.json +++ b/firebase.json @@ -1,6 +1,6 @@ { "hosting": { - "public": "build/docs", + "public": "uploadDocs", "ignore": [ "/index.html", "/index-debug.html", @@ -16,7 +16,7 @@ "destination": "/index-production.html" }, { - "source": "**/*!(.jpg|.jpeg|.gif|.png|.html|.js|.json|.css|.svg|.ttf|.woff|.woff2|.eot)", + "source": "**/*!(.jpg|.jpeg|.gif|.png|.html|.js|.map|.json|.css|.svg|.ttf|.woff|.woff2|.eot)", "destination": "/index-production.html" } ] diff --git a/scripts/travis/build.sh b/scripts/travis/build.sh index f7b33c3129da..b0ca7489e919 100755 --- a/scripts/travis/build.sh +++ b/scripts/travis/build.sh @@ -48,8 +48,7 @@ case "$JOB" in "deploy") # we never deploy on Pull requests, so it's safe to skip the build here if [[ "$TRAVIS_PULL_REQUEST" == "false" ]]; then - grunt package - grunt compress:firebaseCodeDeploy + grunt prepareFirebaseDeploy else echo "Skipping build because Travis has been triggered by Pull Request" fi From 59a9c1319de13b9224644b28b799bed33fe4c0d9 Mon Sep 17 00:00:00 2001 From: Oscar Busk Date: Wed, 23 Aug 2017 15:08:55 +0200 Subject: [PATCH 4/5] docs(guide/production): add more info on `debugInfoEnabled()` Add bullet mentioning how placeholder comments are affected. Closes #16155 --- docs/content/guide/production.ngdoc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/content/guide/production.ngdoc b/docs/content/guide/production.ngdoc index 10621884bf39..8fd465361b6b 100644 --- a/docs/content/guide/production.ngdoc +++ b/docs/content/guide/production.ngdoc @@ -20,6 +20,9 @@ and adds CSS classes to data-bound elements: CSS class are attached to the corresponding element. These scope references can then be accessed via `element.scope()` and `element.isolateScope()`. +- Placeholder comments for structural directives will contain information about what directive +and binding caused the placeholder. E.g. ``. + Tools like [Protractor](https://github.com/angular/protractor) and [Batarang](https://github.com/angular/angularjs-batarang) need this information to run, but you can disable this in production for a significant performance boost with: From 233a93f6e01f7f06d17cdea8a7b2a7098803639d Mon Sep 17 00:00:00 2001 From: Oscar Busk Date: Wed, 23 Aug 2017 15:02:06 +0200 Subject: [PATCH 5/5] docs($compileProvider): add more info on `debugInfoEnabled()` Add more info on what `debugInfoEnabled()` affects. Closes #16154 --- src/ng/compile.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ng/compile.js b/src/ng/compile.js index 615e42516fc1..143023f2aa63 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -1387,7 +1387,12 @@ function $CompileProvider($provide, $$sanitizeUriProvider) { * binding information and a reference to the current scope on to DOM elements. * If enabled, the compiler will add the following to DOM elements that have been bound to the scope * * `ng-binding` CSS class + * * `ng-scope` and `ng-isolated-scope` CSS classes * * `$binding` data property containing an array of the binding expressions + * * Data properties used by the {@link angular.element#methods `scope()`/`isolateScope()` methods} to return + * the element's scope. + * * Placeholder comments will contain information about what directive and binding caused the placeholder. + * E.g. ``. * * You may want to disable this in production for a significant performance boost. See * {@link guide/production#disabling-debug-data Disabling Debug Data} for more.