Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b176fea

Browse files
authored
Merge pull request #193 from FoamyGuy/adding_docs_links_to_lib_md
Adding docs links to lib md
2 parents f165e24 + d5a1f55 commit b176fea

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

adabot/circuitpython_bundle.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,12 @@ def check_lib_links_md(bundle_path):
8080
pypi_name = ""
8181
if common_funcs.repo_is_on_pypi({"name" : url_name}):
8282
pypi_name = " ([PyPi](https://pypi.org/project/{}))".format(url_name.replace("_", "-").lower())
83+
docs_name = ""
84+
docs_link = common_funcs.get_docs_link(bundle_path, submodule)
85+
if docs_link:
86+
docs_name = f" \([Docs]({docs_link}))"
8387
title = url_name.replace("_", " ")
84-
list_line = "* [{0}]({1}){2}".format(title, url, pypi_name)
88+
list_line = "* [{0}]({1}){2}{3}".format(title, url, pypi_name, docs_name)
8589
if list_line not in read_lines:
8690
updates_made.append(url_name)
8791
if "drivers" in submodule[1]["path"]:

adabot/lib/common_funcs.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,19 @@ def list_repos(*, include_repos=None):
202202

203203
return repos
204204

205+
def get_docs_link(bundle_path, submodule):
206+
try:
207+
f = open(f"{bundle_path}/{submodule[1]['path']}/README.rst", 'r')
208+
lines = f.read().split("\n")
209+
f.close()
210+
for i in range(10):
211+
if "target" in lines[i] and "readthedocs" in lines[i]:
212+
return lines[i].replace(" :target: ", "")
213+
return None
214+
except FileNotFoundError:
215+
# didn't find readme
216+
return None
217+
205218
def repo_is_on_pypi(repo):
206219
"""returns True when the provided repository is in pypi"""
207220
is_on = False

0 commit comments

Comments
 (0)