Skip to content

Commit

Permalink
Merge pull request #193 from FoamyGuy/adding_docs_links_to_lib_md
Browse files Browse the repository at this point in the history
Adding docs links to lib md
  • Loading branch information
tannewt authored Nov 9, 2020
2 parents f165e24 + d5a1f55 commit b176fea
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 5 additions & 1 deletion adabot/circuitpython_bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]:
Expand Down
13 changes: 13 additions & 0 deletions adabot/lib/common_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b176fea

Please sign in to comment.