Skip to content

Commit

Permalink
chore: some tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Sep 15, 2023
1 parent 6cd412b commit 1ce7f93
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
40 changes: 19 additions & 21 deletions mknodes/manual/internals_section.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import inspect

import mknodes
import mknodes as mk

from mknodes.utils import classhelpers

Expand All @@ -10,53 +10,51 @@

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

nav.add_index_page(hide_toc=True, icon="octicons/code-24")
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)
2 changes: 1 addition & 1 deletion mknodes/navs/mkdefaultwebsite.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 1ce7f93

Please sign in to comment.