Skip to content

Commit 1744f61

Browse files
authored
Merge pull request #1095 from UE4SS-RE/pushdocsupdates
Update mdBook and cargo-binstall versions
2 parents c4b5add + 358d715 commit 1744f61

File tree

6 files changed

+114
-14
lines changed

6 files changed

+114
-14
lines changed

.github/workflows/pushdocs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ jobs:
2121
python-version: '3.x'
2222

2323
- name: Setup mdBook Preprocessors
24-
uses: cargo-bins/cargo-binstall@v1.6.8
24+
uses: cargo-bins/cargo-binstall@v1.16.2
2525

2626
- name: Setup mdBook
2727
run: |
2828
mkdir mdbook
29-
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.14/mdbook-v0.4.14-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook
29+
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.5.1/mdbook-v0.5.1-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook
3030
echo `pwd`/mdbook >> $GITHUB_PATH
3131
3232
- name: Install mdBook Preprocessors

docs-export/book.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[book]
22
language = "en"
3-
multilingual = false
43
src = "src"
54
title = "UE4SS Documentation"
65

@@ -9,6 +8,4 @@ additional-css = ["css/custom.css"]
98

109
[output.html.fold]
1110
enable = true
12-
level = 1
13-
14-
[preprocessor.alerts]
11+
level = 1

docs-export/deduplicate_summary.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env python3
2+
3+
import os
4+
import sys
5+
import re
6+
7+
def deduplicate_summary(summary_path):
8+
"""
9+
Remove duplicate file references from SUMMARY.md while preserving structure.
10+
Keeps the first occurrence of each unique file path.
11+
"""
12+
if not os.path.exists(summary_path):
13+
return False
14+
15+
with open(summary_path, 'r', encoding='utf-8') as f:
16+
lines = f.readlines()
17+
18+
seen_paths = set()
19+
new_lines = []
20+
modified = False
21+
22+
# Regex to match markdown links: [text](path)
23+
link_pattern = re.compile(r'\[([^\]]+)\]\(([^)]+)\)')
24+
25+
for line in lines:
26+
# Find all markdown links in the line
27+
matches = link_pattern.findall(line)
28+
29+
if matches:
30+
# Get the file path (remove anchors)
31+
for text, path in matches:
32+
# Remove anchor if present
33+
clean_path = path.split('#')[0]
34+
35+
if clean_path in seen_paths:
36+
# This is a duplicate, comment it out
37+
if not line.strip().startswith('<!--'):
38+
line = ''
39+
modified = True
40+
else:
41+
seen_paths.add(clean_path)
42+
43+
new_lines.append(line)
44+
45+
if modified:
46+
with open(summary_path, 'w', encoding='utf-8') as f:
47+
f.writelines(new_lines)
48+
return True
49+
50+
return False
51+
52+
if __name__ == '__main__':
53+
if len(sys.argv) > 1:
54+
summary_path = sys.argv[1]
55+
else:
56+
summary_path = 'SUMMARY.md'
57+
58+
changed = deduplicate_summary(summary_path)
59+
if changed:
60+
print(f"Deduplicated {summary_path}")
61+
else:
62+
print(f"No duplicates found in {summary_path}")

docs-export/export.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,39 @@ def copy_transform(src, dst, transformer):
2727
with open(dst, 'w') as file:
2828
file.write(content)
2929

30+
def deduplicate_summary(summary_path):
31+
"""Remove duplicate file references from SUMMARY.md"""
32+
if not os.path.exists(summary_path):
33+
return
34+
35+
with open(summary_path, 'r', encoding='utf-8') as f:
36+
lines = f.readlines()
37+
38+
seen_paths = set()
39+
new_lines = []
40+
link_pattern = re.compile(r'\[([^\]]+)\]\(([^)]+)\)')
41+
42+
for line in lines:
43+
matches = link_pattern.findall(line)
44+
is_duplicate = False
45+
46+
if matches:
47+
for text, path in matches:
48+
clean_path = path.split('#')[0]
49+
if clean_path in seen_paths:
50+
# Skip this line entirely instead of commenting it out
51+
is_duplicate = True
52+
break
53+
else:
54+
seen_paths.add(clean_path)
55+
56+
# Only add the line if it's not a duplicate
57+
if not is_duplicate:
58+
new_lines.append(line)
59+
60+
with open(summary_path, 'w', encoding='utf-8') as f:
61+
f.writelines(new_lines)
62+
3063
def export_version(ref, name):
3164
docs_spec = f'{ref}:docs'
3265

@@ -46,6 +79,12 @@ def export_version(ref, name):
4679
subprocess.check_output(('tar', 'xvf', '-', '-C', src_dir), stdin=ps.stdout)
4780
ps.wait()
4881

82+
# Deduplicate SUMMARY.md for old versions with duplicate paths
83+
# mdBook v0.5+ enforces unique paths, but old release tags may have duplicates
84+
# This preprocessing step removes duplicate entries before mdBook sees them
85+
summary_path = os.path.join(src_dir, 'SUMMARY.md')
86+
deduplicate_summary(summary_path)
87+
4988
# copy README.md to <version>/src/
5089
# rewrite absolute URLs to relative mdBook URLs
5190
copy_transform('README.md', os.path.join(src_dir, 'README.md'), lambda content: re.sub(r'\(https://docs.ue4ss.com/dev/([^)#]+)\.html(#[^)]*)?\)', r'(\1.md\2)', content))

docs-repo-template/build.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,14 @@
99
build_dir = 'docs'
1010

1111
# build release as the root
12-
subprocess.run(['mdbook', 'build', os.path.join('versions', 'release'), '-d', os.path.abspath(build_dir)])
12+
result = subprocess.run(['mdbook', 'build', os.path.join('versions', 'release'), '-d', os.path.abspath(build_dir)])
13+
if result.returncode != 0:
14+
print(f"ERROR: Failed to build release docs")
15+
exit(1)
1316

1417
for version in os.listdir('versions'):
1518
version_build_dir = os.path.join(build_dir, version)
16-
subprocess.run(['mdbook', 'build', os.path.join('versions', version), '-d', os.path.abspath(version_build_dir)])
19+
result = subprocess.run(['mdbook', 'build', os.path.join('versions', version), '-d', os.path.abspath(version_build_dir)])
20+
if result.returncode != 0:
21+
print(f"WARNING: Failed to build docs for version {version}, skipping...")
22+
continue

docs/SUMMARY.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,19 +117,15 @@
117117
- [Creating a C++ Mod](./guides/creating-a-c++-mod.md)
118118
- [Installing a C++ Mod](./guides/installing-a-c++-mod.md)
119119
- [GUI tabs with a C++ Mod](./guides/creating-gui-tabs-with-c++-mod.md)
120+
- [Accessing UE properties with a C++ mod](./guides/accessing-ue-properties-c++.md)
120121

121122
## Guides
122123

123124
- [Guides]()
124125
- [Fixing missing AOBs](./guides/fixing-compatibility-problems.md)
125126
- [Fixing missing AOBs (Advanced)](./guides/fixing-compatibility-problems-advanced.md)
126127
- [Generating UHT headers](./guides/generating-uht-compatible-headers.md)
127-
- [Creating a C++ Mod](./guides/creating-a-c++-mod.md)
128-
- [Installing a C++ Mod](./guides/installing-a-c++-mod.md)
129-
- [GUI tabs with a C++ Mod](./guides/creating-gui-tabs-with-c++-mod.md)
130-
- [Accessing UE properties with a C++ mod](./guides/accessing-ue-properties-c++.md)
131-
- [Creating a Lua Mod](./guides/creating-a-lua-mod.md)
132-
- [Using Custom Lua Bindings](./guides/using-custom-lua-bindings.md)
128+
133129

134130
## Misc
135131

0 commit comments

Comments
 (0)