diff --git a/adabot/circuitpython_bundle.py b/adabot/circuitpython_bundle.py index 308f19d..137db7a 100644 --- a/adabot/circuitpython_bundle.py +++ b/adabot/circuitpython_bundle.py @@ -80,8 +80,12 @@ def check_lib_links_md(bundle_path): pypi_name = "" if common_funcs.repo_is_on_pypi({"name" : url_name}): pypi_name = " ([PyPi](https://pypi.org/project/{}))".format(url_name.replace("_", "-").lower()) + docs_name = "" + docs_link = common_funcs.get_docs_link(bundle_path, submodule) + if docs_link: + docs_name = f" \([Docs]({docs_link}))" title = url_name.replace("_", " ") - list_line = "* [{0}]({1}){2}".format(title, url, pypi_name) + list_line = "* [{0}]({1}){2}{3}".format(title, url, pypi_name, docs_name) if list_line not in read_lines: updates_made.append(url_name) if "drivers" in submodule[1]["path"]: diff --git a/adabot/lib/common_funcs.py b/adabot/lib/common_funcs.py index 93a4d9c..0f0f22c 100644 --- a/adabot/lib/common_funcs.py +++ b/adabot/lib/common_funcs.py @@ -202,6 +202,19 @@ def list_repos(*, include_repos=None): return repos +def get_docs_link(bundle_path, submodule): + try: + f = open(f"{bundle_path}/{submodule[1]['path']}/README.rst", 'r') + lines = f.read().split("\n") + f.close() + for i in range(10): + if "target" in lines[i] and "readthedocs" in lines[i]: + return lines[i].replace(" :target: ", "") + return None + except FileNotFoundError: + # didn't find readme + return None + def repo_is_on_pypi(repo): """returns True when the provided repository is in pypi""" is_on = False