Skip to content

Commit

Permalink
added validation
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveSamJacob19 committed Jul 8, 2024
1 parent fd2b28e commit 45ac981
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions scripts/build/parse_features_toc.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,22 +297,25 @@ def sort_versions_for(feature, high_to_low=True):
print("Modifying the docs TOCs of version " + version + " to remove the duplicate feature versions.")
feature_version_path = featurePath + version
for root, dirs, files in os.walk(feature_version_path):
for basename in files:
if fnmatch.fnmatch(basename, "*.html"):
if(basename != "index.html"):
href = path.join(root, basename)
page = BeautifulSoup(open(href), "lxml")

# Find the toc and replace it with the modified toc
page_toc = page.find_all('ul', {'class': 'nav-list'})[0]
if page_toc.find('span', text='Features') is not None:
toc_to_replace = page_toc.find('span', text='Features').parent
elif page_toc.find('a', text='Features') is not None:
toc_to_replace = page_toc.find('a', text='Features').parent
toc_to_replace.clear()
toc_to_replace.append(featureTOC)
with open(href, "w") as file:
file.write(str(page))
if "../" not in root:
for basename in files:
if fnmatch.fnmatch(basename, "*.html"):
if(basename != "index.html"):
href = path.join(root, basename)
page = BeautifulSoup(open(href), "lxml")

# Find the toc and replace it with the modified toc
page_toc = page.find_all('ul', {'class': 'nav-list'})[0]
if page_toc.find('span', text='Features') is not None:
toc_to_replace = page_toc.find('span', text='Features').parent
elif page_toc.find('a', text='Features') is not None:
toc_to_replace = page_toc.find('a', text='Features').parent
toc_to_replace.clear()
toc_to_replace.append(featureTOC)
with open(href, "w") as file:
file.write(str(page))
else:
print("invalid")

timerEnd = time.time()
print('Total execution time for parsing ToC Features: ', timerEnd - timerStart)

0 comments on commit 45ac981

Please sign in to comment.