Skip to content

Commit 1243d9c

Browse files
committed
Initial commit.
0 parents  commit 1243d9c

File tree

8 files changed

+155
-0
lines changed

8 files changed

+155
-0
lines changed

.github/dependabot.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: github-actions
4+
directory: /
5+
schedule:
6+
interval: monthly

.github/workflows/build.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Build API docs
2+
on:
3+
push:
4+
schedule:
5+
- cron: '0 0 * * 0'
6+
jobs:
7+
build:
8+
container: alpine:edge
9+
runs-on: ubuntu-latest
10+
env:
11+
INSPIRCD_BRANCHES: insp3 master
12+
INSPIRCD_TAGS: v3 v4
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Install dependencies
17+
run: |-
18+
apk add doxygen git python3
19+
20+
- name: Build API docs
21+
run: |-
22+
./mkapi
23+
24+
- name: Deploy API docs
25+
uses: peaceiris/actions-gh-pages@v3
26+
with:
27+
github_token: ${{ secrets.GITHUB_TOKEN }}
28+
publish_dir: ./site

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.*
2+
!.git*
3+
site

README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
## About
2+
3+
InspIRCd is a modular C++ Internet Relay Chat (IRC) server for UNIX-like and Windows systems.
4+
5+
This repository contains the sources for the API documentation available at [api.inspircd.org](https://api.inspircd.org).
6+
7+
## License
8+
9+
This API documentation is licensed under the same license as InspIRCd (GPLv2).

mkapi

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#!/usr/bin/env python3
2+
#
3+
# InspIRCd -- Internet Relay Chat Daemon
4+
#
5+
# Copyright (C) 2022 Sadie Powell <[email protected]>
6+
#
7+
# This file is part of InspIRCd. InspIRCd is free software: you can
8+
# redistribute it and/or modify it under the terms of the GNU General Public
9+
# License as published by the Free Software Foundation, version 2.
10+
#
11+
# This program is distributed in the hope that it will be useful, but WITHOUT
12+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13+
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14+
# details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
#
19+
20+
21+
import os
22+
import re
23+
import shutil
24+
import subprocess
25+
import sys
26+
import tempfile
27+
28+
CC_BOLD = "\x1B[1m" if sys.stdout.isatty() else ''
29+
CC_RED = "\x1B[1;31m" if sys.stdout.isatty() else ''
30+
CC_RESET = "\x1B[0m" if sys.stdout.isatty() else ''
31+
32+
# INSPIRCD_BRANCHES contains a space-delimited list of git branch names.
33+
INSPIRCD_BRANCHES = os.getenv('INSPIRCD_BRANCHES', 'master').split()
34+
35+
# INSPIRCD_REPOSITORY contains the location of the InspIRCd git repository.
36+
INSPIRCD_REPOSITORY = os.getenv('INSPIRCD_REPOSITORY', 'https://github.com/inspircd/inspircd.git')
37+
38+
# INSPIRCD_TAGS contains a space-delimited list of git tag prefixes.
39+
INSPIRCD_TAGS = os.getenv('INSPIRCD_TAGS', '').split()
40+
41+
def error(message):
42+
print(f"{CC_RED}Error:{CC_RESET} {message}!", file=sys.stderr)
43+
sys.exit(1)
44+
45+
GIT = os.getenv('GIT', 'git')
46+
if not shutil.which(GIT):
47+
error(f"Git ({GIT}) must be installed to build the API docs")
48+
49+
DOXYGEN = os.getenv('DOXYGEN', 'doxygen')
50+
if not shutil.which(DOXYGEN):
51+
error(f"Doxygen ({DOXYGEN}) must be installed to build the API docs")
52+
53+
SITE_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'site')
54+
for file in os.listdir(SITE_DIR):
55+
abs_file = os.path.join(SITE_DIR, file)
56+
if os.path.isdir(abs_file) and os.path.exists(os.path.join(abs_file, 'doxygen.css')):
57+
print(f"Removing {CC_BOLD}{abs_file}{CC_RESET} from a previous run ...")
58+
shutil.rmtree(abs_file)
59+
60+
with tempfile.TemporaryDirectory() as git:
61+
print(f"Cloning {CC_BOLD}{INSPIRCD_REPOSITORY}{CC_RESET} to {git} ...")
62+
if subprocess.call([GIT, 'clone', INSPIRCD_REPOSITORY, git]):
63+
sys.exit(1)
64+
os.chdir(git)
65+
66+
# Build the list of refs to build docs for.
67+
references = {}
68+
for branch in INSPIRCD_BRANCHES:
69+
references[branch] = [branch]
70+
for tag in subprocess.check_output([GIT, 'tag', '--list', '--sort', '-v:refname'], encoding='utf-8').split('\n'):
71+
for tag_prefix in INSPIRCD_TAGS:
72+
if tag.startswith(tag_prefix):
73+
versions = re.match(r'^v((((\d+)\.\d+)\.\d+).*)', tag)
74+
if not versions:
75+
continue
76+
if not tag in references:
77+
references[tag] = []
78+
for version in versions.groups():
79+
references[tag].append(version)
80+
81+
DOXYGEN_DIR = os.path.join(git, 'docs', 'doxygen', 'html')
82+
for reference, directories in references.items():
83+
print(f"Building API docs for {CC_BOLD}{reference}{CC_RESET} ...")
84+
if os.system(f"{GIT} clean -dfx && {GIT} checkout {reference} && {DOXYGEN} docs/Doxyfile 1>/dev/null"):
85+
sys.exit(1)
86+
87+
for directory in directories:
88+
site_dir = os.path.join(SITE_DIR, directory)
89+
if os.path.exists(site_dir):
90+
continue
91+
print(f"Copying API docs from {CC_BOLD}{DOXYGEN_DIR}{CC_RESET} to {CC_BOLD}{site_dir}{CC_RESET} ...")
92+
shutil.copytree(DOXYGEN_DIR, site_dir)

site/CNAME

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
api.inspircd.org

site/index.html

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Redirecting...</title>
6+
<meta name="robots" content="noindex">
7+
<meta http-equiv="refresh" content="0; url=https://www.inspircd.org/api/">
8+
</head>
9+
<body>
10+
Redirecting...
11+
</body>
12+
</html>

site/robots.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# www.robotstxt.org
2+
3+
User-agent: *
4+
Disallow: /

0 commit comments

Comments
 (0)