diff --git a/scripts/build/parse_features_toc.py b/scripts/build/parse_features_toc.py index e0cf8a9b5..05192fa03 100755 --- a/scripts/build/parse_features_toc.py +++ b/scripts/build/parse_features_toc.py @@ -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)