Skip to content

Commit 9beb15e

Browse files
committed
Generate an index page with links to all of the docs.
1 parent 8394b95 commit 9beb15e

File tree

5 files changed

+52
-14
lines changed

5 files changed

+52
-14
lines changed

.github/workflows/build.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ jobs:
2828

2929
- name: Install dependencies
3030
run: |-
31-
apk add doxygen git python3 tar
31+
apk add doxygen git python3 py3-pip tar
32+
pip3 install --break-system-packages jinja2
3233
3334
- name: Build API docs
3435
run: |-

.github/workflows/check.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ jobs:
1616

1717
- name: Install dependencies
1818
run: |-
19-
apk add doxygen git python3
19+
apk add doxygen git python3 py3-pip
20+
pip3 install --break-system-packages jinja2
2021
2122
- name: Build API docs
2223
run: |-

index.html.j2

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>InspIRCd API Documentation</title>
5+
<meta charset="utf-8">
6+
<style type="text/css">
7+
body {
8+
color: #444444;
9+
font-size: 18px;
10+
line-height: 1.5;
11+
margin: 50px 15%;
12+
}
13+
h1 {
14+
line-height: 1.2;
15+
}
16+
li {
17+
margin-bottom: 10px;
18+
}
19+
</style>
20+
</head>
21+
<body>
22+
<h1>InspIRCd API Documentation</h1>
23+
{%- for version, directories in docs.items() %}
24+
<h2>{{ version }}</h2>
25+
<ul>
26+
{%- for directory in directories %}
27+
<li><a href="{{ directory }}">{{ directory }}</a></li>
28+
{%- endfor %}
29+
</ul>
30+
{%- endfor %}
31+
<footer>Documentation generated at {{ time }} using the <a href="https://github.com/inspircd/inspircd-api">InspIRCd API Documentation Builder</a>.</footer>
32+
</body>
33+
</html>

mkapi

+15
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,16 @@
1818
#
1919

2020

21+
import datetime
2122
import os
2223
import re
2324
import shutil
2425
import subprocess
2526
import sys
2627
import tempfile
2728

29+
import jinja2
30+
2831
CC_BOLD = "\x1B[1m" if sys.stdout.isatty() else ''
2932
CC_RED = "\x1B[1;31m" if sys.stdout.isatty() else ''
3033
CC_RESET = "\x1B[0m" if sys.stdout.isatty() else ''
@@ -57,6 +60,7 @@ for file in os.listdir(SITE_DIR):
5760
print(f"Removing {CC_BOLD}{abs_file}{CC_RESET} from a previous run ...")
5861
shutil.rmtree(abs_file)
5962

63+
docs = {}
6064
with tempfile.TemporaryDirectory() as git:
6165
print(f"Cloning {CC_BOLD}{INSPIRCD_REPOSITORY}{CC_RESET} to {git} ...")
6266
if subprocess.call([GIT, 'clone', INSPIRCD_REPOSITORY, git]):
@@ -96,3 +100,14 @@ with tempfile.TemporaryDirectory() as git:
96100
continue
97101
print(f"Copying API docs from {CC_BOLD}{DOXYGEN_DIR}{CC_RESET} to {CC_BOLD}{site_dir}{CC_RESET} ...")
98102
shutil.copytree(DOXYGEN_DIR, site_dir)
103+
if not reference in docs:
104+
docs[reference] = []
105+
docs[reference].append(directory)
106+
107+
env = jinja2.Environment(loader=jinja2.FileSystemLoader(os.path.dirname(__file__)))
108+
template = env.get_template("index.html.j2")
109+
with open(os.path.join(SITE_DIR, "index.html"), "w") as fh:
110+
fh.write(template.render(
111+
docs=docs,
112+
time=datetime.datetime.now()
113+
))

site/index.html

-12
This file was deleted.

0 commit comments

Comments
 (0)