MkClassPage

An MkClassPage is an MkPage subclass used to display information about a specific class. It uses a Jinja template to display the class-related information. By default, the Docstrings, tables for sub and parent classes as well as an inheritance graph are shown. The template can be adjusted manually in case a different layout is preferred.

class MkClassPage(mktemplatepage.MkTemplatePage)

Page showing information about a class.

This is an example for an MkClassPage with the default layout:

MkCode

Sub classes

Name

Children

Inherits

MkDiagram
mknodes.basenodes.mkdiagram
Class representing a mermaid diagram.

MkTreeView
mknodes.templatenodes.mktreeview
Node to display tree structures.

    Base classes

    Name

    Children

    Inherits

    MkContainer
    mknodes.basenodes.mkcontainer
    A node containing other MkNodes.

    ⋔ Inheritance diagram

    graph TD
      1761293797["mkcode.MkCode"]
      835538629["mkcontainer.MkContainer"]
      1956333208["mkcontainer.MkContainerBase"]
      1359323199["mknode.MkNode"]
      2751680898["builtins.object"]
      835538629 --> 1761293797
      1956333208 --> 835538629
      1359323199 --> 1956333208
      2751680898 --> 1359323199
    

    🛈 DocStrings

    class MkCode(mkcontainer.MkContainer)
    

    Class representing a Code block.

    fence_boundary

    fence_boundary: str
    

    Return fence boundary, based on nesting level. Default is ```.

    fence_title

    fence_title: str
    

    Title in first line.

    __init__

    def __init__(content: str | mk.MkNode | list[mk.MkNode] = '', *, language: str = 'python', title: str = '', linenums: int | None = None, highlight_lines: list[int] | None = None, fence_level: int | None = None, **kwargs: Any) -> None
    

    Constructor.

    Parameters:

    Name

    Type

    Description

    Default

    content

    str | mk.MkNode | list[mk.MkNode]

    Content to show inside code box

    ‘’

    language

    str

    language for syntax highlighting

    ‘python’

    title

    str

    Code block title

    ‘’

    linenums

    int | None

    If set, use as start linenumber

    None

    highlight_lines

    list[int] | None

    Optionally highlight lines

    None

    fence_level

    int | None

    Determines amount of ticks used for fence.
    If None, auto-determine based on nesting depth.

    None

    kwargs

    Any

    Keyword arguments passed to parent

    {}

    fence_for

    def fence_for(text: str) -> str
    

    Return the fence for given code: longer than any fence inside the code.

    for_file

    def for_file(path: JoinablePathLike, *, linenums: bool = True, highlight_caller: bool = True, title: str | None = None, language: str | None = None, **kwargs: Any) -> Self
    

    Create a MkCode node based on a code file.

    Line numbers will be shown by default. If highlight_caller is True, it will try to detect whether the calling method is inside the code block are creating and if yes, it will highlight that line.

    Parameters:

    Name

    Type

    Description

    Default

    path

    JoinablePathLike

    Path to the code file (also supports fsspec-protocol URLs)

    linenums

    bool

    Whether to show line numbers

    True

    highlight_caller

    bool

    Whether we want to try to highlight the line which called
    this method.

    True

    title

    str | None

    title to use for the code box. If None is set, filename will be used.

    None

    language

    str | None

    Syntax highlighting language. If None, try to infer from extension.

    None

    kwargs

    Any

    Keyword arguments passed to MkCode ctor

    {}

    for_object

    def for_object(obj: datatypes.HasCodeType, *, dedent: bool = True, extract_body: bool = False, title: str | None = None, linenums: bool = True, highlight_caller: bool = True, **kwargs: Any) -> Self
    

    Create a MkCode node based on a python object.

    Fetches code by using the inspect module. Line numbers will be shown by default. If highlight_caller is True, it will try to detect whether the calling method is inside the code block are displaying and if yes, it will highlight that line.

    Parameters:

    Name

    Type

    Description

    Default

    obj

    datatypes.HasCodeType

    Python object to show code from

    dedent

    bool

    Whether to dedent the code

    True

    extract_body

    bool

    if True, Function / Class signatures are stripped from the code

    False

    title

    str | None

    Title to use for code block. If None, it will use the object path.

    None

    linenums

    bool

    Whether to show line numbers

    True

    highlight_caller

    bool

    Whether we want to try to highlight the line which called
    this method.

    True

    kwargs

    Any

    Keyword arguments passed to MkCode ctor

    {}

    get_content

    def get_content() -> resources.NodeContent
    

    Single-pass: get code block markdown and resources.

    get_text

    def get_text() -> str
    

    Text content.

    github Show source on GitHub