Skip to content

Commit 91ad185

Browse files
Merge pull request #87252 from gaurav-nelson/rhacs-docs-main
[RHACS] Synced build scripts form main
2 parents e1b8afe + 7e65d40 commit 91ad185

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

build_for_portal.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@
3737
EXTERNAL_LINK_RE = re.compile(
3838
"[\./]*([\w_-]+)/[\w_/-]*?([\w_.-]*\.(?:html|adoc))", re.DOTALL
3939
)
40-
INCLUDE_RE = re.compile("include::(.*?)\[(.*?)\]", re.M)
40+
INCLUDE_RE = re.compile(r"^include::(.*?)\[(.*?)\]", re.M)
4141
IFDEF_RE = re.compile(r"^if(n?)def::(.*?)\[\]", re.M)
4242
ENDIF_RE = re.compile(r"^endif::(.*?)\[\]\r?\n", re.M)
4343
COMMENT_CONTENT_RE = re.compile(r"^^////$.*?^////$", re.M | re.DOTALL)
44+
COMMENTED_XREF_RE = re.compile(r"^//.*xref:.*$")
4445
TAG_CONTENT_RE = re.compile(
4546
r"//\s+tag::(.*?)\[\].*?// end::(.*?)\[\]", re.M | re.DOTALL
4647
)
@@ -625,10 +626,19 @@ def scrub_file(info, book_src_dir, src_file, tag=None, cwd=None):
625626
# data that it finds.
626627
# modified 20/Aug/2024 to process https links which are preceded
627628
# by an added directory (happens with hugeBook)
629+
# Modified 05/Dec/2024 to allow for https links from openshift-kni repo.
628630

631+
# Check for both allowed URL patterns
629632
https_pos = base_src_file.find("https://raw.githubusercontent.com/openshift/")
630-
if https_pos >=0:
631-
base_src_file = base_src_file[https_pos:]
633+
https_kni_pos = base_src_file.find("https://raw.githubusercontent.com/openshift-kni/")
634+
635+
if https_pos >= 0 or https_kni_pos >= 0:
636+
# Ensure we start from the correct URL (either github or openshift-kni)
637+
if https_kni_pos >= 0:
638+
base_src_file = base_src_file[https_kni_pos:]
639+
else:
640+
base_src_file = base_src_file[https_pos:]
641+
632642
try:
633643
response = requests.get(base_src_file)
634644
if response:
@@ -656,6 +666,9 @@ def scrub_file(info, book_src_dir, src_file, tag=None, cwd=None):
656666
if line.strip() == "" and not content_found:
657667
continue
658668

669+
# Replace lines containing commented xrefs
670+
line = COMMENTED_XREF_RE.sub("// Removed commented line that contains an xref", line)
671+
659672
# Check if the line should be included in the output
660673
if include_line(line):
661674
content_found = True

makeBuild.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
# uses a refactored Aura script which is an opensource port of ccutil
55

6+
import argparse
67
import sys
78
import os
89
import logging
@@ -19,6 +20,15 @@
1920

2021
#print(branch)
2122

23+
def setup_parser():
24+
parser = argparse.ArgumentParser(
25+
formatter_class=argparse.ArgumentDefaultsHelpFormatter
26+
)
27+
parser.add_argument(
28+
"--include-api-book", help="Include the rest_api book in the build", action="store_true", default=False,
29+
)
30+
return parser
31+
2232
# function to convert XML ids to HTML 4 compatible ids from ccutil
2333
def _fix_ids_for_html4(tree):
2434
"""
@@ -122,6 +132,10 @@ def build_book(book):
122132
# Initialize logging
123133
cli.init_logging(False, False)
124134

135+
136+
parser = setup_parser()
137+
args = parser.parse_args()
138+
125139
for distro in os.listdir("drupal-build"):
126140

127141
print("---------------------------------------")
@@ -136,7 +150,9 @@ def build_book(book):
136150
continue
137151
# rest api book is a pain and doesn't convert well
138152
if book == "rest_api":
139-
continue
153+
# Exclude the REST API book unless we explicitly require it
154+
if not args.include_api_book:
155+
continue
140156

141157
if os.path.exists(os.path.join("drupal-build", distro, book,"hugeBook.flag")):
142158
for secondary_book in os.listdir(os.path.join("drupal-build", distro, book)):

0 commit comments

Comments
 (0)