Build singlehtml, rewrite html header links with version-dependent paths

Peter D. Barnes, Jr. 2012-07-30 15:15:52 -07:00
parent 2c991fc00a
commit b01421a2ca
5 changed files with 232 additions and 28 deletions

View File

@ -1,29 +1,165 @@
#!/bin/bash
# Get the current repo version
# and format appropriately as a
# Javascript variable for inclusion in html files
# Get the current repo name and version
# and format appropriately as a Javascript
# variable for inclusion in html files.
# Use cases:
# 1. Hosted on nsnam.org, tagged release.
# 2. Hosted on nsnam.org, ns-3-dev.
# 3. User repo, at modified from a tagged release (or ns-3-dev).
# 4. User repo, at a release tag.
# 5. User repo, at a private tag.
# 6. Private web host, at a tag (or ns-3-dev, or local mod).
#
# For case 1 and 2, we want the links to point to the nsnam.org
# publicly hosted pages. For all other cases, we want to point
# to the built pages in the repo itself.
#
# The approach to identify cases 1 & 2 is to test:
# a. We're on nsnam.org (actually, nsnam.ece.gatech.edu), and
# b. We're in the tmp build directory, /tmp/daily_nsnam/
# (This is the directory used by the update-* scripts
# run by cron jobs.)
#
# If both a and b are true, we're building for nsnam.org.
#
# The repo version is either a tag name or a commit (short) id.
#
# If we're building for nsnam.org, and at a tag, we use just
# the tag as the repo name/version string, e.g. 'ns-3.14'.
# Otherwise, we're building for ns-3-dev, and we use, e.g,
# 'ns-3-dev @ fd0f27a10eff'.
#
# If we're *not* building for nsnam.org, we use the repo
# directory name as the repo name. (This will typically be
# a name meaningful to the user doing the build, perhaps a
# shorthand for the feature they are working on.) For
# example, this script was developed in a repo (mis)named
# 'doxygen'. We always use the repo version, resulting
# in document version strings like 'doxygen @ ns-3.15' or
# 'doxygen @ fd0f27a10eff'
#
me=`basename $0`
function say
{
echo "$me: $*"
}
# script arguments
say
verbose=0
nsnam=0
tag=0
while getopts ntv option ; do
case $option in
n)
nsnam=1
verbose=1
;;
t)
tag=1
verbose=1
;;
v)
verbose=1
;;
\?)
say "invalid option: -$OPTION"
exit -1
;;
esac
done
[[ $verbose -eq 1 ]] && say verbose
[[ $nsnam -eq 1 ]] && say nsnam
[[ $tag -eq 1 ]] && say using tag
# Hostname, fully qualified, e.g. nsnam.ece.gatech.edu
HOST=`hostname`
NSNAM="nsnam.ece.gatech.edu"
# Build directory
DAILY="/tmp/daily_nsnam/.*"
if [ $nsnam -eq 1 ]; then
HOST=$NSNAM
OLDPWD=$PWD
PWD=/tmp/daily_nsnam/foo
say "forcing build for nsnam.org"
fi
if [[ $HOST == $NSNAM && $PWD =~ $DAILY ]] ; then
PUBLIC=1
say "building public docs for nsnam.org"
else
PUBLIC=0
say "building private docs"
fi
if [ $nsnam -eq 1 ]; then
PWD=$OLDPWD
fi
# Destination javascript file
outf="doc/ns3_html_theme/static/ns3_version.js"
# Distance from last tag
# Zero distance means we're at the tag
distance=`hg log -r tip --template '{latesttagdistance}'`
if [ $distance -eq 0 ]; then
version=`hg log -r tip --template '{latesttag}'`
else
repo=`basename $PWD`
version=`hg log -r tip --template "$repo @ {node|short}"`
version=`hg log -r tip --template '{node|short}'`
fi
jsver="var ns3_version = \"$version\";"
echo $jsver > doc/ns3_html_theme/static/ns3_version.js
if [ $tag -eq 1 ]; then
distance=0
version="3.14"
say "forcing version = $version"
fi
if [ $PUBLIC -eq 1 ]; then
echo "var ns3_host = \"http://www.nsnam.org/\";" > $outf
if [ $distance -eq 0 ]; then
echo "var ns3_version = \"Release $version\";" >> $outf
echo "var ns3_release = \"docs/release/$version/\";" >> $outf
else
echo "var ns3_version = \"ns-3-dev @ $version\";" >> $outf
echo "var ns3_release = \"docs/\";" >> $outf
fi
echo "var ns3_local = \"\";" >> $outf
echo "var ns3_doxy = \"doxygen/\";" >> $outf
else
repo=`basename $PWD`
echo "var ns3_host = \"file://$PWD/\";" > $outf
echo "var ns3_version = \"$repo @ $version\";" >> $outf
echo "var ns3_release = \"doc/\";" >> $outf
echo "var ns3_local = \"build/\";" >> $outf
echo "var ns3_doxy = \"html/\";" >> $outf
fi
# Copy to html directories
# This is done automatically by the Doxygen and Sphinx build steps
cd doc
# This is not always done automatically by the Doxygen and Sphinx build steps
cd doc 2>&1 >/dev/null
for d in {manual,models,tutorial{,-pt-br}}/build/html/_static html ; do
cp ns3_html_theme/static/ns3_version.js $d
cp ns3_html_theme/static/ns3_links.js $d
done
cd - 2>&1 >/dev/null
# Show what was done
echo ns-3 javascript version: $jsver
if [ $verbose ]; then
say
say "outf = $outf:"
cat -n $outf
fi

View File

@ -25,6 +25,7 @@
<script type="text/javascript" src="_static/drop-down-menu.js"></script>
<script type="text/javascript" src="_static/ns3_version.js"></script>
<script type="text/javascript" src="_static/ns3_links.js"></script>
{% endblock %}
@ -34,9 +35,10 @@
<tbody>
<tr style="height: 56px;">
<td id="projectlogo">
<a href="{{theme_site + theme_homepage}}">
<img alt="ns-3 Logo"
src="{{ pathto('_static/' + theme_logo, 1)}}"/>
<a id="ns3_home1"
href="{{theme_site + theme_homepage}}">
<img alt="ns-3 Logo"
src="{{ pathto('_static/' + theme_logo, 1)}}"/>
</a>
</td>
<td id="projecttext">
@ -47,28 +49,48 @@
<td id="ns3-menu">
<div class="menu">
<ul >
<li><a href="{{theme_site + theme_homepage}}">&nbsp;&nbsp;Home</a>
<li><a id="ns3_home2"
href="{{theme_site + theme_homepage}}"
>&nbsp;&nbsp;Home</a>
</li>
<li><a href="{{theme_site + theme_wiki}}">Wiki</a>
<li><a id="ns3_wiki"
href="{{theme_site + theme_wiki}}"
>Wiki</a>
</li>
<li><span onmouseover="mopen('mDocs')"
onmouseout="mclosetime()">Docs &nbsp;&nbsp;&nbsp;&#x25BC;</span>
<li><span
onmouseover="mopen('mDocs')"
onmouseout="mclosetime()"
>Docs &nbsp;&nbsp;&nbsp;&#x25BC;</span>
<div id="mDocs"
onmouseover="mcancelclosetime()"
onmouseout="mclosetime()">
<a href="{{theme_site + theme_release + theme_manual}}">Manual</a><br/>
<a href="{{theme_site + theme_release + theme_models}}">Models</a><br/>
<a href="{{theme_site + theme_release + theme_doxygen}}">API</a><br/>
<a id="ns3_man"
href="{{theme_site + theme_release + theme_manual}}"
>Manual</a><br/>
<a id="ns3_mod"
href="{{theme_site + theme_release + theme_models}}"
>Models</a><br/>
<a id="ns3_api"
href="{{theme_site + theme_release + theme_doxygen}}"
>API</a><br/>
</li>
<li><span onmouseover="mopen('mTuts')"
onmouseout="mclosetime()">Tutorials &nbsp;&#x25BC;</span>
<li><span
onmouseover="mopen('mTuts')"
onmouseout="mclosetime()"
>Tutorials &nbsp;&#x25BC;</span>
<div id="mTuts"
onmouseover="mcancelclosetime()"
onmouseout="mclosetime()">
<a href="{{theme_site + theme_release + theme_tutorial}}">English</a><br/>
<a href="{{theme_site + theme_release + theme_tutport}}">Portuguese</a><br/>
<a id="ns3_tut"
href="{{theme_site + theme_release + theme_tutorial}}"
>English</a><br/>
<a id="ns3_ptbr"
href="{{theme_site + theme_release + theme_tutport}}"
>Portuguese</a><br/>
</li>
<li><a href="{{theme_site + theme_bugzilla}}">Bugs</a>
<li><a id="ns3_bugs"
href="{{theme_site + theme_bugzilla}}"
>Bugs</a>
</li>
</ul>
</div>
@ -79,6 +101,7 @@
</tr>
</tbody>
</table>
<script type="text/javascript">ns3_write_links()</script>
</div>
{% endblock %}

View File

@ -0,0 +1,45 @@
// nsnam.org links, independent of version
var ns3_site = "http://www.nsnam.org/";
var ns3_home = ns3_site + "";
var ns3_wiki = ns3_site + "wiki";
var ns3_bugs = ns3_site + "bugzilla";
// Links that depend on version:
// Defined in ns3_version.js:
// ns3_host = "http://www.nsnam.org/" file://$PWD
// ns3_version = "3.14" "3.14
// = "ns-3-dev @ 12345abcde "repo @ 12345abcde
// ns3_release = "docs/release/3.14/" "repo/"
// ns3_local = "" "build/"
//
// This lets us build several kinds of links:
// http://www.nsnam.org/docs/manual/html/index.html
// http://www.nsnam.org/docs/release/3.14/manual/html/index.html
// file:///.../doc/manual/build/html/index.html
//
// with the appropriate version string.
var ns3_index = "index.html";
var ns3_rel = ns3_host + ns3_release;
var ns3_api = ns3_rel + ns3_doxy + ns3_index;
ns3_index = ns3_local + "html/" + ns3_index;
var ns3_man = ns3_rel + "manual/" + ns3_index;
var ns3_mod = ns3_rel + "models/" + ns3_index;
var ns3_tut = ns3_rel + "tutorial/" + ns3_index;
var ns3_ptbr = ns3_rel + "tutorial-pt-br/" + ns3_index;
function ns3_write_links() {
document.getElementById("ns3_home1").href = ns3_home;
document.getElementById("ns3_home2").href = ns3_home;
document.getElementById("ns3_wiki" ).href = ns3_wiki;
document.getElementById("ns3_bugs" ).href = ns3_bugs;
document.getElementById("ns3_api" ).href = ns3_api;
document.getElementById("ns3_man" ).href = ns3_man;
document.getElementById("ns3_mod" ).href = ns3_mod;
document.getElementById("ns3_tut" ).href = ns3_tut;
document.getElementById("ns3_ptbr" ).href = ns3_ptbr;
}

View File

@ -1 +0,0 @@
var ns3_version = "doxygen @ def424669160";

View File

@ -1099,7 +1099,8 @@ class Ns3SphinxContext(Context.Context):
def sphinx_build(self, path):
print
print "[waf] Building sphinx docs for " + path
if subprocess.Popen(["make", "-k", "html"], cwd=path).wait() :
if subprocess.Popen(["make", "SPHINXOPTS=-N", "-k", "html", "singlehtml"],
cwd=path).wait() :
raise SystemExit(1)
def execute(self):