Skip to content

Commit 38c2231

Browse files
committed
Change includes directory handling to rely on symlinks to proj root
See OSDOCS-4538 for additional context.
1 parent d97bada commit 38c2231

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

build_for_portal.py

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@
1919
import logging
2020

2121
# See manual and pip3 install aura.tar.gz for logging
22-
from aura import cli
23-
24-
cli.init_logging(False, True)
22+
# from aura import cli
23+
#
24+
# cli.init_logging(False, True)
2525

2626
has_errors = False
2727
CLONE_DIR = "."
@@ -1090,6 +1090,39 @@ def parse_repo_config(config_file, distro, version):
10901090
return repo_urls
10911091

10921092

1093+
def collect_master_adoc_files(project_path=os.path.abspath(os.curdir)):
1094+
"""Given the project path, return a list of all master.adoc file paths."""
1095+
1096+
master_adoc_collection = []
1097+
1098+
for project_dir, dirs, files in os.walk(project_path, topdown=True):
1099+
if "master.adoc" in files:
1100+
master_path = os.path.join(project_dir, "master.adoc")
1101+
master_adoc_collection.append(master_path)
1102+
1103+
return master_adoc_collection
1104+
1105+
1106+
def create_symlinks_to_project_root_from_master_files(
1107+
list_of_master_file_paths, distro="openshift-enterprise"
1108+
):
1109+
"""Create symlinks for every master.adoc-containing
1110+
directory to the openshift-docs project root."""
1111+
1112+
drupal_build_path_includes_dir = os.path.join(
1113+
os.path.abspath(os.curdir), "drupal-build", distro, "includes"
1114+
)
1115+
1116+
if not os.path.exists(drupal_build_path_includes_dir):
1117+
os.mkdir(drupal_build_path_includes_dir)
1118+
1119+
for path in list_of_master_file_paths:
1120+
directory = os.path.split(path)[0]
1121+
book_includes_dir = os.path.join(directory, "includes")
1122+
if not os.path.isdir(book_includes_dir):
1123+
os.symlink(drupal_build_path_includes_dir, book_includes_dir)
1124+
1125+
10931126
def main():
10941127
parser = setup_parser()
10951128
args = parser.parse_args()
@@ -1138,6 +1171,10 @@ def main():
11381171
log.info("Building the drupal files")
11391172
build_master_files(info)
11401173

1174+
create_symlinks_to_project_root_from_master_files(
1175+
collect_master_adoc_files(), args.distro
1176+
)
1177+
11411178
# Copy the original data and reformat for drupal
11421179
reformat_for_drupal(info)
11431180

0 commit comments

Comments
 (0)