chore: add comparison to default settings

This commit is contained in:
Daylin Morgan 2022-06-15 15:35:29 -05:00
parent 2ec0537ce3
commit 6c2758ebda
4 changed files with 130 additions and 3 deletions

View file

@ -5,7 +5,7 @@ repos:
rev: v4.1.0 rev: v4.1.0
hooks: hooks:
- id: trailing-whitespace - id: trailing-whitespace
exclude: ".svg$" exclude: "(.*svg$|docs/rich-diff.md)"
- id: end-of-file-fixer - id: end-of-file-fixer
- id: check-added-large-files - id: check-added-large-files
- repo: https://github.com/pycqa/isort - repo: https://github.com/pycqa/isort

View file

@ -1,6 +1,6 @@
SRC_FILES = $(wildcard yartsu/*) SRC_FILES = $(wildcard yartsu/*)
.PHONY: list lint build svg-docs theme-docs docs typing format dist check-tag .PHONY: list lint build typing format dist check-tag
lint: format typing lint: format typing
@ -37,11 +37,16 @@ build/yartsu: $(SRC_FILES)
install-bin: build/yartsu install-bin: build/yartsu
cp ./build/yartsu ~/bin cp ./build/yartsu ~/bin
docs: svg-docs theme-docs demo-docs .PHONY: svg-docs theme-docs diff-docs demo-docs docs
docs: svg-docs theme-docs demo-docs diff-docs
theme-docs: theme-docs:
./scripts/theme-showcase-gen ./scripts/theme-showcase-gen
diff-docs:
./scripts/code_svg_format_diff.py > docs/rich-diff.md
svg-docs: svg-docs:
lolcat -F .5 -S 9 -f assets/logo.txt | yartsu -o assets/logo.svg lolcat -F .5 -S 9 -f assets/logo.txt | yartsu -o assets/logo.svg
yartsu -o assets/yartsu.svg -t "yartsu --help" -- yartsu -h yartsu -o assets/yartsu.svg -t "yartsu --help" -- yartsu -h
@ -53,6 +58,7 @@ demo-docs:
console.print('\n:snake: [b i]Emoji\'s!'); \ console.print('\n:snake: [b i]Emoji\'s!'); \
console.print(' [cyan]Nerd Fonts!');" \ console.print(' [cyan]Nerd Fonts!');" \
| yartsu -w 25 -o assets/demo.svg | yartsu -w 25 -o assets/demo.svg
clean: clean:
rm -rf build dist rm -rf build dist

67
docs/rich-diff.md Normal file
View file

@ -0,0 +1,67 @@
# Deviation From Rich
## Versions
- Rich: 12.4.4
- Yartsu: 22.6b2.dev2+gabdbc1d
## Diff
```diff
---
+++
@@ -1,47 +1,39 @@
<svg class="rich-terminal" viewBox="0 0 {width} {height}" xmlns="http://www.w3.org/2000/svg">
<!-- Generated with Rich https://www.textualize.io -->
<style>
-
@font-face {{
font-family: "Fira Code";
src: local("FiraCode-Regular"),
- url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Regular.woff2") format("woff2"),
- url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Regular.woff") format("woff");
+ url("https://cdn.jsdelivr.net/gh/ryanoasis/nerd-fonts@2.1.0/patched-fonts/FiraCode/Regular/complete/Fira%20Code%20Regular%20Nerd%20Font%20Complete.ttf") format("truetype");
font-style: normal;
font-weight: 400;
}}
@font-face {{
font-family: "Fira Code";
src: local("FiraCode-Bold"),
- url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff2/FiraCode-Bold.woff2") format("woff2"),
- url("https://cdnjs.cloudflare.com/ajax/libs/firacode/6.2.0/woff/FiraCode-Bold.woff") format("woff");
+ url("https://cdn.jsdelivr.net/gh/ryanoasis/nerd-fonts@2.1.0/patched-fonts/FiraCode/Bold/complete/Fira%20Code%20Bold%20Nerd%20Font%20Complete.ttf") format("truetype");
font-style: bold;
font-weight: 700;
}}
-
.{unique_id}-matrix {{
font-family: Fira Code, monospace;
font-size: {char_height}px;
line-height: {line_height}px;
font-variant-east-asian: full-width;
}}
-
.{unique_id}-title {{
font-size: 18px;
font-weight: bold;
font-family: arial;
}}
-
{styles}
</style>
-
<defs>
<clipPath id="{unique_id}-clip-terminal">
<rect x="0" y="0" width="{terminal_width}" height="{terminal_height}" />
</clipPath>
{lines}
</defs>
-
{chrome}
<g transform="translate({terminal_x}, {terminal_y})" clip-path="url(#{unique_id}-clip-terminal)">
{backgrounds}
```
AUTO-GENERATED by code_svg_format_diff.py

54
scripts/code_svg_format_diff.py Executable file
View file

@ -0,0 +1,54 @@
#!/usr/bin/env python3
from importlib.metadata import version
from rich._export_format import CONSOLE_SVG_FORMAT as DEFAULT
from yartsu._export_format import CONSOLE_SVG_FORMAT as MODIFIED
MARKDOWN_DOC = """
# Deviation From Rich
## Versions
- Rich: {rich_version}
- Yartsu: {yartsu_version}
## Diff
```diff
{diff}
```
AUTO-GENERATED by code_svg_format_diff.py"""
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"),
diff=unidiff_output(DEFAULT, MODIFIED),
)
)
if __name__ == "__main__":
main()