Skip to content

Commit 0dcfa69

Browse files
committed
Add make docs
1 parent 364be8c commit 0dcfa69

File tree

3 files changed

+73
-6
lines changed

3 files changed

+73
-6
lines changed

.nojekyll

Whitespace-only changes.

Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ update-to-date:
8686
touch Sources/**/openapi.yml
8787
touch Sources/**/Client.swift
8888

89-
#.build/docs: ## Need env GITHUB_PAGES is created as 'true'
90-
# swift package --allow-writing-to-directory $@ generate-documentation \
91-
# --disable-indexing \
92-
# --output-path $@ \
93-
# --transform-for-static-hosting \
94-
# --hosting-base-path github-rest-api-swift-openapi;
89+
docs: ## Need env GITHUB_PAGES is created as 'true'
90+
swift package --allow-writing-to-directory $@ generate-documentation \
91+
--disable-indexing \
92+
--transform-for-static-hosting \
93+
--hosting-base-path github-rest-api-swift-openapi;
94+
sh Script/setupDocsHtml.sh
9595

9696
.PHONY: help
9797
.SILENT: help

Script/setupDocsHtml.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/bin/bash
2+
3+
# 要處理的目錄
4+
dirRoot="docs"
5+
6+
# 目標 index.html 的完整路徑
7+
indexFilePath="index.html"
8+
9+
# 切換到 dirRoot 目錄
10+
cd "$dirRoot" || exit
11+
12+
# 開始構建 index.html 的內容
13+
echo "<!DOCTYPE html>
14+
<html lang=\"en\">
15+
<head>
16+
<meta charset=\"UTF-8\">
17+
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
18+
<title>GitHubRestAPISwiftOpenAPI | Documentation</title>
19+
<style>
20+
body {
21+
font-family: 'Arial', sans-serif;
22+
margin: 20px;
23+
}
24+
25+
h1 {
26+
color: #333;
27+
}
28+
29+
ul {
30+
list-style-type: none;
31+
padding: 0;
32+
}
33+
34+
li {
35+
margin-bottom: 10px;
36+
}
37+
38+
a {
39+
color: #0066cc;
40+
text-decoration: none;
41+
font-weight: bold;
42+
}
43+
44+
a:hover {
45+
text-decoration: underline;
46+
}
47+
</style>
48+
</head>
49+
<body>
50+
<h1> Documentation of Supported Frameworks / GitHubRestAPISwiftOpenAPI</h1>
51+
<ul>" > "$indexFilePath"
52+
53+
# 遍歷所有目錄,添加到 index.html 中
54+
for dir in */; do
55+
# 去掉目錄名稱最後的斜杠 '/'
56+
dir=${dir%/}
57+
name=${dir%.doccarchive}
58+
# 添加目錄名稱到 index.html,並創建連結
59+
echo " <li>- <a href=\"$dir/index.html\">$name</a></li>" >> "$indexFilePath"
60+
done
61+
62+
# 完成 index.html 的內容
63+
echo " </ul>
64+
</body>
65+
</html>" >> "$indexFilePath"
66+
67+
echo "Directory index created at $indexFilePath"

0 commit comments

Comments
 (0)