Skip to content

Commit

Permalink
down rank the pages in the search, add in inter page links
Browse files Browse the repository at this point in the history
  • Loading branch information
branfosj committed Sep 7, 2024
1 parent 69e6562 commit 93aa583
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docs/version-specific/software-markdown-pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,36 @@
from pathlib import Path


MKDOCS_SEARCH_PRIORITY = """---
search:
boost: 0.5
---
"""


def generate_character_links_line(characters, current=None):
"""
Generate links to index page for each character
:param characters: Initial characters to generate links for
"""
links = []
for c in characters:
if c == current:
links.append(f'*{c}*')
else:
links.append(f"[../{c}/index.md]({c})")
return f"{' - '.join(links)}\n\n"


def output_markdown(processed, output_base_path):
"""
Output markdown pages (index and per letter directories, each with an index and page per software)
:param processed: Processed data to output (dictionary - letter -> software -> list of versions)
:param output_base_path: Pathlib object for base path of output
"""
packages = sum(len(v) for v in processed.values())
top_page = open(output_base_path / 'index.md', 'w')
top_page.write(MKDOCS_SEARCH_PRIORITY)
top_page.write("# List of supported software\n\n")
top_page.write(f"EasyBuild supports {packages} different software packages (incl. toolchains, bundles):\n\n")

Expand All @@ -17,7 +44,9 @@ def output_markdown(processed, output_base_path):
letter_dir = output_base_path / letter
letter_dir.mkdir()
letter_page = open(letter_dir / 'index.md', 'w')
letter_page.write(MKDOCS_SEARCH_PRIORITY)
letter_page.write(f"# List of supported software ({letter})\n\n")
letter_page.write(generate_character_links_line([v for v in processed], current=letter))

for software in processed[letter]:
top_page.write(f" * [{software}]({letter}/{software}.md)\n")
Expand All @@ -26,6 +55,7 @@ def output_markdown(processed, output_base_path):
versionsuffix = any(v['versionsuffix'] for v in processed[letter][software])

software_page = open(letter_dir / f'{software}.md', 'w')
software_page.write(MKDOCS_SEARCH_PRIORITY)
software_page.write(f"# {software}\n\n")
software_page.write(f"{processed[letter][software][0]['description']}\n\n")
software_page.write(f"*homepage*: <{processed[letter][software][0]['homepage']}>\n\n")
Expand All @@ -45,6 +75,8 @@ def output_markdown(processed, output_base_path):
software_page.write(" | ")
software_page.write(f"``{version['toolchain']}``\n")

software_page.write('\n')
software_page.write(generate_character_links_line([v for v in processed]))
software_page.close()

letter_page.close()
Expand Down

0 comments on commit 93aa583

Please sign in to comment.