-
Notifications
You must be signed in to change notification settings - Fork 51
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve Variables from mkdocstrings #233
Comments
Welcome to this project and thank you!' first issue |
In theory, that might work 🤔 As long, however, as the output of mkdocstrings is inserted into the page before Mkdocs-Macros does its magic. Have you tried? |
I have been messing around with this a bit. Here is some tests I'm playing with: import logging, re
import mkdocs.plugins as plugins
log = logging.getLogger('mkdocs')
def my_filter(value):
return "Hello there"
# this always runs too late, it complains the filter doesn't exist before running this event
# I think mkdocstrings is doing jinja stuff on their own before mkdocs gives the event
def on_env(env, config, files, **kwargs):
log.warning("Hello from one env!")
env.filters['my_filter'] = my_filter
return env
# This actually works for now
def on_page_content(html, page, **kwargs):
return html.replace('{kind}', page.meta.get('kind', 'unknown')) The The So maybe this plugin can run a bit later? What event does this plugin run during? |
Have you tried writing a Mkdocs-Macros module in Python ( 💡 Tip: if all else fails you could use the mkdocs-macros-plugin/mkdocs_macros/plugin.py Lines 495 to 503 in 9a08f11
|
It is not! At least not as mkdocs-macros would expect it. mkdocstrings works during Markdown conversion. MkDocs hooks never get to see the raw contents of docstrings.
Indeed, we use our own env. To enable mkdocs-macros' features inside docstrings you will have to use a hack like this one: mkdocstrings/mkdocstrings#615 (comment) 🙂 |
@pawamoy My bad, I had forgotten about that... 😄 I am still in awe, because you might have a better understanding of Mkdocs-Macros, than I of mkdocstrings. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
I have a variable in the docstrings within code
then in the markdown
Is there a way to render variables that come in the output of other plugins?
The text was updated successfully, but these errors were encountered: