-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #485 from FoamyGuy/add_import_name
Add import name
- Loading branch information
Showing
2 changed files
with
380 additions
and
347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.