Skip to content

Commit

Permalink
Merge pull request #485 from FoamyGuy/add_import_name
Browse files Browse the repository at this point in the history
Add import name
  • Loading branch information
dhalbert authored Nov 6, 2024
2 parents 56768b6 + e7716c6 commit 99c6f7f
Show file tree
Hide file tree
Showing 2 changed files with 380 additions and 347 deletions.
33 changes: 33 additions & 0 deletions add_import_names.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# SPDX-FileCopyrightText: 2024 Tim Cocks for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
Creates updated_drivers.rst which includes import names for each module.
"""

if __name__ == "__main__":
with open("docs/drivers.rst", "r") as drivers_rst:
with open("updated_drivers.rst", "w") as updated_drivers_rst:
lines = drivers_rst.readlines()

for line in lines:

if "<https://docs.circuitpython.org/" in line:
docs_url = line.split("<")[1].split(">")[0]
# print(docs_url)

short_name = line.split("https://docs.circuitpython.org/projects/")[
1
].split("/en/latest/")[0]
insert_index = line.index("<") - 1
# print(f"adafruit_{short_name} | {insert_index}")

modified = (
line[:insert_index]
+ f" (adafruit_{short_name})"
+ line[insert_index:]
)
# print(modified)
updated_drivers_rst.write(modified)
else:
updated_drivers_rst.write(line)
Loading

0 comments on commit 99c6f7f

Please sign in to comment.