Skip to content

BuildContext

Base classes

Name Children Inherits
Context
mknodes.info.contexts
Base class for contexts.

β‹” Inheritance diagram

graph TD
  101238812541536["buildcontext.BuildContext"]
  101238801037920["contexts.Context"]
  135868862966272["builtins.object"]
  101238801037920 --> 101238812541536
  135868862966272 --> 101238801037920

πŸ›ˆ DocStrings

Bases: Context

Information about a website build.

Parameters:

Name Type Description Default
page_mapping dict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

<class 'dict'>
resources Resources

A resource bundle containing different assets.

Most of the time this class is used for bundling required resources for a specific node.

<dynamic>
build_files dict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2)

<class 'dict'>
node_counter Counter

Dict subclass for counting hashable items. Sometimes called a bag or multiset. Elements are stored as dictionary keys and their counts are stored as dictionary values.

When constructed from a Mapping or Counter, the original object's values will be used as the initial counts.

c = Counter('abcdeabcdabcaba') # count elements from a string

c.most_common(3) # three most common elements [('a', 5), ('b', 4), ('c', 3)] sorted(c) # list all unique elements ['a', 'b', 'c', 'd', 'e'] ''.join(sorted(c.elements())) # list elements with repetitions 'aaaaabbbbcccdde' sum(c.values()) # total of all counts 15

c['a'] # count of letter 'a' 5 for elem in 'shazam': # update counts from an iterable ... c[elem] += 1 # by adding 1 to each element's count c['a'] # now there are seven 'a' 7 del c['b'] # remove all 'b' c['b'] # now there are zero 'b' 0

d = Counter('simsalabim') # make another counter c.update(d) # add in the second counter c['a'] # now there are nine 'a' 9

c.clear() # empty the counter c Counter()

Note: If a count is set to zero or reduced to zero, it will remain in the counter until the entry is deleted or the counter is cleared:

c = Counter('aaabbc') c['b'] -= 2 # reduce the count of 'b' by two c.most_common() # 'b' is still in, but its count is zero [('a', 3), ('c', 1), ('b', 0)]

<dynamic>
templates list[PageTemplate]

Built-in mutable sequence.

If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified.

<dynamic>
Source code in mkdocs_mknodes/buildcontext.py
@dataclasses.dataclass
class BuildContext(contexts.Context):
    """Information about a website build."""

    page_mapping: dict = dataclasses.field(default_factory=dict)
    """A dictionary mapping all page filenames to the corresponding MkPages."""
    resources: resources.Resources = dataclasses.field(
        default_factory=resources.Resources,
    )
    """All resources (JS, CSS, extensions) inferred from the build."""
    # node_stats: list[contexts.NodeBuildStats] = dataclasses.field(default_factory=list)
    """Some stats about nodes construction."""
    build_files: dict = dataclasses.field(default_factory=dict)
    """A mapping of filepaths -> Markdown."""
    node_counter: collections.Counter = dataclasses.field(
        default_factory=collections.Counter,
    )
    """Counter containing the amount of creations for each node class."""
    templates: list[mk.PageTemplate] = dataclasses.field(default_factory=list)
    """A list of required templates."""

build_files class-attribute instance-attribute

build_files: dict = dataclasses.field(default_factory=dict)

A mapping of filepaths -> Markdown.

node_counter class-attribute instance-attribute

node_counter: Counter = dataclasses.field(default_factory=collections.Counter)

Counter containing the amount of creations for each node class.

page_mapping class-attribute instance-attribute

page_mapping: dict = dataclasses.field(default_factory=dict)

A dictionary mapping all page filenames to the corresponding MkPages.

resources class-attribute instance-attribute

resources: Resources = dataclasses.field(default_factory=resources.Resources)

All resources (JS, CSS, extensions) inferred from the build.

templates class-attribute instance-attribute

templates: list[PageTemplate] = dataclasses.field(default_factory=list)

A list of required templates.

:fa-brands-github: Show source on GitHub

Page info
Resources
Resources(css=[],
          markdown_extensions={'pymdownx.superfences': {'custom_fences': [{'class': 'mermaid',
                                                                           'format': <function fence_code_format at 0x7b9269a4ea20>,
                                                                           'name': 'mermaid'}]},
                               'tables': {}},
          plugins=[Plugin('mkdocstrings')],
          js=[],
          assets=[],
          packages=[])
Metadata
created:
  source_filename: /home/runner/work/mkdocs-mknodes/mkdocs-mknodes/.venv/lib/python3.13/site-packages/mknodes/pages/mkclasspage/__init__.py
  source_function: MkClassPage.__init__
  source_line_no: 46
title: BuildContext