Skip to content

pluginconfig

Class info

Classes

Name Children Inherits
PluginConfig
mkdocs_mknodes.plugin.pluginconfig

    🛈 DocStrings

    The Mkdocs Plugin.

    PluginConfig

    Bases: Config

    Source code in mkdocs_mknodes/plugin/pluginconfig.py
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
     41
     42
     43
     44
     45
     46
     47
     48
     49
     50
     51
     52
     53
     54
     55
     56
     57
     58
     59
     60
     61
     62
     63
     64
     65
     66
     67
     68
     69
     70
     71
     72
     73
     74
     75
     76
     77
     78
     79
     80
     81
     82
     83
     84
     85
     86
     87
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    class PluginConfig(base.Config):
        build_fn = c.Type(str, default="mkdocs_mknodes:parse")
        """Path to the build script / callable.
    
        Possible formats:
    
          - `my.module:Class.build_fn` (must be a classmethod / staticmethod)
          - `my.module:build_fn`
          - `path/to/file.py:build_fn`
    
        Can also be remote.
        The targeted callable gets the project instance as an argument and optionally
        keyword arguments from setting below.
        """
        kwargs = c.Optional(c.Type(dict))
        """Keyword arguments passed to the build script / callable.
    
        Build scripts may have keyword arguments. You can set them by using this setting.
        """
        repo_path = c.Type(str, default=".")
        """Path to the repository to create a website for. (`http://....my_project.git`)"""
        clone_depth = c.Type(int, default=100)
        """Clone depth in case the repository is remote. (Required for `git-changelog`)."""
        build_folder = c.Optional(c.Type(str))
        """Folder to create the Markdown files in.
    
        If no folder is set, **MkNodes** will generate a temporary dir."""
        show_page_info = c.Type(bool, default=False)
        """Append an admonition box with build-related information.
    
        If True, all pages get added an expandable admonition box at the bottom,
        containing information about the created page.
        This includes:
        - Metadata
        - Resources
        - Code which created the page (needs the page to be created via decorators, or
        the `generated_by` attribute of the `MkPage` needs to be set manually)
        """
        rewrite_theme_templates = c.Type(bool, default=True)
        """Add additional functionality to themes by rewriting template files.
    
        MkNodes can rewrite the HTML templates of Themes in order to add additional
        functionality.
    
        Right now, enabling this feature allows these options for the **Material-MkDocs**
        theme:
        - use iconify icons instead of the **Material-MkDocs** icons
        - setting the theme features "navigation.indexes" and "navigation.expand" via
          page metadata.
        """
        auto_delete_generated_templates = c.Type(bool, default=True)
        """Delete the generated HTML templates when build is finished.
    
        MkNodes may generate HTML template overrides during the build process and
        deletes them after build. Using this setting, the deletion can be prevented.
        """
        render_by_default = c.Type(bool, default=True)
        """Render all pages in the jinja environment.
    
        This allows to render jinja in the **MkNodes** environment outside of the `MkJinja`
        nodes.
    
        This setting can be overridden by setting the page metadata field "render_macros".
        """
        global_resources = c.Type(bool, default=True)
        """Make resources globally available.
    
        If True, then the resources inferred from the nodes will be put into all HTML pages.
        (This reflects the "default" MkDocs mechanism of putting extra CSS / JS into the
        config file)
        If False, then MkNodes will put the CSS / JS only into the pages which need it.
        (the resources will be moved into the appropriate page template blocks)
        """
        jinja_loaders = c.Optional(c.ListOfItems(c.Type(dict)))
        """List containing additional jinja loaders to use.
    
        Dictionaries must have the `type` key set to either "filesystem" or "fsspec".
    
        Examples:
            ``` yaml
            plugins:
            - mknodes:
                jinja_loaders:
                - type: fsspec
                  path: github://
                  repo: mknodes
                  org: phil65
            ```
        """
        jinja_extensions = c.Optional(c.ListOfItems(c.Type(str)))
        """List containing additional jinja extensions to use.
    
        Examples:
            ``` yaml
            plugins:
            - mknodes:
                jinja_extensions:
                - jinja2_ansible_filters.AnsibleCoreFiltersExtension
            ```
        """
        jinja_block_start_string = c.Optional(c.Type(str))
        """Jinja block start string."""
        jinja_block_end_string = c.Optional(c.Type(str))
        """Jinja block end string."""
        jinja_variable_start_string = c.Optional(c.Type(str))
        """Jinja variable start string."""
        jinja_variable_end_string = c.Optional(c.Type(str))
        """Jinja variable end string."""
        jinja_on_undefined = c.Type(str, default="strict")
        """Jinja undefined macro behavior."""
        llm_base_url = c.Type(str, default="http://localhost:11434")
        """Base URL for LLM usage."""
        llm_token = c.Optional(c.Type(str))
        """(Optional) token for the LLM API."""
        llm_model_name = c.Optional(c.Type(str))
        """LLM model name to use."""
    
        def get_builder(self) -> Callable[..., Any]:
            build_fn = classhelpers.to_callable(self.build_fn)
            build_kwargs = self.kwargs or {}
            return functools.partial(build_fn, **build_kwargs)
    
        def get_jinja_config(self) -> jinjarope.EnvConfig:
            return jinjarope.EnvConfig(
                block_start_string=self.jinja_block_start_string or "{%",
                block_end_string=self.jinja_block_end_string or "%}",
                variable_start_string=self.jinja_variable_start_string or r"{{",
                variable_end_string=self.jinja_variable_end_string or r"}}",
                # undefined=self.jinja_on_undefined,
                loader=jinjarope.loaders.from_json(self.jinja_loaders),
            )
    

    auto_delete_generated_templates class-attribute instance-attribute

    auto_delete_generated_templates = Type(bool, default=True)
    

    Delete the generated HTML templates when build is finished.

    MkNodes may generate HTML template overrides during the build process and deletes them after build. Using this setting, the deletion can be prevented.

    build_fn class-attribute instance-attribute

    build_fn = Type(str, default='mkdocs_mknodes:parse')
    

    Path to the build script / callable.

    Possible formats:

    • my.module:Class.build_fn (must be a classmethod / staticmethod)
    • my.module:build_fn
    • path/to/file.py:build_fn

    Can also be remote. The targeted callable gets the project instance as an argument and optionally keyword arguments from setting below.

    build_folder class-attribute instance-attribute

    build_folder = Optional(Type(str))
    

    Folder to create the Markdown files in.

    If no folder is set, MkNodes will generate a temporary dir.

    clone_depth class-attribute instance-attribute

    clone_depth = Type(int, default=100)
    

    Clone depth in case the repository is remote. (Required for git-changelog).

    global_resources class-attribute instance-attribute

    global_resources = Type(bool, default=True)
    

    Make resources globally available.

    If True, then the resources inferred from the nodes will be put into all HTML pages. (This reflects the "default" MkDocs mechanism of putting extra CSS / JS into the config file) If False, then MkNodes will put the CSS / JS only into the pages which need it. (the resources will be moved into the appropriate page template blocks)

    jinja_block_end_string class-attribute instance-attribute

    jinja_block_end_string = Optional(Type(str))
    

    Jinja block end string.

    jinja_block_start_string class-attribute instance-attribute

    jinja_block_start_string = Optional(Type(str))
    

    Jinja block start string.

    jinja_extensions class-attribute instance-attribute

    jinja_extensions = Optional(ListOfItems(Type(str)))
    

    List containing additional jinja extensions to use.

    Examples:

    plugins:
    - mknodes:
        jinja_extensions:
        - jinja2_ansible_filters.AnsibleCoreFiltersExtension
    

    jinja_loaders class-attribute instance-attribute

    jinja_loaders = Optional(ListOfItems(Type(dict)))
    

    List containing additional jinja loaders to use.

    Dictionaries must have the type key set to either "filesystem" or "fsspec".

    Examples:

    plugins:
    - mknodes:
        jinja_loaders:
        - type: fsspec
          path: github://
          repo: mknodes
          org: phil65
    

    jinja_on_undefined class-attribute instance-attribute

    jinja_on_undefined = Type(str, default='strict')
    

    Jinja undefined macro behavior.

    jinja_variable_end_string class-attribute instance-attribute

    jinja_variable_end_string = Optional(Type(str))
    

    Jinja variable end string.

    jinja_variable_start_string class-attribute instance-attribute

    jinja_variable_start_string = Optional(Type(str))
    

    Jinja variable start string.

    kwargs class-attribute instance-attribute

    kwargs = Optional(Type(dict))
    

    Keyword arguments passed to the build script / callable.

    Build scripts may have keyword arguments. You can set them by using this setting.

    llm_base_url class-attribute instance-attribute

    llm_base_url = Type(str, default='http://localhost:11434')
    

    Base URL for LLM usage.

    llm_model_name class-attribute instance-attribute

    llm_model_name = Optional(Type(str))
    

    LLM model name to use.

    llm_token class-attribute instance-attribute

    llm_token = Optional(Type(str))
    

    (Optional) token for the LLM API.

    render_by_default class-attribute instance-attribute

    render_by_default = Type(bool, default=True)
    

    Render all pages in the jinja environment.

    This allows to render jinja in the MkNodes environment outside of the MkJinja nodes.

    This setting can be overridden by setting the page metadata field "render_macros".

    repo_path class-attribute instance-attribute

    repo_path = Type(str, default='.')
    

    Path to the repository to create a website for. (http://....my_project.git)

    rewrite_theme_templates class-attribute instance-attribute

    rewrite_theme_templates = Type(bool, default=True)
    

    Add additional functionality to themes by rewriting template files.

    MkNodes can rewrite the HTML templates of Themes in order to add additional functionality.

    Right now, enabling this feature allows these options for the Material-MkDocs theme: - use iconify icons instead of the Material-MkDocs icons - setting the theme features "navigation.indexes" and "navigation.expand" via page metadata.

    show_page_info class-attribute instance-attribute

    show_page_info = Type(bool, default=False)
    

    Append an admonition box with build-related information.

    If True, all pages get added an expandable admonition box at the bottom, containing information about the created page. This includes: - Metadata - Resources - Code which created the page (needs the page to be created via decorators, or the generated_by attribute of the MkPage needs to be set manually)