Skip to content

Commit f5e1d8e

Browse files
committed
Improve deadlink checker
1 parent d8e79f9 commit f5e1d8e

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

devtools/deadlinks.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def _filter(elem):
2525
# Create a list containing all links
2626
links = [link.get("href") for link in filter(_filter, soup.find_all("a", href=True))]
2727
if links:
28-
print(links)
28+
print("Checking", links)
2929

3030
# Initialize list for broken links.
3131
broken_links = []
@@ -50,17 +50,19 @@ def _validate_url(url):
5050
def check_project(project):
5151
project_path = doc_folder + project
5252
broken_links = {}
53+
html_file_found = False
5354

5455
for dirName, subdirList, fileList in os.walk(project_path):
5556
for fname in fileList:
5657
if fname.endswith(".html"):
58+
html_file_found = True
5759
fpath = dirName + '/' + fname
5860

5961
file_broken_links = get_broken_links(fpath)
6062
if file_broken_links:
6163
broken_links[fpath] = file_broken_links
6264

63-
return broken_links
65+
return html_file_found, broken_links
6466

6567
# main
6668

@@ -76,7 +78,10 @@ def check_project(project):
7678
]
7779

7880
for project in projects:
79-
broken_links.update(check_project(project))
81+
html_file_found, broken = check_project(project)
82+
if not html_file_found:
83+
print("No .html file found in project " + project + ". Did you generate the docs?")
84+
broken_links.update(broken)
8085

8186
if len(broken_links) > 0:
8287
print("Dead links found!")

0 commit comments

Comments
 (0)