Skip to content

Commit

Permalink
Add the table of contents of API commands that shows which functions …
Browse files Browse the repository at this point in the history
…are deprecated or otherwise unavailable.
  • Loading branch information
BSVino committed Aug 14, 2014
1 parent 26655f4 commit 66ac550
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 26 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "html/copy/jquery-bonsai"]
path = html/copy/jquery-bonsai
url = https://github.com/BSVino/jquery-bonsai.git
89 changes: 68 additions & 21 deletions compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,35 @@ def create_directory(dir):
output_dir = "htdocs/"

print "Resetting output dir..."
if os.path.exists(output_dir):
while os.path.exists(output_dir):
try:
shutil.rmtree(output_dir);
except:
pass # It gives an error sometimes. If it didn't work it's not a huge deal though.
pass # It gives an error sometimes. If it didn't work try again.

while not os.path.exists(output_dir):
try:
create_directory(output_dir)
except:
pass # It gives an error sometimes. If it didn't work try again/
pass # It gives an error sometimes. If it didn't work try again.

print "Done."
f = []
d = []
for (dirpath, dirnames, filenames) in os.walk("html/copy"):
dirpath = dirpath[10:]
d.append(dirpath)
for file in filenames:
if file[0] == '.':
continue
f.append(dirpath + "/" + file)

for directory in d:
create_directory(output_dir + directory)

for file in f:
shutil.copy("html/copy/" + file, output_dir + file)

print "Copied " + str(len(f)) + " files"

print "Reading templates..."
header_fp = open("html/header.html")
Expand All @@ -34,6 +50,51 @@ def create_directory(dir):
footer_fp.close()
print "Done."

unhandled_commands = opengl.commands_version.keys()

def spew_category(name, commands):
commands.sort()

api_commands = ""
commands_list = ""
category_versions = []
for command in commands:
major_versions = opengl.get_major_versions_available(command)
major_versions.sort()

classes = "command"
for v in major_versions:
classes += " gl" + v

if not v in category_versions:
category_versions.append(v)

latest_present = major_versions[-1][0]

commands_list += "<li class='" + classes + "'><a href='../" + latest_present + "/" + command + "'>" + command + "</a></li>"
try:
unhandled_commands.remove(command)
except:
pass

classes = "category"
for v in category_versions:
classes += " gl" + v

api_commands += "<li class='" + classes + "'>" + name + ""

api_commands += "<ul>" + commands_list + "</ul></li>"

return api_commands

api_commands = ""
for category in opengl.command_categories:
api_commands += spew_category(category, opengl.command_categories[category])

api_commands += spew_category("Uncategorized", unhandled_commands)

header = header.replace("{$api_commands}", api_commands)

for version in opengl.version_commands:
written = 0

Expand All @@ -49,23 +110,17 @@ def create_directory(dir):
selected = ""
if version_option[0] == version[0]:
selected = " selected='selected'"
toc_versions_options = toc_versions_options + "<option" + selected + ">GL" + version_option[0] + "</option>"
toc_versions_options = toc_versions_options + "<option value='gl" + version_option[0] + "'" + selected + ">GL" + version_option[0] + "</option>"
header_for_version = header_for_version.replace("{$versions_options}", toc_versions_options)
header_for_version = header_for_version.replace("{$current_api}", "gl" + version[0])

for command in opengl.commands_version:
if not version in opengl.commands_version[command]:
continue

header_for_command = header_for_version

versions_available = opengl.commands_version[command]
versions_available.sort()

major_versions = []
for v in versions_available:
major_version = v[0] + ".x"
if not major_version in major_versions:
major_versions.append(major_version)
major_versions = opengl.get_major_versions_available(command)

command_versions = "<strong>OpenGL " + version[0] + "</strong>"
for version_option in major_versions:
Expand Down Expand Up @@ -97,11 +152,3 @@ def create_directory(dir):

print "Wrote " + str(written) + " commands for GL" + version[0]

f = []
for (dirpath, dirnames, filenames) in os.walk("html/copy"):
f.extend(filenames)

for file in f:
shutil.copy("html/copy/" + file, output_dir + file)

print "Copied " + str(len(f)) + " files"
1 change: 1 addition & 0 deletions html/copy/jquery-bonsai
Submodule jquery-bonsai added at f70ab5
26 changes: 24 additions & 2 deletions html/copy/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ a:hover {
color: #358acc;
}

li {
margin-left: 10px;
}

#everything {
width: 950px;
margin-left: auto;
Expand Down Expand Up @@ -126,7 +130,9 @@ a:hover {
}

#versions_container {
float: right;
float: left;
display: block;
width: 100px;
}

#api {
Expand All @@ -137,4 +143,20 @@ a:hover {

#command_versions {
float: right;
}
}

#opengl_name {
width: 150px;
display: block;
float: left;
margin-top: 2px;
}

#command_categories, #command_categories a {
text-decoration: none;
}

.disabled, .disabled a {
color: #999;
text-decoration: none;
}
36 changes: 34 additions & 2 deletions html/header.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta charset='utf-8'>
<title>{$title} - OpenGL API Documentation</title>
<link href="../reset.css" rel="stylesheet" type="text/css" />
<link href='http://fonts.googleapis.com/css?family=Roboto+Condensed' rel='stylesheet' type='text/css'>
Expand All @@ -9,12 +10,40 @@
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" href="../jquery-ui.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/jquery-ui.min.js"></script>
<script src="../jquery-bonsai/jquery.bonsai.js"></script>
<link href="../jquery-bonsai/jquery.bonsai.css" rel="stylesheet" type="text/css" />

<link href="../style.css" rel="stylesheet" type="text/css" />

<script>
function gl_printable_name(name) {
if (name == "gl2")
return "OpenGL 2";
if (name == "gl3")
return "OpenGL 3";
if (name == "gl4")
return "OpenGL 4";
return "OpenGL X";
}

function set_api_version(version) {
$( "#opengl_name" ).text(gl_printable_name(version));

$(".category").addClass("disabled")
$(".command").addClass("disabled")
$("." + version).removeClass("disabled")
}

$(function() {
$( "#versions_dropdown" ).selectmenu();
$( "#command_categories" ).bonsai()

$( "#versions_dropdown" ).selectmenu({
change: function( event, ui ) {
set_api_version(ui.item.value);
}
});

set_api_version("{$current_api}");
});
</script>

Expand All @@ -23,8 +52,11 @@

<div id="everything">
<div id="toc">
<h2 id="opengl_name"></h2>
<div id="versions_container"><span id="api">API:</span><select id="versions_dropdown">{$versions_options}</select></div>
TABLE OF CONTENTS

<br clear="both" />
<ul id="command_categories">{$api_commands}</ul>

</div>

Expand Down
22 changes: 21 additions & 1 deletion opengl.py
Original file line number Diff line number Diff line change
Expand Up @@ -1085,5 +1085,25 @@ def reverse_versions():
commands_version = reverse_version_index(version_commands)
glsl_version = reverse_version_index(version_glsl)
print "Done."

command_categories = {
"Immediate Mode": [
"glBegin", "glEnd", "glVertex", "glColor", "glColorPointer",
]
}

reverse_versions()

def get_major_versions_available(command):
global commands_version

reverse_versions()
versions_available = commands_version[command]
versions_available.sort()

major_versions = []
for v in versions_available:
major_version = v[0]
if not major_version in major_versions:
major_versions.append(major_version)

return major_versions

0 comments on commit 66ac550

Please sign in to comment.