Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
FoamyGuy committed Nov 5, 2024
1 parent 229be5f commit 1a6a6e4
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions add_import_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,29 @@
Creates updated_drivers.rst which includes import names for each module.
"""

if __name__ == '__main__':
with open('docs/drivers.rst', 'r') as drivers_rst:
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)
# print(docs_url)

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

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

0 comments on commit 1a6a6e4

Please sign in to comment.