Skip to content

Commit 7b5c4bd

Browse files
committed
Updating build.py
1 parent dad0c4c commit 7b5c4bd

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

build.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
import time
1414
import yaml
1515

16+
from aura import cli
17+
18+
cli.init_logging(False, True)
19+
20+
has_errors = False
1621
CLONE_DIR = "."
1722
BASE_PORTAL_URL = "https://access.redhat.com/documentation/en-us/"
1823
ID_RE = re.compile("^\[(?:\[|id=\'|#)(.*?)(\'?,.*?)?(?:\]|\')?\]", re.M | re.DOTALL)
@@ -405,7 +410,8 @@ def copy_file(info, book_src_dir, src_file, dest_dir, dest_file, include_check=T
405410

406411
# Check for any includes
407412
if include_check:
408-
include_iter = INCLUDE_RE.finditer(content)
413+
cleaned_content = remove_conditional_content(content, info, tag=tag)
414+
include_iter = INCLUDE_RE.finditer(cleaned_content)
409415
for include in include_iter:
410416
include_text = include.group(0)
411417
include_path = include.group(1)
@@ -605,7 +611,8 @@ def _fix_links(content, book_dir, src_file, info, tag=None, cwd=None):
605611
fixed_link = link_text
606612
if EXTERNAL_LINK_RE.search(link_file) is not None:
607613
rel_src_file = src_file.replace(os.path.dirname(book_dir) + "/", "")
608-
log.warning("WARNING (%s): \"%s\" appears to try to reference a file not included in the \"%s\" distro", rel_src_file, link_text.replace("\n", ""), info['distro'])
614+
has_errors = True
615+
log.error("ERROR (%s): \"%s\" appears to try to reference a file not included in the \"%s\" distro", rel_src_file, link_text.replace("\n", ""), info['distro'])
609616
else:
610617
fixed_link = "xref:" + link_anchor.replace("#", "") + link_title
611618

@@ -640,7 +647,7 @@ def remove_conditional_content(content, info, tag=None):
640647
endpos = endif.end()
641648
break
642649
else:
643-
search_pos = next_ifdef.end()
650+
search_pos = endif.end()
644651

645652
# Replace the content and move the end pos to be the same as the start since the content was removed
646653
ifdef_text = content[pos:endpos]
@@ -926,6 +933,9 @@ def main():
926933

927934
# Copy the original data and reformat for drupal
928935
reformat_for_drupal(info)
936+
937+
if has_errors:
938+
sys.exit(1)
929939

930940
if args.push:
931941
# Parse the repo urls

0 commit comments

Comments
 (0)