Skip to content

Commit a7e8dce

Browse files
authored
Merge pull request #52762 from maxwelldb/portal-script-hierarchy-osdocs4538
[OSDOCS-4538] Make the build script stop placing includes "above" the new master.adoc files
2 parents 2366517 + 3c7c8b3 commit a7e8dce

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

build_for_portal.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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)