Fix source links, display version and warn about outdated docs
This commit is contained in:
2
Makefile
2
Makefile
@@ -211,7 +211,7 @@ build/timestamps/jsdoc-$(BRANCH)-timestamp: config/jsdoc/api/index.md \
|
|||||||
build/timestamps/node-modules-timestamp
|
build/timestamps/node-modules-timestamp
|
||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
@rm -rf $(BUILD_HOSTED)/apidoc
|
@rm -rf $(BUILD_HOSTED)/apidoc
|
||||||
./node_modules/.bin/jsdoc config/jsdoc/api/index.md -c config/jsdoc/api/conf.json -d $(BUILD_HOSTED)/apidoc
|
./node_modules/.bin/jsdoc config/jsdoc/api/index.md -c config/jsdoc/api/conf.json --package package.json -d $(BUILD_HOSTED)/apidoc
|
||||||
@touch $@
|
@touch $@
|
||||||
|
|
||||||
$(BUILD_HOSTED_EXAMPLES_JS): $(BUILD_HOSTED)/examples/%.js: build/examples/%.js
|
$(BUILD_HOSTED_EXAMPLES_JS): $(BUILD_HOSTED)/examples/%.js: build/examples/%.js
|
||||||
|
|||||||
@@ -113,7 +113,8 @@ function generate(title, docs, filename, resolveLinks) {
|
|||||||
var docData = {
|
var docData = {
|
||||||
filename: filename,
|
filename: filename,
|
||||||
title: title,
|
title: title,
|
||||||
docs: docs
|
docs: docs,
|
||||||
|
packageInfo: ( find({kind: 'package'}) || [] ) [0]
|
||||||
};
|
};
|
||||||
|
|
||||||
var outpath = path.join(outdir, filename),
|
var outpath = path.join(outdir, filename),
|
||||||
@@ -327,11 +328,6 @@ exports.publish = function(taffyData, opts, tutorials) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// update outdir if necessary, then create outdir
|
|
||||||
var packageInfo = ( find({kind: 'package'}) || [] ) [0];
|
|
||||||
if (packageInfo && packageInfo.name) {
|
|
||||||
outdir = path.join(outdir, packageInfo.name, packageInfo.version);
|
|
||||||
}
|
|
||||||
fs.mkPath(outdir);
|
fs.mkPath(outdir);
|
||||||
|
|
||||||
// copy the template's static files to outdir
|
// copy the template's static files to outdir
|
||||||
@@ -439,13 +435,10 @@ exports.publish = function(taffyData, opts, tutorials) {
|
|||||||
if (members.globals.length) { generate('Global', [{kind: 'globalobj'}], globalUrl); }
|
if (members.globals.length) { generate('Global', [{kind: 'globalobj'}], globalUrl); }
|
||||||
|
|
||||||
// index page displays information from package.json and lists files
|
// index page displays information from package.json and lists files
|
||||||
var files = find({kind: 'file'}),
|
var files = find({kind: 'file'});
|
||||||
packages = find({kind: 'package'});
|
|
||||||
|
|
||||||
generate('Index',
|
generate('Index',
|
||||||
packages.concat(
|
[{kind: 'mainpage', readme: opts.readme, longname: (opts.mainpagetitle) ? opts.mainpagetitle : 'Main Page'}].concat(files),
|
||||||
[{kind: 'mainpage', readme: opts.readme, longname: (opts.mainpagetitle) ? opts.mainpagetitle : 'Main Page'}]
|
|
||||||
).concat(files),
|
|
||||||
indexUrl);
|
indexUrl);
|
||||||
|
|
||||||
// set up the lists that we'll use to generate pages
|
// set up the lists that we'll use to generate pages
|
||||||
|
|||||||
@@ -55,18 +55,31 @@ $(function () {
|
|||||||
|
|
||||||
// create source code links to github
|
// create source code links to github
|
||||||
var srcLinks = $('div.tag-source');
|
var srcLinks = $('div.tag-source');
|
||||||
var masterSearch = window.location.href.match(/\/([^\/]*\/)apidoc\//);
|
var location = window.location.href;
|
||||||
if (masterSearch && masterSearch.length) {
|
var branchSearch = location.match(/\/([^\/]*)\/apidoc\//);
|
||||||
var branch = masterSearch[1];
|
if (branchSearch && branchSearch.length) {
|
||||||
|
var branch = branchSearch[1];
|
||||||
|
if (branch !== 'latest') {
|
||||||
|
if (/^v[0-9\.]*$/.test(branch)) {
|
||||||
|
var ok = confirm('You are viewing outdated docs. Do you want to try the latest?');
|
||||||
|
if (ok) {
|
||||||
|
window.location.href = location.replace(branchSearch[0], '/latest/apidoc/');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$('.package-version').text(branch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var version = $('.package-version');
|
||||||
|
var branch = version.text();
|
||||||
srcLinks.each(function(i, el) {
|
srcLinks.each(function(i, el) {
|
||||||
var textParts = el.innerHTML.trim().split(', ');
|
var textParts = el.innerHTML.trim().split(', ');
|
||||||
var link = 'https://github.com/openlayers/ol3/blob/' + branch +
|
var link = 'https://github.com/openlayers/ol3/blob/' + branch + '/' +
|
||||||
textParts[0];
|
textParts[0];
|
||||||
el.innerHTML = '<a href="' + link + '">' + textParts[0] + '</a>, ' +
|
el.innerHTML = '<a href="' + link + '">' + textParts[0] + '</a>, ' +
|
||||||
'<a href="' + link + textParts[1].replace('line ', '#l') + '">' +
|
'<a href="' + link + textParts[1].replace('line ', '#l') + '">' +
|
||||||
textParts[1] + '</a>';
|
textParts[1] + '</a>';
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
// show/hide unstable items
|
// show/hide unstable items
|
||||||
var links = $('a[href^="ol."]');
|
var links = $('a[href^="ol."]');
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ li {
|
|||||||
display: block;
|
display: block;
|
||||||
font-size: 0.85em;
|
font-size: 0.85em;
|
||||||
}
|
}
|
||||||
|
.navigation h4,
|
||||||
.navigation li.item .title a {
|
.navigation li.item .title a {
|
||||||
color: #e1e1e1;
|
color: #e1e1e1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ var self = this;
|
|||||||
?>
|
?>
|
||||||
<div class="navigation">
|
<div class="navigation">
|
||||||
<div class="search">
|
<div class="search">
|
||||||
|
<h4 class='package-version'>v<?js= self.version ?></h4>
|
||||||
<input id="search" type="text" class="form-control input-sm" placeholder="Search Documentation">
|
<input id="search" type="text" class="form-control input-sm" placeholder="Search Documentation">
|
||||||
</div>
|
</div>
|
||||||
<ul class="list">
|
<ul class="list">
|
||||||
|
|||||||
Reference in New Issue
Block a user