Skip to content

Commit 99c6f7f

Browse files
authored
Merge pull request #485 from FoamyGuy/add_import_name
Add import name
2 parents 56768b6 + e7716c6 commit 99c6f7f

File tree

2 files changed

+380
-347
lines changed

2 files changed

+380
-347
lines changed

add_import_names.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# SPDX-FileCopyrightText: 2024 Tim Cocks for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
"""
5+
Creates updated_drivers.rst which includes import names for each module.
6+
"""
7+
8+
if __name__ == "__main__":
9+
with open("docs/drivers.rst", "r") as drivers_rst:
10+
with open("updated_drivers.rst", "w") as updated_drivers_rst:
11+
lines = drivers_rst.readlines()
12+
13+
for line in lines:
14+
15+
if "<https://docs.circuitpython.org/" in line:
16+
docs_url = line.split("<")[1].split(">")[0]
17+
# print(docs_url)
18+
19+
short_name = line.split("https://docs.circuitpython.org/projects/")[
20+
1
21+
].split("/en/latest/")[0]
22+
insert_index = line.index("<") - 1
23+
# print(f"adafruit_{short_name} | {insert_index}")
24+
25+
modified = (
26+
line[:insert_index]
27+
+ f" (adafruit_{short_name})"
28+
+ line[insert_index:]
29+
)
30+
# print(modified)
31+
updated_drivers_rst.write(modified)
32+
else:
33+
updated_drivers_rst.write(line)

0 commit comments

Comments
 (0)