diff --git a/doc/requirements.txt b/doc/requirements.txt index d06348e4b..739f5b300 100644 --- a/doc/requirements.txt +++ b/doc/requirements.txt @@ -6,6 +6,8 @@ PyYAML==6.0 sphinx-tabs<=3.4.1 pandas openpyxl +bs4 +lxml # API Reference Guide os-api-ref>=1.5.0 # Apache-2.0 diff --git a/hide-empty-rows.py b/hide-empty-rows.py new file mode 100644 index 000000000..253a62169 --- /dev/null +++ b/hide-empty-rows.py @@ -0,0 +1,27 @@ +import sys +from bs4 import BeautifulSoup + +def remove_empty_rows_from_tables(file_path): + with open(file_path, 'r', encoding='utf-8') as file: + soup = BeautifulSoup(file, 'lxml') + + # Find all tables in the document + tables = soup.find_all('table') + + for table in tables: + # Find all rows in the table + rows = table.find_all('tr') + for row in rows: + # Check if the row is empty (contains no visible text) + if not row.get_text(strip=True): + row.decompose() # Remove the empty row + + # Save the modified HTML back to the file + with open(file_path, 'w', encoding='utf-8') as file: + file.write(str(soup)) + +if __name__ == '__main__': + for html_file in sys.argv[1:]: + remove_empty_rows_from_tables(html_file) + print(f"Processed {html_file}") + diff --git a/tox.ini b/tox.ini index 30b2087be..dd4651120 100644 --- a/tox.ini +++ b/tox.ini @@ -32,7 +32,8 @@ commands = git clean -dfx doc/source/fault-mgmt/ git restore doc/source/dist_cloud/kubernetes/* bash hw-updates.sh - bash hide-empty-rows.sh doc/build/html + # bash hide-empty-rows.sh doc/build/html + bash -c 'python hide-empty-rows.py $(grep -rl --include="*.html" "post-build-hide-empty-table-rows" doc/build/html/*)' bash htmlChecks.sh doc/build/html