mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
docs: fix problems with multiple versions
This commit is contained in:
@@ -59,6 +59,7 @@ module.exports = function(config) {
|
||||
});
|
||||
|
||||
config.append('processing.processors', [
|
||||
require('./processors/version-data'),
|
||||
require('./processors/git-data'),
|
||||
require('./processors/keywords'),
|
||||
require('./processors/pages-data'),
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
---
|
||||
layout: docs_0.9.0
|
||||
active: javascript
|
||||
title: Javascript
|
||||
header_sub_title: Extend Ionic even further with the power of AngularJS
|
||||
---
|
||||
|
||||
# AngularJS Extensions
|
||||
|
||||
Ionic is both a CSS framework and a Javascript UI library. Many components need Javascript in order to produce magic, though often components
|
||||
can easily be used without coding through framework extensions such as our AngularIonic extensions.
|
||||
|
||||
Ionic follows the View Controller pattern popularized in such frameworks as Cocoa Touch. In the View Controller pattern, we treat different sections of the interface as child Views or even child View Controllers that contain other views. View Controllers then "power" the Views inside of them to provide interaction and UI functionality. A great example is the Tab Bar View Controller which processes taps on a Tab Bar to switch between a set of viewable panes.
|
||||
|
||||
Explore our API docs for detailed information on the View Controllers and Javascript utilities available in Ionic.
|
||||
@@ -1,6 +1,7 @@
|
||||
var path = require('canonical-path');
|
||||
var log = require('winston');
|
||||
|
||||
var currentVersion;
|
||||
var contentsFolder;
|
||||
module.exports = {
|
||||
name: 'index-page',
|
||||
@@ -8,15 +9,16 @@ module.exports = {
|
||||
runBefore: ['extra-docs-added'],
|
||||
description: 'Create documentation index page',
|
||||
init: function(config) {
|
||||
currentVersion = config.get('currentVersion');
|
||||
contentsFolder = config.get('rendering.contentsFolder');
|
||||
},
|
||||
process: function(docs) {
|
||||
docs.push({
|
||||
docType: 'index-page',
|
||||
id: 'index-page',
|
||||
currentVersion: currentVersion,
|
||||
template: 'index.template.html',
|
||||
outputPath: path.resolve(__dirname, '../../tmp/ionic-site/', contentsFolder, 'index.md')
|
||||
outputPath: contentsFolder + '/index.md'
|
||||
});
|
||||
log.warn(docs[docs.length-1]);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
var _ = require('lodash');
|
||||
var path = require('canonical-path');
|
||||
var log = require('winston');
|
||||
var fs = require('fs');
|
||||
var semver = require('semver');
|
||||
|
||||
var AREA_NAMES = {
|
||||
api: 'API',
|
||||
@@ -209,7 +207,6 @@ module.exports = {
|
||||
.indexBy('path')
|
||||
.value();
|
||||
|
||||
|
||||
var docData = {
|
||||
docType: 'pages-data',
|
||||
id: 'pages-data',
|
||||
@@ -220,26 +217,6 @@ module.exports = {
|
||||
pages: pages
|
||||
};
|
||||
|
||||
var docsBaseFolder = path.resolve(__dirname, '../../tmp/ionic-site/docs');
|
||||
var pkg = require('../../package.json');
|
||||
|
||||
//Array of versions sorted backwards
|
||||
var versions = fs.readdirSync(docsBaseFolder)
|
||||
.filter(function(name) {
|
||||
return semver.valid(name) || name == 'nightly';
|
||||
})
|
||||
.sort(semver.rcompare);
|
||||
if (!_.contains(versions, currentVersion)) {
|
||||
versions.unshift(currentVersion);
|
||||
}
|
||||
docData.versions = versions.map(function(ver) {
|
||||
return {
|
||||
href: '/docs/' + ver,
|
||||
name: ver
|
||||
};
|
||||
});
|
||||
docData.currentVersion = _.find(docData.versions, { name: currentVersion });
|
||||
|
||||
docs.push(docData);
|
||||
}
|
||||
};
|
||||
|
||||
43
docs/processors/version-data.js
Normal file
43
docs/processors/version-data.js
Normal file
@@ -0,0 +1,43 @@
|
||||
var _ = require('lodash');
|
||||
var fs = require('fs');
|
||||
var semver = require('semver');
|
||||
var path = require('canonical-path');
|
||||
|
||||
var basePath;
|
||||
var outputFolder;
|
||||
var currentVersion;
|
||||
module.exports = {
|
||||
name: 'version-data',
|
||||
description: 'Give a list of all available versions to the template',
|
||||
runBefore: ['pages-data'],
|
||||
init: function(config) {
|
||||
basePath = config.get('basePath');
|
||||
outputFolder = config.get('rendering.outputFolder');
|
||||
currentVersion = config.get('currentVersion');
|
||||
},
|
||||
process: function(docs, extraData) {
|
||||
var docsBaseFolder = path.resolve(basePath, outputFolder, 'docs');
|
||||
|
||||
//Array of versions sorted backwards
|
||||
var versions = fs.readdirSync(docsBaseFolder)
|
||||
.filter(semver.valid)
|
||||
.sort(semver.rcompare);
|
||||
|
||||
//Add current version to the top of the list if not exists
|
||||
!_.contains(versions, currentVersion) && versions.unshift(currentVersion);
|
||||
|
||||
//Add nightly to the top of the list if not exists
|
||||
!_.contains(versions, 'nightly') && versions.unshift('nightly');
|
||||
|
||||
versions = versions.map(function(ver) {
|
||||
return {
|
||||
href: '/docs/' + ver,
|
||||
name: ver
|
||||
};
|
||||
});
|
||||
extraData.version = {
|
||||
list: versions,
|
||||
current: _.find(versions, { name: currentVersion })
|
||||
};
|
||||
}
|
||||
};
|
||||
3
docs/templates/lib/yaml.template.html
vendored
3
docs/templates/lib/yaml.template.html
vendored
@@ -1,3 +1,4 @@
|
||||
layout: docs_0.9.0
|
||||
active: javascript
|
||||
version: "nightly"
|
||||
version: "<$ version.current.name $>"
|
||||
versionHref: "<$ version.current.href $>"
|
||||
|
||||
17
docs/templates/pages-data.template.html
vendored
17
docs/templates/pages-data.template.html
vendored
@@ -152,31 +152,32 @@
|
||||
<!-- AngularJS -->
|
||||
<ul class="nav left-menu{% if page.active == "javascript" %} active-menu{% endif %}">
|
||||
<li class="menu-title">
|
||||
<a href="<$ doc.currentVersion.href $>/<$ group.href $>">
|
||||
<a href="{% if page.versionHref %}{{page.versionHref}}{% else %}{{site.docs_latest}}{% endif %}">
|
||||
Javascript
|
||||
</a>
|
||||
</li>
|
||||
<li class="menu-item">
|
||||
Version:
|
||||
<select style="width: 100px"
|
||||
onchange="window.location.href=this.options[this.selectedIndex].value">
|
||||
<@ for version in doc.versions @>
|
||||
<option value="<$ version.href $>"{% if page.version == "<$ version.name $>" %} selected{% endif %}>
|
||||
<select style="width: 100px"
|
||||
onchange="window.location.href=this.options[this.selectedIndex].value">
|
||||
<@ for version in version.list @>
|
||||
<option value="<$ version.href $>"
|
||||
{% if page.version == "<$ version.name $>" %}selected{% endif %}>
|
||||
<$ version.name $>
|
||||
</option>
|
||||
<@ endfor @>
|
||||
</select>
|
||||
</select>
|
||||
</li>
|
||||
<@ for component in doc.areas.api.navGroups[0].navItems @>
|
||||
<@ if component.type == "section" @>
|
||||
<li class="menu-subsection{% if page.docType == "<$ component.name $>" %} active{% endif %}">
|
||||
<a href="<$ doc.currentVersion.href $>/<$ component.href $>">
|
||||
<a href="{{page.versionHref}}/<$ component.href $>">
|
||||
<$ component.name $>
|
||||
</a>
|
||||
</li>
|
||||
<@ else @>
|
||||
<li class="menu-item{% if page.doc == "<$ component.name $>" %} active{% endif %}">
|
||||
<a href="<$ doc.currentVersion.href $>/<$ component.href $>">
|
||||
<a href="{{page.versionHref}}/<$ component.href $>">
|
||||
<@ if component.type == "directive" @>
|
||||
<$ component.name | dashCase $>
|
||||
<@ else @>
|
||||
|
||||
@@ -6,6 +6,7 @@ var http = require('http');
|
||||
var cp = require('child_process');
|
||||
var gulp = require('gulp');
|
||||
var pkg = require('./package.json');
|
||||
var semver = require('semver');
|
||||
var through = require('through');
|
||||
|
||||
var argv = require('minimist')(process.argv.slice(2));
|
||||
@@ -38,10 +39,8 @@ gulp.task('build', ['bundle', 'sass']);
|
||||
|
||||
gulp.task('docs', function(done) {
|
||||
var docVersion = argv['doc-version'];
|
||||
if (!docVersion) {
|
||||
console.log('Usage: gulp docs --doc-version=VERSION\n\n' +
|
||||
'Example: gulp docs --doc-version=nightly\n' +
|
||||
'Example: gulp docs --doc-version=0.9.33\n');
|
||||
if (docVersion != 'nightly' && !semver.valid(docVersion)) {
|
||||
console.log('Usage: gulp docs --doc-version=(nightly|versionName)');
|
||||
return process.exit(1);
|
||||
}
|
||||
process.env.DOC_VERSION = docVersion;
|
||||
|
||||
Reference in New Issue
Block a user