mirror of
https://github.com/daylinmorgan/yartsu.git
synced 2024-11-15 02:07:53 -06:00
1 line
No EOL
7.5 KiB
JSON
1 line
No EOL
7.5 KiB
JSON
{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Yartsu","text":"<p> yartsu, another rich terminal screenshot utility </p> <p> Documentation </p> <p></p> <p> </p> <p>NOTE: this is a currently in a beta release and the API is subject to change (feedback welcome)</p> <p>Inspired by recent commits in the wonderful library <code>rich</code> I decided to write <code>yartsu</code>.</p> <p>I needed to programmatically generate screenshots for documentation purposes. The new <code>export_svg</code> methods in <code>rich</code> were a godsend. So I wanted to try to make this feature a little more generalizable to program output outside of <code>rich</code>/<code>python</code>. Hopefully, you find it useful.</p> <p>If you come across anything unexpected please submit an issue.</p>"},{"location":"#install","title":"Install","text":"<pre><code>pipx install yartsu\n# OR\npip install yartsu\n</code></pre>"},{"location":"#releases","title":"Releases","text":"<p>There is a standalone binary available for linux in the releases (Support for additional platforms is planned).</p> <p>Optionally install with <code>eget</code>:</p> <pre><code>eget daylinmorgan/yartsu\n</code></pre> <p>Otherwise you can download an extract manually to somewhere on your path.</p>"},{"location":"#usage","title":"Usage","text":"<p>Getting a properly formatted output from a terminal screenshot is challenging.</p> <p>There are three options for generating a screenshot.</p> <p>If one of the below option causes you any headaches consider first trying a different option.</p>"},{"location":"#option-1-pipes","title":"Option 1: Pipes","text":"<p>Many tools that color output (i.e. <code>grep</code> or <code>ls</code>) additionally allow you to force ANSI color codes to be included even when piping output.</p> <p>In these cases you can simply pipe the output directly into <code>yartsu</code></p> <pre><code>ls --color=always | yartsu -w 50 -o assets/ls_color.svg\n</code></pre>"},{"location":"#option-2-subprocesspty","title":"Option 2: Subprocess/Pty","text":"<p>With this option <code>yartsu</code> will deploy a <code>subprocess</code> and <code>pty</code> to run your command for you in an attempt to preserve ANSI.</p> <p>Note with this option you need to separate the command you want to run with <code>yartsu</code> args using <code>--</code>.</p> <pre><code>yartsu -w 50 -o assets/ls_color.svg -- ls --color /\n</code></pre>"},{"location":"#option-3-text-file","title":"Option 3: Text File","text":"<p>Finally, if you neither of the above options work and you can manage to preserve the codes in a plain text file you can pass this as input to <code>yartsu</code>.</p> <pre><code>ls --color > ls.txt\nyartsu -w 50 -i ls.txt -o assets/ls_color.svg\n</code></pre> <p>By default svgs will be saved at <code>./capture.svg</code>.</p> <p>Additionally, for options 1 and 3 you may want to define your own title with <code>-t/--title</code>. For option 2 the title will by default be the cmd ran by <code>yartsu</code>.</p>"},{"location":"#themes","title":"Themes","text":"<p>There are a number of themes you can use to style output. Use <code>yartsu --list-themes</code> to see the available options. Then you can specify the theme you want with <code>--theme</code>, i.e. <code>yartsu --theme rich_default</code>. You may also use the environment variable <code>YARTSU_THEME</code>.</p> <p>See here a preview of the available themes</p>"},{"location":"#differences-from-rich","title":"Differences from <code>Rich</code>","text":"<p>For both practical and stylistic reasons the underlying code used to generate the SVG is slightly different than <code>rich</code>'s default <code>save_svg</code> method. See here for the current deviation between the latest releases of each respective release.</p>"},{"location":"rich-diff/","title":"Deviation From Rich","text":""},{"location":"rich-diff/#versions","title":"Versions","text":"<ul> <li>Rich: 13.3.5</li> <li>Yartsu: 23.5.1b2.dev25+ga14608d</li> </ul>"},{"location":"rich-diff/#console_svg_format-diff","title":"CONSOLE_SVG_FORMAT Diff","text":"<pre><code>--- \n+++ \n@@ -1,5 +1,5 @@\n-<svg class=\"rich-terminal\" viewBox=\"0 0 {width} {height}\" xmlns=\"http://www.w3.org/2000/svg\">\n- <!-- Generated with Rich https://www.textualize.io -->\n+<svg class=\"rich-terminal shadow\" viewBox=\"0 0 {width} {height}\" xmlns=\"http://www.w3.org/2000/svg\">\n+ <!-- Generated with Rich https://www.textualize.io & yartsu https://github.com/daylinmorgan/yartsu -->\n <style>\n\n @font-face {{\n@@ -32,6 +32,10 @@\n font-family: arial;\n }}\n\n+ .shadow {{\n+ -webkit-filter: drop-shadow( 2px 5px 2px rgba(0, 0, 0, .7));\n+ filter: drop-shadow( 2px 5px 2px rgba(0, 0, 0, .7));\n+ }}\n {styles}\n </style>\n\n@@ -43,7 +47,7 @@\n </defs>\n\n {chrome}\n- <g transform=\"translate({terminal_x}, {terminal_y})\" clip-path=\"url(#{unique_id}-clip-terminal)\">\n+ <g transform=\"translate({terminal_x}, {terminal_y}) scale(.95)\" clip-path=\"url(#{unique_id}-clip-terminal)\">\n {backgrounds}\n <g class=\"{unique_id}-matrix\">\n {matrix}\n</code></pre>"},{"location":"rich-diff/#consoleexport_svg-diff","title":"Console.export_svg Diff","text":"<pre><code>--- \n+++ \n@@ -70,9 +70,9 @@\n line_height = char_height * 1.22\n\n margin_top = 1\n- margin_right = 1\n- margin_bottom = 1\n- margin_left = 1\n+ margin_right = char_width * 5 / 6\n+ margin_bottom = 20 * 5 / 3\n+ margin_left = char_width * 5 / 6\n padding_top = 40\n padding_right = 8\n@@ -222,8 +222,8 @@\n x=terminal_width // 2,\n y=margin_top + char_height + 6,\n )\n- chrome += f\"\"\"\n- <g transform=\"translate(26,22)\">\n+ chrome += \"\"\"\n+ <g transform=\"translate(32,22)\">\n <circle cx=\"0\" cy=\"0\" r=\"7\" fill=\"#ff5f57\"/>\n <circle cx=\"22\" cy=\"0\" r=\"7\" fill=\"#febc2e\"/>\n <circle cx=\"44\" cy=\"0\" r=\"7\" fill=\"#28c840\"/>\n</code></pre> <p>AUTO-GENERATED by scripts/rich-diff</p>"},{"location":"themes/","title":"Themes","text":""},{"location":"themes/#themes","title":"Themes","text":"<p>Available themes:</p> <ul> <li>cat-mocha</li> <li>cat-macchiato</li> <li>cat-frappe</li> <li>cat-latte</li> <li>dracula</li> <li>gruvbox-dark</li> <li>gruvbox-light</li> <li>nord</li> <li>dimmed_monokai</li> <li>monokai</li> <li>night-owlish</li> <li>rich-default</li> </ul>"},{"location":"themes/#cat-mocha","title":"cat-mocha","text":"<p>(back to top)</p>"},{"location":"themes/#cat-macchiato","title":"cat-macchiato","text":"<p>(back to top)</p>"},{"location":"themes/#cat-frappe","title":"cat-frappe","text":"<p>(back to top)</p>"},{"location":"themes/#cat-latte","title":"cat-latte","text":"<p>(back to top)</p>"},{"location":"themes/#dracula","title":"dracula","text":"<p>(back to top)</p>"},{"location":"themes/#gruvbox-dark","title":"gruvbox-dark","text":"<p>(back to top)</p>"},{"location":"themes/#gruvbox-light","title":"gruvbox-light","text":"<p>(back to top)</p>"},{"location":"themes/#nord","title":"nord","text":"<p>(back to top)</p>"},{"location":"themes/#dimmed_monokai","title":"dimmed_monokai","text":"<p>(back to top)</p>"},{"location":"themes/#monokai","title":"monokai","text":"<p>(back to top)</p>"},{"location":"themes/#night-owlish","title":"night-owlish","text":"<p>(back to top)</p>"},{"location":"themes/#rich-default","title":"rich-default","text":"<p>(back to top)</p>"}]} |