Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions build_for_portal.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@
EXTERNAL_LINK_RE = re.compile(
"[\./]*([\w_-]+)/[\w_/-]*?([\w_.-]*\.(?:html|adoc))", re.DOTALL
)
INCLUDE_RE = re.compile("include::(.*?)\[(.*?)\]", re.M)
INCLUDE_RE = re.compile(r"^include::(.*?)\[(.*?)\]", re.M)
IFDEF_RE = re.compile(r"^if(n?)def::(.*?)\[\]", re.M)
ENDIF_RE = re.compile(r"^endif::(.*?)\[\]\r?\n", re.M)
COMMENT_CONTENT_RE = re.compile(r"^^////$.*?^////$", re.M | re.DOTALL)
COMMENTED_XREF_RE = re.compile(r"^//.*xref:.*$")
TAG_CONTENT_RE = re.compile(
r"//\s+tag::(.*?)\[\].*?// end::(.*?)\[\]", re.M | re.DOTALL
)
Expand Down Expand Up @@ -625,10 +626,19 @@ def scrub_file(info, book_src_dir, src_file, tag=None, cwd=None):
# data that it finds.
# modified 20/Aug/2024 to process https links which are preceded
# by an added directory (happens with hugeBook)
# Modified 05/Dec/2024 to allow for https links from openshift-kni repo.

# Check for both allowed URL patterns
https_pos = base_src_file.find("https://raw.githubusercontent.com/openshift/")
if https_pos >=0:
base_src_file = base_src_file[https_pos:]
https_kni_pos = base_src_file.find("https://raw.githubusercontent.com/openshift-kni/")

if https_pos >= 0 or https_kni_pos >= 0:
# Ensure we start from the correct URL (either github or openshift-kni)
if https_kni_pos >= 0:
base_src_file = base_src_file[https_kni_pos:]
else:
base_src_file = base_src_file[https_pos:]

try:
response = requests.get(base_src_file)
if response:
Expand Down Expand Up @@ -656,6 +666,9 @@ def scrub_file(info, book_src_dir, src_file, tag=None, cwd=None):
if line.strip() == "" and not content_found:
continue

# Replace lines containing commented xrefs
line = COMMENTED_XREF_RE.sub("// Removed commented line that contains an xref", line)

# Check if the line should be included in the output
if include_line(line):
content_found = True
Expand Down
18 changes: 17 additions & 1 deletion makeBuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

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

import argparse
import sys
import os
import logging
Expand All @@ -19,6 +20,15 @@

#print(branch)

def setup_parser():
parser = argparse.ArgumentParser(
formatter_class=argparse.ArgumentDefaultsHelpFormatter
)
parser.add_argument(
"--include-api-book", help="Include the rest_api book in the build", action="store_true", default=False,
)
return parser

# function to convert XML ids to HTML 4 compatible ids from ccutil
def _fix_ids_for_html4(tree):
"""
Expand Down Expand Up @@ -122,6 +132,10 @@ def build_book(book):
# Initialize logging
cli.init_logging(False, False)


parser = setup_parser()
args = parser.parse_args()

for distro in os.listdir("drupal-build"):

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

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