Skip to content

Available Modules: Custom inserted text #721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 14 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
1 change: 1 addition & 0 deletions config/templates/hpc.template
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ plugins:
- exclude-search:
exclude:
- content/HPC/*
- available_software/custom/*


markdown_extensions:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
We have a dedicated page on AlphaFold available [here](../../../../alphafold.md).
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
We have a dedicated page on MATLAB available [here](../../../../MATLAB.md).
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
We have a dedicated page on OpenFOAM available [here](../../../../openFOAM.md).
2 changes: 2 additions & 0 deletions mkdocs/docs/HPC/only/gent/available_software/custom/Python.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
We have a dedicated page on Python available [here](../../../../python.md).
For more info on python virtual environments, check out [this page](../../../../setting_up_python_virtual_environments.md)
4 changes: 4 additions & 0 deletions mkdocs/docs/HPC/only/gent/available_software/custom/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Custom text for available software

This folder must contain markdown files precisely matching names of software packages available on the HPC cluster.
The MarkDown in these files will be included in the available_software/detail pages.
29 changes: 26 additions & 3 deletions scripts/available_software/available_software.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,9 @@ def main():
print("Done!")
print("Generate detailed pages... ", end="", flush=True)
detail_folder = os.path.join(root_dir, "mkdocs/docs/HPC/only/gent/available_software/detail")
custom_text_folder = os.path.join(root_dir, "mkdocs/docs/HPC/only/gent/available_software/custom")
generated_time_yml = os.path.join(root_dir, "mkdocs/extra/gent.yml") # yml containing time the data was generated
generate_detail_pages(json_path, detail_folder, generated_time_yml)
generate_detail_pages(json_path, detail_folder, custom_text_folder, generated_time_yml)
print("Done!")


Expand Down Expand Up @@ -359,6 +360,7 @@ def generate_software_detail_page(
software_name: str,
software_data: dict,
clusters: list,
custom_text_folder: str,
path: str
) -> None:
"""
Expand All @@ -367,13 +369,17 @@ def generate_software_detail_page(
@param software_name: Name of the software
@param software_data: Additional information about the software (version, etc...)
@param clusters: List with all the cluster names
@param custom_text_folder: Path to the folder with custom text for the software
@param path: Path of the directory where the detailed page will be created.
"""
sorted_versions = dict_sort(software_data["versions"])
newest_version = list(sorted_versions.keys())[-1]

filename = f"{path}/{software_name}.md"
md_file = MdUtils(file_name=filename, title=f"{software_name}")

md_file.write(get_custom_markdown_text(software_name, custom_text_folder))

md_file.new_header(level=1, title="Available modules")

md_file.new_paragraph(f"The overview below shows which {software_name} installations are available per HPC-UGent "
Expand All @@ -399,7 +405,24 @@ def generate_software_detail_page(
f.write("---\nhide:\n - toc\n---\n" + read_data)


def generate_detail_pages(json_path, dest_path, generated_time_yml) -> None:
def get_custom_markdown_text(module_name: str, custom_text_folder: str) -> str:
"""
Get the custom Markdown text that will be added to the detailed Markdown pages.

@return: Custom Markdown text
"""
custom_markdown_path = os.path.join(custom_text_folder, module_name + ".md")

if not os.path.exists(custom_markdown_path):
return ""

print(f"Adding custom text for {module_name} located at {custom_markdown_path}")

with open(custom_markdown_path, 'r') as f:
return "\n" + f.read() + "\n"


def generate_detail_pages(json_path, dest_path, custom_text_folder, generated_time_yml) -> None:
"""
Generate all the detailed pages for all the software that is available.
"""
Expand All @@ -412,7 +435,7 @@ def generate_detail_pages(json_path, dest_path, generated_time_yml) -> None:

all_clusters = data["clusters"]
for software, content in data["software"].items():
generate_software_detail_page(software, content, all_clusters, dest_path)
generate_software_detail_page(software, content, all_clusters, custom_text_folder, dest_path)


def update_generated_time_yml(generated_time_yml, generated_time) -> None:
Expand Down
Loading