-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed incompatibility with d2 module (#249)
- Added test case
- Loading branch information
Laurent Franceschetti
committed
Oct 18, 2024
1 parent
3a73707
commit 5641806
Showing
8 changed files
with
83 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
""" | ||
This __init__.py file is indispensable for pytest to | ||
recognize its packages. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Home | ||
|
||
This checks the compatibility with the d2 plugin. | ||
|
||
There used to be an issue, see [Github](https://github.com/fralau/mkdocs-macros-plugin/issues/249). | ||
|
||
It was due to the CustomEncoder class (in util module), | ||
which was susceptible to fail if an object was not printable. | ||
|
||
```d2 | ||
A -> B | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
# Documentation name | ||
site_name: 'Compatibility with d2 plugin' | ||
|
||
# Your repository URL and name | ||
repo_url: https://gitlab.com/karreg/mkdocs-macros-d2-issue | ||
repo_name: mkdocs-macros-d2-issue | ||
|
||
# Plugins | ||
plugins: | ||
- search | ||
- d2 | ||
- macros | ||
|
||
# Documentation content | ||
nav: | ||
- Home: 'index.md' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
Testing the d2 project | ||
There was an incompatibility: | ||
Error: The current file is not set for the '!relative' tag. It cannot be used in this context; the intended usage is within `markdown_extensions`. | ||
see https://github.com/fralau/mkdocs-macros-plugin/issues/249 | ||
Requires d2 | ||
(C) Laurent Franceschetti 2024 | ||
""" | ||
|
||
REQUIRED = "d2" | ||
|
||
import pytest | ||
import subprocess | ||
|
||
def is_d2_installed(): | ||
try: | ||
subprocess.run(["brew", "list", REQUIRED], check=True, | ||
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) | ||
return True | ||
except subprocess.CalledProcessError: | ||
return False | ||
|
||
|
||
import test | ||
from test.fixture import MacrosDocProject | ||
|
||
|
||
@pytest.mark.skipif(not is_d2_installed(), reason="d2 is not installed") | ||
def test_d2(): | ||
""" | ||
This test will run only if d2 library is installed; | ||
otherwise the d2 plugin will not run | ||
https://d2lang.com/tour/install/ | ||
""" | ||
project = MacrosDocProject() | ||
project.build(strict=False) | ||
# did not fail | ||
print(project.build_result.stderr) | ||
assert not project.build_result.returncode, "Failed when it should not" |