-
-
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
Build: remove append_conf
_magic_ from MkDocs
#11206
Conversation
Delete all the magic around MkDocs YAML that processes the `mkdocs.yml`. file and define `readthedocs` theme automatically based on a feature flag, `MKDOCS_THEME_RTD`. This PR removes: - automatically defining `readthedocs` as theme when `MKDOCS_THEME_RTD` feature flag is defined. - processing `mkdocs.yml` to add internal JS and CSS (embed and analytics) files automatically This is another step forward on removing all the magic we perform on behalf the users and being more explicit about how to configure each doctool. Reference: * readthedocs/addons#72 (comment) Closes #8529
Listen to `Project.post_save` signal and enable Addons if the project was created after a specific date, it's MkDocs and it's the first time the `AddonsConfig` is created.
Co-authored-by: Santos Gallegos <[email protected]>
readthedocs/projects/signals.py
Outdated
if ( | ||
project.pub_date | ||
> datetime.datetime(2023, 4, 1, 0, 0, 0, tzinfo=datetime.timezone.utc) | ||
and instance.documentation_type == MKDOCS | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this logic always run? We are removing the old injection logic completely in this PR, if an old project is build, they won't have the old injections nor the new addons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have only a few projects on commercial using this feature only, and we plan to contact them telling how to migrate their configuration. Basically, they just need to define theme.name: readthedocs
in their mkdocs.yml
file.
I used this date here as an example, but we should give them more time than 20 days 😄 to migrate. We will contact them via email and write a blog post about this as well before merging this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I re-read your comment and I think you are right 👍🏼 . I updated this code to remove the datetime limitation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a solid change, and a big step forward for Addons & our new build approach ❤️ Not 👍'ing yet until we make a full plan for rolling it out to unblock it.
Blog post announcing the depreaction of the `mkdocs.yml` manipulation done by Read the Docs at build time, following the plan described. Related: * readthedocs/addons#72 (comment) * readthedocs/readthedocs.org#11206 * readthedocs/readthedocs.org#8529
* Post: MkDocs YAML manipulation Blog post announcing the depreaction of the `mkdocs.yml` manipulation done by Read the Docs at build time, following the plan described. Related: * readthedocs/addons#72 (comment) * readthedocs/readthedocs.org#11206 * readthedocs/readthedocs.org#8529 * Use double quotes The other ones don't render properly. * Apply suggestions from code review Co-authored-by: Eric Holscher <[email protected]> --------- Co-authored-by: Eric Holscher <[email protected]>
Merge this PR on April 15th and deploy it after it. |
This PR was reviewed but it doesn't have an approval yet. I re-checked the changes and it seems it's fine to be merged and deploy. Please, take a final look at it today since we need to merge and deploy it today/tomorrow as we published in our blog. |
@@ -389,8 +178,3 @@ def yaml_load_safely(content): | |||
information loss. | |||
""" | |||
return yaml.load(content, Loader=SafeLoader) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove all code related to SafeLoader
and just call safe_load now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't yet because it's used to get the final doctype for the version at
readthedocs.org/readthedocs/doc_builder/backends/mkdocs.py
Lines 66 to 68 in 8440aab
config = yaml_load_safely(fh) | |
use_directory_urls = config.get("use_directory_urls", True) | |
return MKDOCS if use_directory_urls else MKDOCS_HTML |
This code will be eventually removed since the doctype doesn't have too much sense anymore now that we support many doctools more. We should probably need to have a conversation about how to delete doctypes completely in a safe way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, but don't think you need the custom loader to just read that setting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrm, but without the safeloader we will executing !!python
syntax, which is why we added it, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No if you call safe_load()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The custom loader was added to don't set those values to None
after reading them (we were using safe_load
previously).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool. Good point! I will delete this chunk of code then 👍🏼
yaml_dump_safely, | ||
yaml_load_safely, | ||
) | ||
from readthedocs.doc_builder.backends.mkdocs import ProxyPythonName, yaml_load_safely |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
readthedocs/config/tests/test_yaml_loader.py
Delete all the magic around MkDocs YAML that processes the
mkdocs.yml
file and definereadthedocs
theme automatically based on a feature flag,MKDOCS_THEME_RTD
.This PR removes:
readthedocs
as theme whenMKDOCS_THEME_RTD
feature flag is defined.mkdocs.yml
to add internal JS and CSS (embed and analytics) files automaticallyThis is another step forward on removing all the magic we perform on behalf the users and being more explicit about how to configure each doctool.
Reference:
Closes #8529