Populate MkPages from SUMMARY.md

MkNavs can parse index files in SUMMARY.md style (as popularized by mkdocs-literate-nav).

Given the following folder structure:

Directory tree

📂 nav_tree
┣━━ 📂 test_folder
┃   ┣━━ 📝 markdown-exec.md (508 Bytes)
┃   ┗━━ 📝 sub_1.md (287 Bytes)
┣━━ 📂 test_subnav
┃   ┣━━ 📝 subnav_page_1.md (132 Bytes)
┃   ┣━━ 📝 subnav_page_2.md (1.7 kB)
┃   ┗━━ 📝 SUMMARY.md (72 Bytes)
┣━━ 📝 SUMMARY.md (162 Bytes)
┗━━ 📝 test_file.md (55 Bytes)

and a root SUMMARY.md looking like:

Root SUMMARY.md

* Test nested
    * [General] (test_folder/sub_1.md)
    * [Markdown-Exec] (test_folder/markdown-exec.md)
* [Test Subnav] (test_subnav/)
* [Test file] (test_file.md)
Page info
Code for this section
mknodes.manual.navs_section._
@nav.route.nav("Populate MkPages from SUMMARY.md")
def _(nav: mk.MkNav):
    folder = paths.TEST_RESOURCES / "nav_tree/"
    summary_file = folder / "SUMMARY.md"
    nav.parse.file(summary_file, hide="toc")
    page = nav.add_page(is_index=True, hide="toc", icon="file")
    text = summary_file.read_text()
    text = text.replace("](", "] (")  ##  # noqa: E262
    path = paths.TEST_RESOURCES / "nav_tree/"
    variables = dict(path=path, text=text)
    page += mk.MkTemplate("navs/nav_from_file.jinja", variables=variables)
Resources
Resources(css=[],
          markdown_extensions={'admonition': {},
                               'attr_list': {},
                               'md_in_html': {},
                               'pymdownx.details': {},
                               'pymdownx.emoji': {'emoji_generator': <function to_svg at 0x7fd7a6931800>,
                                                  'emoji_index': <function twemoji at 0x7fd7a69316c0>},
                               'pymdownx.highlight': {'anchor_linenums': True,
                                                      'line_spans': '__span',
                                                      'pygments_lang_class': True},
                               'pymdownx.magiclink': {'repo': 'mknodes',
                                                      'repo_url_shorthand': True,
                                                      'user': 'phil65'},
                               'pymdownx.superfences': {}},
          plugins=[],
          js=[],
          assets=[],
          packages=[])
Metadata
created:
  source_filename: /home/runner/work/mknodes/mknodes/mknodes/manual/navs_section.py
  source_function: _
  source_line_no: 25
hide:
- toc
icon: material/file
template: SUMMARY.html
title: Populate MkPages from SUMMARY.md