Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 0a2b723

Browse files
committed
chore(doc-gen, docs-app): create plnkr examples with correct Angular version
When the docs are based on the snapshot, the plnkr examples must use the snapshot files from code.angularjs.org Closes #15267 PR (#15269)
1 parent 0acb900 commit 0a2b723

File tree

3 files changed

+56
-5
lines changed

3 files changed

+56
-5
lines changed

docs/app/src/examples.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,8 @@ angular.module('examples', [])
181181
filePromises.push($http.get(exampleFolder + '/' + filename, { transformResponse: [] })
182182
.then(function(response) {
183183

184-
// The manifests provide the production index file but Plunkr wants
185-
// a straight index.html
186-
if (filename === 'index-production.html') {
184+
// Plunkr needs an index file that's simply named index.html
185+
if (filename === 'index-plnkr.html') {
187186
filename = 'index.html';
188187
}
189188

docs/config/index.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module.exports = new Package('angularjs', [
2323
.factory(require('./services/deployments/default'))
2424
.factory(require('./services/deployments/jquery'))
2525
.factory(require('./services/deployments/production'))
26+
.factory(require('./services/deployments/plnkr'))
2627

2728
.factory(require('./inline-tag-defs/type'))
2829

@@ -150,7 +151,8 @@ module.exports = new Package('angularjs', [
150151
generateProtractorTestsProcessor,
151152
generateExamplesProcessor,
152153
debugDeployment, defaultDeployment,
153-
jqueryDeployment, productionDeployment) {
154+
jqueryDeployment, productionDeployment,
155+
plnkrDeployment) {
154156

155157
generateIndexPagesProcessor.deployments = [
156158
debugDeployment,
@@ -170,7 +172,8 @@ module.exports = new Package('angularjs', [
170172
debugDeployment,
171173
defaultDeployment,
172174
jqueryDeployment,
173-
productionDeployment
175+
productionDeployment,
176+
plnkrDeployment
174177
];
175178
})
176179

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
'use strict';
2+
// Special deployment that is only used for the examples on plnkr.
3+
// While the embedded examples use the Angular files relative the docs folder,
4+
// plnkr uses the CDN urls, and needs to switch between Google CDN for tagged versions
5+
// and the code.angularjs.org server for the snapshot (master) version.
6+
7+
var versionInfo = require('../../../../lib/versions/version-info');
8+
var isSnapshot = versionInfo.currentVersion.isSnapshot;
9+
10+
var cdnUrl = isSnapshot ?
11+
'//code.angularjs.org/snapshot' :
12+
'//ajax.googleapis.com/ajax/libs/angularjs/' + versionInfo.cdnVersion;
13+
14+
module.exports = function plnkrDeployment(getVersion) {
15+
return {
16+
name: 'plnkr',
17+
examples: {
18+
commonFiles: {
19+
scripts: [cdnUrl + '/angular.min.js']
20+
},
21+
dependencyPath: cdnUrl + '/'
22+
},
23+
scripts: [
24+
cdnUrl + '/angular.min.js',
25+
cdnUrl + '/angular-resource.min.js',
26+
cdnUrl + '/angular-route.min.js',
27+
cdnUrl + '/angular-cookies.min.js',
28+
cdnUrl + '/angular-sanitize.min.js',
29+
cdnUrl + '/angular-touch.min.js',
30+
cdnUrl + '/angular-animate.min.js',
31+
'components/marked-' + getVersion('marked', 'node_modules', 'package.json') + '/lib/marked.js',
32+
'js/angular-bootstrap/dropdown-toggle.min.js',
33+
'components/lunr.js-' + getVersion('lunr.js') + '/lunr.min.js',
34+
'components/google-code-prettify-' + getVersion('google-code-prettify') + '/src/prettify.js',
35+
'components/google-code-prettify-' + getVersion('google-code-prettify') + '/src/lang-css.js',
36+
'js/versions-data.js',
37+
'js/pages-data.js',
38+
'js/nav-data.js',
39+
'js/docs.min.js'
40+
],
41+
stylesheets: [
42+
'components/bootstrap-' + getVersion('bootstrap') + '/css/bootstrap.min.css',
43+
'components/open-sans-fontface-' + getVersion('open-sans-fontface') + '/open-sans.css',
44+
'css/prettify-theme.css',
45+
'css/docs.css',
46+
'css/animations.css'
47+
]
48+
};
49+
};

0 commit comments

Comments
 (0)