remove empty rows (r9, r8, r7, r6)
Use bs4 to remove empty table rows from tagged html output files. This replaces shell script that had a column count limitation. - Remove arg count check - not needed Change-Id: I09bd4cfd4360dbb04638ed3d6a16899bc1f4f62d Signed-off-by: Ron Stone <ronald.stone@windriver.com>
This commit is contained in:
parent
9ce722249e
commit
37a6f5c996
@ -6,6 +6,8 @@ PyYAML==6.0
|
|||||||
sphinx-tabs<=3.4.1
|
sphinx-tabs<=3.4.1
|
||||||
pandas
|
pandas
|
||||||
openpyxl
|
openpyxl
|
||||||
|
bs4
|
||||||
|
lxml
|
||||||
|
|
||||||
# API Reference Guide
|
# API Reference Guide
|
||||||
os-api-ref>=1.5.0 # Apache-2.0
|
os-api-ref>=1.5.0 # Apache-2.0
|
||||||
|
27
hide-empty-rows.py
Normal file
27
hide-empty-rows.py
Normal file
@ -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}")
|
||||||
|
|
3
tox.ini
3
tox.ini
@ -32,7 +32,8 @@ commands =
|
|||||||
git clean -dfx doc/source/fault-mgmt/
|
git clean -dfx doc/source/fault-mgmt/
|
||||||
git restore doc/source/dist_cloud/kubernetes/*
|
git restore doc/source/dist_cloud/kubernetes/*
|
||||||
bash hw-updates.sh
|
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
|
bash htmlChecks.sh doc/build/html
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user