From 1ce7f935ed0d996f00e5ad8b676a35201845ff14 Mon Sep 17 00:00:00 2001 From: Philipp Temminghoff Date: Fri, 15 Sep 2023 13:54:14 +0200 Subject: [PATCH] chore: some tweaks --- mknodes/manual/internals_section.py | 40 ++++++++++++++--------------- mknodes/navs/mkdefaultwebsite.py | 2 +- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/mknodes/manual/internals_section.py b/mknodes/manual/internals_section.py index 6ba65326..c59cbddd 100644 --- a/mknodes/manual/internals_section.py +++ b/mknodes/manual/internals_section.py @@ -1,6 +1,6 @@ import inspect -import mknodes +import mknodes as mk from mknodes.utils import classhelpers @@ -10,41 +10,39 @@ SECTION_CODE = "Code for this section" -nav = mknodes.MkNav("Internals") +nav = mk.MkNav("Internals") -def create_internals_section(root_nav: mknodes.MkNav): +def create_internals_section(root_nav: mk.MkNav): """Create the "Internals" Sub-MkNav and attach it to given MkNav.""" root_nav += nav page = nav.add_index_page(hide_toc=True, icon="magnify") - page += mknodes.MkCode.for_object(create_internals_section, header=SECTION_CODE) - page += mknodes.MkAdmonition(INTRO_TEXT) + page += mk.MkCode.for_object(create_internals_section, header=SECTION_CODE) + page += mk.MkAdmonition(INTRO_TEXT) -# @nav.route("Tree") -# def create_tree_page(): -# """Create the "Tree" MkPage and attach it to given MkNav.""" -# page = mknodes.MkPage("Tree", hide_toc=True, icon="graph") -# page += mknodes.MkHeader("This is the tree we built up to now.", level=3) -# tree = nav.root.get_tree_repr(detailed=False) -# page += mknodes.MkCode(tree) -# return page +@nav.route.page("Tree", show_source=True, hide_toc=True, icon="graph") +def create_tree_page(page: mk.MkPage): + """Create the "Tree" MkPage and attach it to given MkNav.""" + page += mk.MkHeader("This is the tree we built up to now.", level=3) + tree = page.root.get_tree_repr(detailed=False) + page += mk.MkCode(tree, language="") @nav.route.page("Requirements", hide_toc=True, icon="puzzle-edit", show_source=True) -def create_requirements_page(page: mknodes.MkPage): +def create_requirements_page(page: mk.MkPage): """Create the "Required extensions" MkPage and attach it to given MkNav.""" - page += mknodes.MkJinjaTemplate("requirements.md") + page += mk.MkJinjaTemplate("requirements.md") @nav.route.page("Build Log", show_source=True, hide_toc=True, icon="puzzle-edit") -def create_log_page(page: mknodes.MkPage): +def create_log_page(page: mk.MkPage): """Create the "Required extensions" MkPage and attach it to given MkNav.""" - page += mknodes.MkText("log() | MkCode", is_jinja_expression=True) + page += mk.MkText("log() | MkCode", is_jinja_expression=True) @nav.route.nav("Complete code", show_source=True) -def create_complete_code_section(nav: mknodes.MkNav): +def create_complete_code_section(nav: mk.MkNav): """Create the "Complete code" sub-MkNav and attach it to given MkNav.""" from mknodes import manual @@ -52,11 +50,11 @@ def create_complete_code_section(nav: mknodes.MkNav): for _module_name, module in inspect.getmembers(manual, inspect.ismodule): filename = module.__name__.split(".")[-1] + ".py" page = nav.add_page(filename, hide_toc=True) - page += mknodes.MkCode.for_object(module, title=filename) + page += mk.MkCode.for_object(module, title=filename) example_page = nav.add_page("create_example_page methods") - for kls in classhelpers.iter_subclasses(mknodes.MkNode): + for kls in classhelpers.iter_subclasses(mk.MkNode): # iter_subclasses just calls __subclasses__ recursively. if "create_example_page" not in kls.__dict__: continue header = kls.__name__ - example_page += mknodes.MkCode.for_object(kls.create_example_page, header=header) + example_page += mk.MkCode.for_object(kls.create_example_page, header=header) diff --git a/mknodes/navs/mkdefaultwebsite.py b/mknodes/navs/mkdefaultwebsite.py index bf9af516..642513fb 100644 --- a/mknodes/navs/mkdefaultwebsite.py +++ b/mknodes/navs/mkdefaultwebsite.py @@ -75,7 +75,7 @@ def add_debug_nav(self): page = internals_nav.add_page("Tree", hide_toc=True, icon="graph") page += mknodes.MkHeader("Node tree.", level=3) text = self.root.get_tree_repr(detailed=False) - page += mknodes.MkCode(text) + page += mknodes.MkCode(text, language="") page = internals_nav.add_page("Requirements", hide_toc=True, icon="puzzle-edit") page += mknodes.MkJinjaTemplate("requirements.md") page = internals_nav.add_page("Build Log", hide_toc=True, icon="puzzle-edit")