Skip to content

Commit e8e7316

Browse files
committed
Modernize docs make script
1 parent f338538 commit e8e7316

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

docs/make.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,27 @@
33
"""Build HTML from reST files."""
44

55
from glob import glob
6-
from os.path import splitext
6+
from pathlib import Path
77

88
from docutils.core import publish_file
99

1010
print("Creating the documentation...")
1111

1212
for rst_file in glob('*.rst'):
13-
name = splitext(rst_file)[0]
14-
lang = splitext(name)[1]
13+
rst_path = Path(rst_file)
14+
name = Path(rst_file).stem
15+
lang = Path(name).suffix
1516
if lang.startswith('.'):
1617
lang = lang[1:]
1718
if lang == 'zh':
1819
lang = 'zh_cn'
1920
else:
2021
lang = 'en'
21-
html_file = name + '.html'
22+
html_path = Path(name + '.html')
2223
print(name, lang)
2324

24-
with open(rst_file, encoding='utf-8-sig') as source:
25-
with open(html_file, 'w', encoding='utf-8') as destination:
25+
with rst_path.open(encoding='utf-8-sig') as source:
26+
with html_path.open('w', encoding='utf-8') as destination:
2627
output = publish_file(
2728
writer_name='html5', source=source, destination=destination,
2829
enable_exit_status=True,

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,6 @@ select = [
106106
]
107107
# You can use `ruff rule ...` to see what these ignored rules check
108108
ignore = [
109-
"PTH122",
110-
"PTH123",
111109
"S110",
112110
]
113111
line-length = 79

0 commit comments

Comments
 (0)