Add build context awaremess to col removal
This change allows valid build contexts for column removal to be specificed directly in rst file as meta. Change-Id: Ibab2c9dab752aa5bd3a4fe8a0b23982d21bdd812 Signed-off-by: Ron Stone <ronald.stone@windriver.com>
This commit is contained in:
parent
9fc33f8fe5
commit
0b3fced7df
@ -8,12 +8,25 @@ def remove_column_from_tables(file_path):
|
||||
with open(file_path, 'r', encoding='utf-8') as file:
|
||||
soup = BeautifulSoup(file, 'lxml')
|
||||
|
||||
in_context = None
|
||||
|
||||
print("Checking if in valid context for", file_path)
|
||||
|
||||
if BUILD_CONTEXT:
|
||||
context_tag = soup.find('meta', attrs={'name': 'docs-build-context'})
|
||||
if context_tag:
|
||||
if context_tag.get('content') != BUILD_CONTEXT:
|
||||
print("Not in", context_tag.get('content'), "- skipping", file_path)
|
||||
context_tags = soup.find('meta', attrs={'name': 'docs-build-context'})
|
||||
if context_tags:
|
||||
for context_tag in context_tags.get('content').split(","):
|
||||
if context_tag == BUILD_CONTEXT:
|
||||
in_context = True
|
||||
print(" ... in", context_tag, "- Processing")
|
||||
break
|
||||
else:
|
||||
print(" ... not in", context_tag)
|
||||
|
||||
if not in_context:
|
||||
return
|
||||
else:
|
||||
print("docs-build-context not set. Treating", BUILD_CONTEXT, "as valid.")
|
||||
|
||||
# Find column to delete
|
||||
column_tag = soup.find('meta', attrs={'name': 'remove-column-from-html-table'})
|
||||
@ -26,7 +39,8 @@ def remove_column_from_tables(file_path):
|
||||
# Remove empty rows?
|
||||
row_tag = soup.find('meta', attrs={'name': 'remove-column-emptied-row'})
|
||||
if row_tag:
|
||||
empty_rows = 1
|
||||
if row_tag.get('content') == 1:
|
||||
empty_rows = 1
|
||||
else:
|
||||
empty_rows = 0
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user