-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Special !! values are reset to null in mkdocs.yml #7461
Comments
The solution in #6889 (comment) should do the trick. We parse those inside a docker environment, so it should be safe. |
So, we execute that in the builders, but the parsing code is still executed inside the application layer, we are safe to execute commands that we send to docker, not the ones we execute inside the application layer. So, we can't use the normal
|
Here's a way to "fake" load from pathlib import Path
import yaml
class ProxyPythonName(yaml.YAMLObject):
def __init__(self, value):
self.value = value
class CustomLoader(yaml.SafeLoader):
def construct_python_name(self, suffix, node):
return ProxyPythonName(suffix)
class CustomDumper(yaml.SafeDumper):
def represent_name(self, data):
return self.represent_scalar("tag:yaml.org,2002:python/name:" + data.value, "")
CustomLoader.add_multi_constructor("tag:yaml.org,2002:python/name:", CustomLoader.construct_python_name)
CustomDumper.add_representer(ProxyPythonName, CustomDumper.represent_name)
string = Path("mkdocs.yml").read_text()
loaded = yaml.load(string, Loader=CustomLoader)
dumped = yaml.dump(loaded, Dumper=CustomDumper)
print(dumped) Input: markdown_extensions:
- pymdownx.superfences:
custom_fences:
- class: mermaid
format: !!python/name:pymdownx.superfences.fence_div_format
name: mermaid Output: markdown_extensions:
- pymdownx.superfences:
custom_fences:
- class: mermaid
format: !!python/name:pymdownx.superfences.fence_div_format ''
name: mermaid No Python code was imported / executed 🙂 |
Two years later, the problem reappeared again, but this time with |
Shouldn't be too hard to open a new issue asking if maintainers would be OK to support it, and to copy-paste the code of the previous PR adding support for |
@FeeeeK it seems we implemented this only for As a workaround for now, you could use the feature to Override the build process by using Here is an example of how to create the version: 2
build:
os: ubuntu-22.04
tools:
python: "3"
commands:
pip install -r requirements.txt
mkdocs build --site-dir $READTHEDOCS_OUTPUT/html |
Thanks, @humitos, I already did it, but it would be nice if there were any warnings about this, now there is only traceback from toc without any additional info. |
Details
As reported here (the issue is now stale, not sure if you'd prefer the discussion to continue over there), values like
!!python/name:module.name
inmkdocs.yml
are dropped during the build process. They end up beingnull
in the finalmkdocs.yml
, which in turn breaks build in various places (mainly plugins).Expected Result
These values should not be reset to
null
as it breaks the build. More details in the linked issue.Actual Result
Special values starting with
!!python/name:
in mkdocs are reset to null, and it breaks the build.The text was updated successfully, but these errors were encountered: