Trying to test a plugin I'm developing locally but can't get it recognized #3457
-
I've got a plugin that I'm trying to debug. $ find . -type f | grep -v '.git'
./LICENSE
./pyproject.toml
./README.md
./mkdocs_inline_select_svg_plugin/__init__.py
./mkdocs_inline_select_svg_plugin/__pycache__/plugin.cpython-311.pyc
./mkdocs_inline_select_svg_plugin/__pycache__/__init__.cpython-311.pyc
./mkdocs_inline_select_svg_plugin/plugin.py The pyproject.toml looks like [build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "mkdocs-inline-select-svg-plugin"
description = "A MkDocs plugin that inlines SVG images matching a pattern into the output without inlining Materials theme icons."
readme = "README.md"
license = "Apache-2.0"
keywords = ["mkdocs", "mkdocs-plugin", "plugin", "svg"]
authors = [
{ name = "Mike Samuel", email = "mikesamuel@gmail.com" },
]
version = "0.1.0"
requires-python = ">=3.8"
dependencies = [
"mkdocs >=1.4.0",
"beautifulsoup4 >=4.12.0",
]
[project.urls]
Source = "https://github.com/temperlang/svg-inline-mkdocs-plugin"
[project.entry-points."mkdocs.plugins"]
inline-select-svg = "mkdocs_inline_select_svg_plugin.plugin:MkdocsInlineSelectSvgPlugin" And that plugin.py exports MkdocsInlineSelectSvgPlugin thus: import re
import os
import mkdocs
import mkdocs.config
import mkdocs.config.config_options
import urllib
from bs4 import BeautifulSoup
from urllib.parse import urlparse
class MkdocsInlineSelectSvgConfig(mkdocs.config.base.Config):
"""
...
"""
pattern = mkdocs.config.config_options.Type(str, default='[.]inline[.]svg$')
class MkdocsInlineSelectSvgPlugin(mkdocs.plugins.BasePlugin[MkdocsInlineSelectSvgConfig]):
"""
...
"""
def on_config(self, config: MkdocsInlineSelectSvgConfig):
...
return config
def on_page_content(self, html, page, config, files, **kwargs):
..... I do Then I'm testing it with an existing mkdocs setup. poetry run python
Python 3.11.6 (main, Nov 2 2023, 04:52:24) [Clang 14.0.3 (clang-1403.0.22.14.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import mkdocs_inline_select_svg_plugin.plugin
>>> p = mkdocs_inline_select_svg_plugin.plugin.MkdocsInlineSelectSvgPlugin()
>>> p.on_config(mkdocs_inline_select_svg_plugin.plugin.MkdocsInlineSelectSvgConfig())
{'pattern': '[.]inline[.]svg$'}
>>> p.pattern
re.compile('[.]inline[.]svg$') Then I have a mkdocs.yml including plugins:
- search
- inline-select-svg:
pattern: "[.]inline[.]svg$" But when I try to run mkdocs it fails. $ poetry run mkdocs build
INFO - DeprecationWarning: 'materialx.emoji.twemoji' is deprecated.
Material emoji logic has been officially moved into mkdocs-material
version 9.4. Please use Material's 'material.extensions.emoji.twemoji'
as mkdocs_material_extensions is deprecated and will no longer be
supported moving forward. This is the last release.
File
"/Users/mikesamuel/Library/Caches/pypoetry/virtualenvs/temper-docs-9BZ3Pax0-py3.11/lib/python3.11/site-packages/materialx/emoji.py",
line 106, in twemoji
return _patch_index(options)
File
"/Users/mikesamuel/Library/Caches/pypoetry/virtualenvs/temper-docs-9BZ3Pax0-py3.11/lib/python3.11/site-packages/materialx/emoji.py",
line 59, in _deprecated_func
warnings.warn(
WARNING - Material emoji logic has been officially moved into mkdocs-material
version 9.4. Please use Material's 'material.extensions.emoji.twemoji'
as mkdocs_material_extensions is deprecated and will no longer be
supported moving forward. This is the last release.
ERROR - Config value 'plugins': The "inline-select-svg" plugin is not installed
Aborted with 1 configuration errors! Any thoughts? I'm not an expert on Python config, so I don't know exactly how the entry points stuff is supposed to connect things. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Poetry is a separate installation environment, right? it'd need to be |
Beta Was this translation helpful? Give feedback.
Poetry is a separate installation environment, right?
it'd need to be
pip install .
+mkdocs build
or
poetry run pip install .
+poetry run mkdocs build