mirror of
https://github.com/azerothcore/mod-ale
synced 2025-11-29 15:38:17 +08:00
Render sidebar dynamically with js
This commit is contained in:
@@ -160,10 +160,14 @@ if __name__ == '__main__':
|
|||||||
# Make a folder for the class.
|
# Make a folder for the class.
|
||||||
os.mkdir('build/' + class_.name)
|
os.mkdir('build/' + class_.name)
|
||||||
index_path = '{}/index.html'.format(class_.name)
|
index_path = '{}/index.html'.format(class_.name)
|
||||||
|
sidebar_path = '{}/sidebar.js'.format(class_.name)
|
||||||
|
|
||||||
# Render the class's index page.
|
# Render the class's index page.
|
||||||
render('class.html', index_path, level=1, classes=classes, current_class=class_)
|
render('class.html', index_path, level=1, classes=classes, current_class=class_)
|
||||||
|
|
||||||
|
# Render the class's sidebar script.
|
||||||
|
render('sidebar.js', sidebar_path, level=1, classes=classes, current_class=class_)
|
||||||
|
|
||||||
# Render each method's page.
|
# Render each method's page.
|
||||||
for method in class_.methods:
|
for method in class_.methods:
|
||||||
method_path = '{}/{}.html'.format(class_.name, method.name)
|
method_path = '{}/{}.html'.format(class_.name, method.name)
|
||||||
|
|||||||
@@ -23,9 +23,18 @@
|
|||||||
|
|
||||||
{% block sidebar %}
|
{% block sidebar %}
|
||||||
<h2>{{ current_class.name }} Methods</h2>
|
<h2>{{ current_class.name }} Methods</h2>
|
||||||
{%- for method in current_class.methods %}
|
<script src="sidebar.js"></script>
|
||||||
<a class="fn {{ 'current' if method == current_method }}" href="{{ root(current_class.name + '/' + method.name + '.html') }}">{{ method.name }}</a>
|
<script>
|
||||||
{%- endfor %}
|
// Highlight current method by adding "current" class to it
|
||||||
|
var element = document.getElementById("{{ current_class.name + ':' + current_method.name }}");
|
||||||
|
if (element) {
|
||||||
|
var classname = "current";
|
||||||
|
arr = element.className.split(" ");
|
||||||
|
if (arr.indexOf(classname) == -1) {
|
||||||
|
element.className += " " + classname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
5
docs/ElunaDoc/templates/sidebar.js
Normal file
5
docs/ElunaDoc/templates/sidebar.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
document.write(`
|
||||||
|
{%- for method in current_class.methods %}
|
||||||
|
<a id="{{ current_class.name + ':' + method.name }}" class="fn" href="{{ root(current_class.name + '/' + method.name + '.html') }}">{{ method.name }}</a>
|
||||||
|
{%- endfor %}
|
||||||
|
`);
|
||||||
Reference in New Issue
Block a user