forked from nasa/astrobee
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support multiple versions for docs (nasa#675)
- Loading branch information
Showing
8 changed files
with
258 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | ||
<html> | ||
<head> | ||
<title>Page not found - Astrobee software documentation</title> | ||
<style type="text/css" media="screen"> | ||
body { | ||
background-color: #f1f1f1; | ||
margin: 0; | ||
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; | ||
} | ||
|
||
.container { margin: 50px auto 40px auto; width: 600px; text-align: center; } | ||
|
||
a { color: #4183c4; text-decoration: none; } | ||
a:hover { text-decoration: underline; } | ||
|
||
h1 { width: 800px; position:relative; left: -100px; letter-spacing: -1px; line-height: 60px; font-size: 60px; font-weight: 100; margin: 0px 0 50px 0; text-shadow: 0 1px 0 #fff; } | ||
p { color: rgba(0, 0, 0, 0.5); margin: 20px 0; line-height: 1.6; } | ||
|
||
ul { list-style: none; margin: 25px 0; padding: 0; } | ||
li { display: table-cell; font-weight: bold; width: 1%; } | ||
|
||
#suggestions { | ||
margin-top: 35px; | ||
color: #ccc; | ||
} | ||
#suggestions a { | ||
color: #666666; | ||
font-weight: 200; | ||
font-size: 14px; | ||
margin: 0 10px; | ||
} | ||
|
||
</style> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>404</h1> | ||
|
||
<p><strong>Sorry, that page does not exist!</strong></p> | ||
|
||
<p>If you got here by using the menu at the top to change what version of the Astrobee software you want documentation for, please note that different software versions may define different documentation pages in some cases.</p> | ||
|
||
<div id="suggestions"><a href="/astrobee/v/develop/">[ Return to the Astrobee documentation root ]</a>.</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Please visit the [Astrobee Documentation](https://nasa.github.io/astrobee/documentation.html) | ||
Please visit the [Astrobee Documentation](https://nasa.github.io/astrobee/v/develop/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | ||
<html><head><meta http-equiv=Refresh content="0;url=html/index.html"></head></html> | ||
<html><head><meta http-equiv=Refresh content="0;url=v/develop/"></head></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#!/usr/bin/env python | ||
# Copyright (c) 2017, United States Government, as represented by the | ||
# Administrator of the National Aeronautics and Space Administration. | ||
# | ||
# All rights reserved. | ||
# | ||
# The Astrobee platform is licensed under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with the | ||
# License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations | ||
# under the License. | ||
|
||
""" | ||
Recursively copy a folder as "HTML symlinks" -- this means writing files | ||
in the target folder with the same relative paths as in the source | ||
folder, but instead of copying the file content, each output file is a | ||
minimal HTML page that will redirect to the original file in the source | ||
folder. | ||
""" | ||
|
||
import argparse | ||
import os | ||
|
||
HTML_TEMPLATE = """ | ||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | ||
<html><head><meta http-equiv=Refresh content="0;url={}"></head></html> | ||
""".lstrip() | ||
|
||
|
||
def copy_html_link(src_path_in, tgt_path_in, verbose): | ||
src_path = os.path.realpath(src_path_in) | ||
tgt_path = os.path.realpath(tgt_path_in) | ||
src_rel_tgt = os.path.relpath(src_path, tgt_path) | ||
count = 0 | ||
for dir_path, dirs, files in os.walk(src_path): | ||
dir_path_suffix = dir_path.replace(src_path, "") | ||
dir_path_suffix = dir_path_suffix.lstrip("/") | ||
for f in files: | ||
if not dir_path_suffix: | ||
depth = 0 | ||
else: | ||
depth = len(dir_path_suffix.split("/")) | ||
up_depth = "/".join([".."] * depth) | ||
src_f_rel_tgt_f = os.path.join(up_depth, src_rel_tgt, dir_path_suffix, f) | ||
out_path = os.path.join(tgt_path, dir_path_suffix, f) | ||
out_dir = os.path.dirname(out_path) | ||
if not os.path.isdir(out_dir): | ||
os.makedirs(out_dir, exist_ok=True) | ||
with open(out_path, "w") as out: | ||
out.write(HTML_TEMPLATE.format(src_f_rel_tgt_f)) | ||
count += 1 | ||
if verbose: | ||
print("%s -> %s" % (out_path, src_f_rel_tgt_f)) | ||
print("wrote %s HTML redirect files" % count) | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser( | ||
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter | ||
) | ||
parser.add_argument( | ||
"src_path", | ||
type=str, | ||
help="source path", | ||
) | ||
parser.add_argument( | ||
"tgt_path", | ||
type=str, | ||
help="target path", | ||
) | ||
parser.add_argument( | ||
"-v", | ||
"--verbose", | ||
action="store_true", | ||
default=False, | ||
help="make output more verbose", | ||
) | ||
|
||
args = parser.parse_args() | ||
|
||
copy_html_link(args.src_path, args.tgt_path, args.verbose) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
// The line below will be replaced to include any additional | ||
// auto-detected versions. See script in docs.yaml. | ||
var allVersions = ["develop", "master", "ros2"]; | ||
|
||
function buildSelect(currentVersion) { | ||
if (!allVersions.includes(currentVersion)) { | ||
allVersions.unshift(currentVersion); | ||
} | ||
|
||
// couldn't get external CSS stylesheet to apply here for some reason | ||
var buf = ['<span id="versionselectorlabel">Astrobee Version:</span><select id="versionselector" style="font-size: 100%; padding: 3px 5px 3px 5px; margin-left: 5px;">']; | ||
for (version of allVersions) { | ||
buf.push('<option value="' + version + '"'); | ||
if (version == currentVersion) { | ||
buf.push(' selected="selected"'); | ||
} | ||
buf.push(">" + version + "</option>"); | ||
} | ||
buf.push("</select>"); | ||
|
||
return buf.join(""); | ||
} | ||
|
||
function detectCurrentVersion() { | ||
const version_regex = /\/v\/(.*)\//; | ||
var match = version_regex.exec(window.location.pathname); | ||
if (match) { | ||
return match[1]; | ||
} else { | ||
return "(unknown)"; | ||
} | ||
} | ||
|
||
function onSelectorChange() { | ||
var selector = document.getElementById("versionselector"); | ||
var currentVersion = detectCurrentVersion(); | ||
var selectedVersion = selector.value; | ||
window.location.pathname = window.location.pathname.replace(currentVersion, selectedVersion); | ||
} | ||
|
||
function initVersionSelector() { | ||
var currentVersion = detectCurrentVersion(); | ||
var projNumDiv = document.getElementById("projectnumber"); | ||
projNumDiv.innerHTML = buildSelect(currentVersion); | ||
var selector = document.getElementById("versionselector"); | ||
// couldn't get external CSS stylesheet to apply here for some reason | ||
document.getElementById('projectnumber').style = "position: relative; top: -0.3em;"; | ||
|
||
selector.addEventListener("change", onSelectorChange); | ||
} | ||
|
||
initVersionSelector(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters