Repository navigation
Mike patch #75
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
Mike patch #75
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,6 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| from pathlib import Path | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| from invoke.collection import Collection | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| from invoke.tasks import task | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| from compas_invocations2 import build | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| from compas_invocations2 import style | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| from compas_invocations2 import tests | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -10,6 +10,68 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||
| from compas_pb.invocations import proto_docs | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _patch_versions_info(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| def _patch_versions_info(): | |
| def _patch_versions_info(): | |
| """Monkey-patch ``mike.versions.VersionInfo`` to preserve unknown JSON fields. | |
| This project stores additional metadata in ``versions.json`` which is not | |
| supported by mike's built-in :class:`~mike.versions.VersionInfo` model. | |
| By default, mike discards unknown fields on load and rewrites the file | |
| on dump, which would remove this extra metadata and break the version | |
| selector of existing Sphinx sites that rely on it. | |
| This helper replaces :meth:`VersionInfo.from_json` and | |
| :meth:`VersionInfo.to_json` at runtime so that: | |
| * unknown keys encountered during ``from_json`` are stored on the instance | |
| (via ``external_attrs``), and | |
| * those keys are merged back into the output of ``to_json``. | |
| Notes | |
| ----- | |
| This is a process-wide monkey-patch: once applied, all subsequent uses of | |
| :class:`mike.versions.VersionInfo` in the current process will use the | |
| patched serialization methods. Call this function before invoking any | |
| mike commands that load or write ``versions.json`` (for example, | |
| inside the ``mike_deploy`` task). | |
| """ |
Copilot
AI
Dec 17, 2025
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.
Typo in comment: "everytime" should be "every time" (two words).
| # VersionInfo class. Unfortunately mike overwrites the entire content everytime which breaks the version selector of the old Sphinx sites. | |
| # VersionInfo class. Unfortunately mike overwrites the entire content every time which breaks the version selector of the old Sphinx sites. |
Copilot
AI
Dec 17, 2025
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 monkey-patch modifies the VersionInfo class globally for the entire process. If this function is called multiple times, the patching will occur multiple times, which is redundant but should not cause issues. However, consider adding a guard to prevent redundant patching, or document that this is intentional behavior. This would make the code more defensive and clearer about its intent.
Copilot
AI
Dec 17, 2025
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 mike_deploy task lacks a docstring describing its purpose, parameters, and usage. According to the coding guidelines, public API functions and classes should have numpy style docstrings. While this is an invoke task and not strictly a public API function, it's part of the public interface exposed to developers. Adding a docstring would improve usability, especially since this task performs a non-trivial operation (monkey-patching).
Copilot
AI
Dec 17, 2025
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 driver.deploy(None, args) call passes None as the first argument. This should be verified to ensure it's the correct usage of the mike driver API. If None represents a missing configuration or context, it might be worth adding a comment explaining why this is acceptable or if there's a better value to pass.
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 workflow passes
--push-to-origin trueas a string, but the mike_deploy function expectspush_to_originto be a bool. Invoke will interpret the string "true" as a truthy value and convert it to boolean True, so this should work. However, for clarity and explicitness, consider passing it without the value (as a flag) like--push-to-originsince the parameter defaults to False. Alternatively, if you want to be explicit, the current approach works but relies on invoke's automatic type conversion.