docs: allow multiple versions

This commit is contained in:
Andy Joslin
2014-03-12 15:51:49 -06:00
parent 8936d9e525
commit 4813fd0bb9
16 changed files with 131 additions and 74 deletions

View File

@@ -7,6 +7,7 @@ var basePackage = require('dgeni-packages/ngdoc');
var pkg = require('../package.json');
module.exports = function(config) {
config.set('currentVersion', process.env.DOC_VERSION || 'nightly');
config = basePackage(config);
@@ -19,7 +20,7 @@ module.exports = function(config) {
config.set('basePath', __dirname);
config.set('source.projectPath', '.');
config.set('rendering.outputFolder', '../tmp/ionic-site');
config.set('rendering.contentsFolder', 'docs/angularjs');
config.set('rendering.contentsFolder', 'docs/' + config.get('currentVersion'));
config.set('processing.api-docs', {
outputPath: '${area}/${module}/${docType}/${name}/index.md',
@@ -60,8 +61,8 @@ module.exports = function(config) {
config.append('processing.processors', [
require('./processors/git-data'),
require('./processors/keywords'),
require('./processors/versions-data'),
require('./processors/pages-data'),
require('./processors/index-page'),
require('./processors/debug-dump')
]);

View File

@@ -4,9 +4,10 @@ var log = require('winston');
module.exports = {
name: 'link',
description: 'Process inline link tags (of the form {@link some/uri Some Title}), replacing them with HTML anchors',
handlerFactory: function(partialNames) {
handlerFactory: function(partialNames, config) {
return function handleLinkTags(doc, tagName, tagDescription) {
var version = config.get('currentVersion');
// Parse out the uri and title
return tagDescription.replace(INLINE_LINK, function(match, uri, title) {
@@ -18,7 +19,7 @@ module.exports = {
linkInfo.title = 'TODO:' + linkInfo.title;
}
return '<a href="/docs/angularjs/' + linkInfo.url + '">' + linkInfo.title + '</a>';
return '<a href="/docs/' + version + '/' + linkInfo.url + '">' + linkInfo.title + '</a>';
});
};
}

15
docs/nightly/index.md Normal file
View File

@@ -0,0 +1,15 @@
---
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.

View File

@@ -0,0 +1,22 @@
var path = require('canonical-path');
var log = require('winston');
var contentsFolder;
module.exports = {
name: 'index-page',
runAfter: ['adding-extra-docs'],
runBefore: ['extra-docs-added'],
description: 'Create documentation index page',
init: function(config) {
contentsFolder = config.get('rendering.contentsFolder');
},
process: function(docs) {
docs.push({
docType: 'index-page',
id: 'index-page',
template: 'index.template.html',
outputPath: path.resolve(__dirname, '../../tmp/ionic-site/', contentsFolder, 'index.md')
});
log.warn(docs[docs.length-1]);
}
};

View File

@@ -1,6 +1,8 @@
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',
@@ -128,6 +130,7 @@ var navGroupMappers = {
var outputFolder;
var processorConfig;
var currentVersion;
module.exports = {
name: 'pages-data',
@@ -138,6 +141,7 @@ module.exports = {
init: function(config) {
outputFolder = config.rendering.outputFolder;
processorConfig = config.get('processing.pages-data', {});
currentVersion = config.get('currentVersion');
},
process: function(docs) {
@@ -215,6 +219,27 @@ module.exports = {
areas: areas,
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);
}
};

View File

@@ -1,37 +0,0 @@
var _ = require('lodash');
module.exports = {
name: 'versions-data',
description: 'This plugin will create a new doc that will be rendered as an angularjs module ' +
'which will contain meta information about the versions of angular',
runAfter: ['adding-extra-docs', 'pages-data'],
runBefore: ['extra-docs-added'],
process: function(docs, gitData) {
var version = gitData.version;
var versions = gitData.versions;
if ( !version ) {
throw new Error('Invalid configuration. Please provide a valid `source.currentVersion` property');
}
if ( !versions ) {
throw new Error('Invalid configuration. Please provide a valid `source.previousVersions` property');
}
var versionDoc = {
docType: 'versions-data',
id: 'versions-data',
template: 'versions-data.template.js',
outputPath: 'js/versions-data.js',
};
versionDoc.currentVersion = version;
versionDoc.versions = _(versions)
.push(version)
.reverse()
.value();
docs.push(versionDoc);
}
};

View File

@@ -1,6 +1,5 @@
---
layout: docs_0.9.0
active: javascript
<@ include "lib/yaml.template.html" @>
title: "<@ if doc.title @><$ doc.title $><@ elif doc.module @><$ doc.groupType | title $>s in module ionic<@ else @>Pages<@ endif @>"
header_sub_title: "<$ doc.components.length $> <$ doc.groupType $>s"
doc: "<$ doc.groupType $>"

View File

@@ -1,6 +1,5 @@
---
layout: docs_0.9.0
active: javascript
<@ include "lib/yaml.template.html" @>
title: "<@ if doc.docType == "directive" @><$ doc.name | dashCase $><@ else @><$ doc.name $><@ endif @>"
header_sub_title: "<$ doc.docType | capital $> in module <$ doc.module $>"
doc: "<$ doc.name $>"

14
docs/templates/index.template.html vendored Normal file
View File

@@ -0,0 +1,14 @@
---
<@ include "lib/yaml.template.html" @>
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.

View File

3
docs/templates/lib/yaml.template.html vendored Normal file
View File

@@ -0,0 +1,3 @@
layout: docs_0.9.0
active: javascript
version: "nightly"

View File

@@ -42,7 +42,6 @@
<div class="docked-menu{% if page.active == "javascript" %} no-fixed{% endif %}">
<!-- Getting Started -->
<ul class="nav left-menu{% if page.active == "docs-overview" %} active-menu{% endif %}">
<li class="menu-title">
@@ -153,20 +152,31 @@
<!-- AngularJS -->
<ul class="nav left-menu{% if page.active == "javascript" %} active-menu{% endif %}">
<li class="menu-title">
<a href="{{ site.docs_0_9_0 }}/angularjs/<$ group.href $>">
<a href="<$ doc.currentVersion.href $>/<$ group.href $>">
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 %}>
<$ version.name $>
</option>
<@ endfor @>
</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="{{ site.docs_0_9_0}}/angularjs/<$ component.href $>">
<a href="<$ doc.currentVersion.href $>/<$ component.href $>">
<$ component.name $>
</a>
</li>
<@ else @>
<li class="menu-item{% if page.doc == "<$ component.name $>" %} active{% endif %}">
<a href="{{ site.docs_0_9_0 }}/angularjs/<$ component.href $>">
<a href="<$ doc.currentVersion.href $>/<$ component.href $>">
<@ if component.type == "directive" @>
<$ component.name | dashCase $>
<@ else @>

View File

@@ -1,4 +0,0 @@
// Meta data used by the AngularJS docs app
angular.module('versionsData', [])
.value('NG_VERSION', {$ doc.currentVersion | json $})
.value('NG_VERSIONS', {$ doc.versions | json $});

View File

@@ -36,8 +36,16 @@ if (IS_RELEASE_BUILD) {
gulp.task('default', ['build']);
gulp.task('build', ['bundle', 'sass']);
gulp.task('docs', function() {
return dgeni('docs/docs.config.js').generateDocs();
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');
return process.exit(1);
}
process.env.DOC_VERSION = docVersion;
dgeni('docs/docs.config.js').generateDocs().then(done);
});
var IS_WATCH = false;

View File

@@ -5,7 +5,7 @@
* Ported from github.com/EightMedia/hammer.js Gestures - thanks!
*/
(function(ionic) {
/**
* ionic.Gestures
* use this to create instances
@@ -23,7 +23,7 @@
// default settings
ionic.Gestures.defaults = {
// add css to the element to prevent the browser from doing
// its native behavior. this doesnt prevent the scrolling,
// its native behavior. this doesnt prevent the scrolling,
// but cancels the contextmenu, tap highlighting etc
// set to false to disable this
stop_browser_behavior: 'disable-user-behavior'
@@ -213,21 +213,21 @@
* this holds the last move event,
* used to fix empty touchend issue
* see the onTouch event for an explanation
* @type {Object}
* type {Object}
*/
var last_move_event = null;
/**
* when the mouse is hold down, this is true
* @type {Boolean}
* type {Boolean}
*/
var enable_detect = false;
/**
* when touch events have been fired, this is true
* @type {Boolean}
* type {Boolean}
*/
var touch_triggered = false;
@@ -456,7 +456,7 @@
ionic.Gestures.PointerEvent = {
/**
* holds all pointers
* @type {Object}
* type {Object}
*/
pointers: {},
@@ -536,7 +536,7 @@
* also used for cloning when dest is an empty object
* @param {Object} dest
* @param {Object} src
* @parm {Boolean} merge do a merge
* @param {Boolean} merge do a merge
* @returns {Object} dest
*/
extend: function extend(dest, src, merge) {
@@ -972,16 +972,16 @@
* like in the drag gesture we set it to 'drag' and in the swipe gesture we can
* check if the current gesture is 'drag' by accessing ionic.Gestures.detectionic.current.name
*
* @readonly
* readonly
* @param {ionic.Gestures.Instance} inst
* the instance we do the detection for
*
* @readonly
* readonly
* @param {Object} startEvent
* contains the properties of the first gesture detection in this sessionic.
* Used for calculations about timing, distance, etc.
*
* @readonly
* readonly
* @param {Object} lastEvent
* contains all the properties of the last gesture detect in this sessionic.
*
@@ -1007,7 +1007,7 @@
/**
* Hold
* Touch stays at the same place for x time
* @events hold
* events hold
*/
ionic.Gestures.gestures.Hold = {
name: 'hold',
@@ -1053,7 +1053,7 @@
/**
* Tap/DoubleTap
* Quick touch at a place or double at the same place
* @events tap, doubletap
* events tap, doubletap
*/
ionic.Gestures.gestures.Tap = {
name: 'tap',
@@ -1099,7 +1099,7 @@
/**
* Swipe
* triggers swipe events when the end velocity is above the threshold
* @events swipe, swipeleft, swiperight, swipeup, swipedown
* events swipe, swipeleft, swiperight, swipeup, swipedown
*/
ionic.Gestures.gestures.Swipe = {
name: 'swipe',
@@ -1135,7 +1135,7 @@
* Move with x fingers (default 1) around on the page. Blocking the scrolling when
* moving left and right is a good practice. When all the drag events are blocking
* you disable scrolling on that area.
* @events drag, drapleft, dragright, dragup, dragdown
* events drag, drapleft, dragright, dragup, dragdown
*/
ionic.Gestures.gestures.Drag = {
name: 'drag',
@@ -1256,7 +1256,7 @@
/**
* Transform
* User want to scale or rotate with 2 fingers
* @events transform, pinch, pinchin, pinchout, rotate
* events transform, pinch, pinchin, pinchout, rotate
*/
ionic.Gestures.gestures.Transform = {
name: 'transform',
@@ -1346,7 +1346,7 @@
/**
* Touch
* Called as first, tells the user has touched the screen
* @events touch
* events touch
*/
ionic.Gestures.gestures.Touch = {
name: 'touch',
@@ -1382,7 +1382,7 @@
/**
* Release
* Called as last, tells the user has released the screen
* @events release
* events release
*/
ionic.Gestures.gestures.Release = {
name: 'release',

View File

@@ -15,7 +15,7 @@
"karma-script-launcher": "~0.1.0",
"sauce-connect-launcher": "^0.2.2",
"dgeni": "^0.2.0",
"dgeni-packages": "git://github.com/ajoslin/dgeni-packages.git#api-config",
"dgeni-packages": "^0.7.1",
"jshint-stylish": "^0.1.5",
"gulp-template": "^0.1.1",
"gulp-concat": "^2.1.7",
@@ -35,7 +35,8 @@
"lodash": "^2.4.1",
"winston": "^0.7.2",
"minimist": "0.0.8",
"gulp-minify-css": "^0.3.0"
"gulp-minify-css": "^0.3.0",
"semver": "^2.2.1"
},
"licenses": [
{