-
Notifications
You must be signed in to change notification settings - Fork 18
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
"make format" and credits.md - changes affect mkdocs #31
Comments
Thanks, goes straight to the heart <3 Yeah I'm suffering from the same thing since a few weeks. There's an issue open on blacken-docs to add a way to ignore parts of the markup when formatting, but the maintainer said it's a tough task and they don't have the time to fix it yet. A quick workaround is to use markdown-exec to defer the snippet inclusion: ```python exec="1"
print('--8<-- "whatever"')
``` Not sure that's actually the worakaround, I'm on mobile, let me find the issue later :) |
Thanks for the workaround! That should work for me! I was able to correct by adding the following to the for path in paths:
path = Path(path) # noqa: PLW2901
if path.is_file():
filepaths.add(path.as_posix())
else:
for ext in exts:
filepaths |= {filepath.as_posix() for filepath in path.rglob(f"*.{ext}")}
# Apply exclude
excl_filepaths = filepaths.copy()
for excl in exclude:
reg_obj = excl
for file in excl_filepaths:
if reg_obj.search(file):
filepaths.remove(file) With that [unoptimized] approach to remove the matched entries from the ctx.run(
blacken_docs.run(
*PY_SRC_LIST,
"docs",
exts=["py", "md"],
exclude=["credits.md"],
line_length=120,
),
title="Formatting docs",
nofail=True,
) Reckon something like that might work? |
Thanks, we can indeed consider adding an exclusion parameter to the duty callable 🙂 So here the issue I was speaking of: adamchainz/blacken-docs#193, and the workaround is: ```python exec="1" result="python"
print('--8<-- "docs/examples/model_ext.py"')
``` |
Implemented and works, thanks! |
Spoke too soon. |
Thank you for reporting back, I'll investigate :) |
OK, you're right, it didn't work. Here's one that works (even uglier): ```python exec="yes"
print("""```python exec="1"\n--8<-- "scripts/gen_credits.py"\n```""")
``` |
I opened a PR on blacken-docs and prepared copier-pdm for it, we just have to wait now, closing 🙂 |
Thanks for ugly hack, that's working. Will monitor the upstream repo out of interest. |
Great repo, much less overhead than Hypermodem and cookiecutter.
Getting started with the repo and noticed that if a
make format
is done, it changes thedocs/credits.md
file contents which mkdocs then fails. Incredits.md
there is this (python exec="yes"
on the open fence):which when
make format
is run with blacken-docs changes the format to:with spaces changes.
make check-docs
will then error with:I looked into duty and the lazy callable for
blacken_docs
has an exclude parameter, but it looks like it's never used. I'll continue to pursue there, but has anyone see this error and was able to correct?The text was updated successfully, but these errors were encountered: