mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
chore(docs): build to latest, mark latest in dropdown, remove /ionic
This commit is contained in:
@@ -20,13 +20,16 @@ module.exports = function(config) {
|
||||
config.set('basePath', __dirname);
|
||||
config.set('source.projectPath', '.');
|
||||
config.set('rendering.outputFolder', '../tmp/ionic-site');
|
||||
config.set('rendering.contentsFolder', 'docs/' + config.get('currentVersion'));
|
||||
|
||||
var versionData = require('./generate-versions')(config);
|
||||
config.set('versionData', versionData);
|
||||
config.set('rendering.contentsFolder', 'docs/' + versionData.current.folder);
|
||||
|
||||
config.set('processing.api-docs', {
|
||||
outputPath: '${area}/${module}/${docType}/${name}/index.md',
|
||||
path: '${area}/${module}/${docType}/${name}',
|
||||
moduleOutputPath: '${area}/${name}/index.md',
|
||||
modulePath: '${area}/${name}'
|
||||
outputPath: 'api/${docType}/${name}/index.md',
|
||||
path: 'api/${docType}/${name}',
|
||||
moduleOutputPath: 'api/module/${name}/index.md',
|
||||
modulePath: 'api/module/${name}'
|
||||
});
|
||||
|
||||
config.set('processing.pages-data', {
|
||||
@@ -60,11 +63,9 @@ module.exports = function(config) {
|
||||
|
||||
config.append('processing.processors', [
|
||||
require('./processors/version-data'),
|
||||
require('./processors/git-data'),
|
||||
require('./processors/keywords'),
|
||||
require('./processors/pages-data'),
|
||||
require('./processors/index-page'),
|
||||
require('./processors/debug-dump')
|
||||
]);
|
||||
|
||||
return config;
|
||||
|
||||
55
docs/generate-versions.js
Normal file
55
docs/generate-versions.js
Normal file
@@ -0,0 +1,55 @@
|
||||
var _ = require('lodash');
|
||||
var fs = require('fs');
|
||||
var semver = require('semver');
|
||||
var path = require('canonical-path');
|
||||
|
||||
module.exports = function(config) {
|
||||
var basePath = config.get('basePath');
|
||||
var outputFolder = config.get('rendering.outputFolder');
|
||||
var currentVersion = config.get('currentVersion');
|
||||
|
||||
var docsBaseFolder = path.resolve(basePath, outputFolder, 'docs');
|
||||
|
||||
var versions;
|
||||
try {
|
||||
versions = require(docsBaseFolder + '/version-data.json');
|
||||
} catch(e) {
|
||||
versions = [];
|
||||
}
|
||||
|
||||
var nightlyVersion = {
|
||||
href: '/docs/nightly',
|
||||
folder: 'nightly',
|
||||
name: 'nightly'
|
||||
};
|
||||
|
||||
if ( !_.find(versions, {name: currentVersion}) ) {
|
||||
//Make sure nightly version is always at the front of the list
|
||||
if (currentVersion != 'nightly') {
|
||||
versions.unshift({
|
||||
href: '/docs/latest',
|
||||
folder: 'latest',
|
||||
name: currentVersion
|
||||
});
|
||||
//Make sure that if we have a nightly version, it moves back to the front
|
||||
if (_.contains(versions, {name:'nightly'})) {
|
||||
_.remove(versions, {name:'nightly'});
|
||||
versions.unshift(nightlyVersion);
|
||||
}
|
||||
} else {
|
||||
versions.unshift(nightlyVersion);
|
||||
}
|
||||
}
|
||||
|
||||
//Add current version to the top of the list if not exists
|
||||
if (!_.find(versions, {name: currentVersion})) {
|
||||
versions.unshift(currentVersion);
|
||||
}
|
||||
|
||||
return {
|
||||
list: versions,
|
||||
current: _.find(versions, { name: currentVersion }),
|
||||
latest: _.find(versions, function(v) { return semver.valid(v.name); }) ||
|
||||
_.first(versions)
|
||||
};
|
||||
};
|
||||
@@ -7,7 +7,7 @@ module.exports = {
|
||||
handlerFactory: function(partialNames, config) {
|
||||
|
||||
return function handleLinkTags(doc, tagName, tagDescription) {
|
||||
var version = config.get('currentVersion');
|
||||
var versionData = config.get('versionData');
|
||||
|
||||
// Parse out the uri and title
|
||||
return tagDescription.replace(INLINE_LINK, function(match, uri, title) {
|
||||
@@ -19,7 +19,7 @@ module.exports = {
|
||||
linkInfo.title = 'TODO:' + linkInfo.title;
|
||||
}
|
||||
|
||||
return '<a href="/docs/' + version + '/' + linkInfo.url + '">' + linkInfo.title + '</a>';
|
||||
return '<a href="' + versionData.current.href + '/' + linkInfo.url + '">' + linkInfo.title + '</a>';
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
var writer = require('dgeni/lib/utils/doc-writer');
|
||||
var log = require('winston');
|
||||
var util = require("util");
|
||||
|
||||
var filter, outputPath, depth;
|
||||
|
||||
module.exports = {
|
||||
name: 'debug-dump',
|
||||
runBefore: ['write-files'],
|
||||
description: 'This processor dumps docs that match a filter to a file',
|
||||
init: function(config, injectables) {
|
||||
filter = config.get('processing.debug-dump.filter');
|
||||
outputPath = config.get('processing.debug-dump.outputPath');
|
||||
depth = config.get('processing.debug-dump.depth', 2);
|
||||
},
|
||||
process: function(docs) {
|
||||
if ( filter && outputPath ) {
|
||||
log.info('Dumping docs:', filter, outputPath);
|
||||
var filteredDocs = filter(docs);
|
||||
var dumpedDocs = util.inspect(filteredDocs, depth);
|
||||
return writer.writeFile(outputPath, dumpedDocs).then(function() {
|
||||
return docs;
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -1,28 +0,0 @@
|
||||
var pkg = require('../../package.json');
|
||||
|
||||
//TODO get versions from git
|
||||
|
||||
var version = {
|
||||
major: '0',
|
||||
minor: '9',
|
||||
dot: '26',
|
||||
codename: 'rabbit',
|
||||
full: 'Nightly',
|
||||
cdn: '0.9.26'
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
name: 'git-data',
|
||||
runBefore: ['loading-files'],
|
||||
description: 'This processor adds information from the local git repository to the extraData injectable',
|
||||
init: function(config, injectables) {
|
||||
injectables.value('gitData', {
|
||||
version: version,
|
||||
versions: [],
|
||||
info: 'git-data Information'
|
||||
});
|
||||
},
|
||||
process: function(extraData, gitData) {
|
||||
extraData.git = gitData;
|
||||
}
|
||||
};
|
||||
@@ -1,46 +1,13 @@
|
||||
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
|
||||
};
|
||||
process: function(docs, config, extraData) {
|
||||
extraData.version = config.get('versionData');
|
||||
docs.push({
|
||||
docType: 'version-data',
|
||||
id: 'version-data',
|
||||
template: 'version-data.template.json',
|
||||
outputPath: 'docs/version-data.json'
|
||||
});
|
||||
extraData.version = {
|
||||
list: versions,
|
||||
current: _.find(versions, { name: currentVersion }),
|
||||
//Stable = most recent (first) valid semver version
|
||||
stable: _.find(versions, function(v) { return semver.valid(v.name); }) ||
|
||||
_.first(versions)
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
4
docs/templates/pages-data.template.html
vendored
4
docs/templates/pages-data.template.html
vendored
@@ -24,7 +24,7 @@
|
||||
<option
|
||||
value="<$ ver.href $>/{% if page.path %}{{page.path}}{% endif %}"
|
||||
{% if page.version == "<$ ver.name $>" %}selected{% endif %}>
|
||||
<$ ver.name $>
|
||||
<$ ver.name $> <@ if version.latest.name == ver.name @>(latest)<@ endif @>
|
||||
</option>
|
||||
<@ endfor @>
|
||||
</select>
|
||||
@@ -57,7 +57,7 @@
|
||||
<!-- Docs: JavaScript -->
|
||||
<ul class="nav left-menu active-menu">
|
||||
<li class="menu-title">
|
||||
<a href="{% if page.versionHref %}{{page.versionHref}}{% else %}}<$ version.stable.href $>{% endif %}">
|
||||
<a href="{% if page.versionHref %}{{page.versionHref}}{% else %}}<$ version.latest.href $>{% endif %}">
|
||||
JavaScript
|
||||
</a>
|
||||
</li>
|
||||
|
||||
1
docs/templates/version-data.template.json
vendored
Normal file
1
docs/templates/version-data.template.json
vendored
Normal file
@@ -0,0 +1 @@
|
||||
<$ version.list | json $>
|
||||
Reference in New Issue
Block a user