Skip to content

Commit

Permalink
Merge pull request #3794 from OpenLiberty/validate_parse_toc
Browse files Browse the repository at this point in the history
Added Validation in python file
  • Loading branch information
SteveSamJacob19 authored Jul 5, 2024
2 parents d610ddd + 9492edf commit c2aabd3
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 path for root")

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

0 comments on commit c2aabd3

Please sign in to comment.