2022-06-15 15:35:29 -05:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2022-06-16 13:28:45 -05:00
|
|
|
import inspect
|
2022-06-15 15:35:29 -05:00
|
|
|
from importlib.metadata import version
|
|
|
|
|
|
|
|
from rich._export_format import CONSOLE_SVG_FORMAT as DEFAULT
|
2022-06-16 13:28:45 -05:00
|
|
|
from rich.console import Console as RichConsole
|
2022-06-15 15:35:29 -05:00
|
|
|
|
|
|
|
from yartsu._export_format import CONSOLE_SVG_FORMAT as MODIFIED
|
2022-06-16 13:28:45 -05:00
|
|
|
from yartsu.console import Console as YartsuConsole
|
2022-06-15 15:35:29 -05:00
|
|
|
|
|
|
|
MARKDOWN_DOC = """
|
|
|
|
# Deviation From Rich
|
|
|
|
|
|
|
|
## Versions
|
|
|
|
|
|
|
|
- Rich: {rich_version}
|
|
|
|
- Yartsu: {yartsu_version}
|
|
|
|
|
2022-06-16 13:28:45 -05:00
|
|
|
## CONSOLE_SVG_FORMAT Diff
|
2022-06-15 15:35:29 -05:00
|
|
|
|
|
|
|
```diff
|
2022-06-16 13:28:45 -05:00
|
|
|
{export_format_diff}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Console.export_svg Diff
|
|
|
|
|
|
|
|
```diff
|
|
|
|
{export_svg_diff}
|
2022-06-15 15:35:29 -05:00
|
|
|
```
|
|
|
|
|
2023-05-14 13:58:06 -05:00
|
|
|
AUTO-GENERATED by scripts/rich-diff"""
|
2022-06-15 15:35:29 -05:00
|
|
|
|
|
|
|
|
|
|
|
def unidiff_output(expected, actual):
|
|
|
|
"""
|
|
|
|
Helper function. Returns a string containing the unified diff of two multiline strings.
|
|
|
|
"""
|
|
|
|
# see https://stackoverflow.com/questions/845276/how-to-print-the-comparison-of-two-multiline-strings-in-unified-diff-format
|
|
|
|
|
|
|
|
import difflib
|
|
|
|
|
|
|
|
expected = expected.splitlines(1)
|
|
|
|
actual = actual.splitlines(1)
|
|
|
|
|
|
|
|
diff = difflib.unified_diff(expected, actual)
|
|
|
|
|
|
|
|
return "".join(diff)
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
print(
|
|
|
|
MARKDOWN_DOC.format(
|
|
|
|
rich_version=version("rich"),
|
|
|
|
yartsu_version=version("yartsu"),
|
2022-06-16 13:28:45 -05:00
|
|
|
export_format_diff=unidiff_output(DEFAULT, MODIFIED),
|
|
|
|
export_svg_diff=unidiff_output(
|
|
|
|
inspect.getsource(RichConsole.export_svg),
|
|
|
|
inspect.getsource(YartsuConsole.export_svg),
|
|
|
|
),
|
|
|
|
),
|
2022-06-15 15:35:29 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|