<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>notes from /dev/null - regfmt</title><link href="http://yummymelon.com/devnull/" rel="alternate"/><link href="http://yummymelon.com/devnull/feeds/tags/regfmt.atom.xml" rel="self"/><id>http://yummymelon.com/devnull/</id><updated>2022-10-25T11:31:00-07:00</updated><entry><title>Introducing regfmt</title><link href="http://yummymelon.com/devnull/introducing-regfmt.html" rel="alternate"/><published>2022-10-25T11:31:00-07:00</published><updated>2022-10-25T11:31:00-07:00</updated><author><name>Charles Choi</name></author><id>tag:yummymelon.com,2022-10-25:/devnull/introducing-regfmt.html</id><summary type="html">&lt;p&gt;Introducing regfmt - a command line utility to generate SVG diagrams for control register-style data formats&lt;/p&gt;</summary><content type="html">&lt;p&gt;&lt;img alt="img" src="http://yummymelon.com/images/example_0001-github.svg"&gt;&lt;/p&gt;
&lt;p&gt;Sometimes a project you've had in the mental back burner for decades calls to you again, but this time you pay attention. So it is with &lt;strong&gt;regfmt&lt;/strong&gt;, a command line utility that I spent this past month working on.&lt;/p&gt;
&lt;h2&gt;Backstory&lt;/h2&gt;
&lt;p&gt;While I was in grad school back in the early 1990's the department had prescribed using the AT&amp;amp;T &lt;a href="https://www.troff.org"&gt;troff&lt;/a&gt; tools for writing papers. Among those tools was one called &lt;a href="https://github.com/arnoldrobbins/dformat"&gt;dformat&lt;/a&gt;, which enabled you to easily draw out control register-style data formats using a domain specific language (DSL).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;dformat&lt;/strong&gt; was a great tool for its time but over the years got consigned to bit rot and ultimately forgotten by many. Among the reasons for it being forgotten was that it only supported the &lt;strong&gt;troff&lt;/strong&gt; specific &lt;strong&gt;pic&lt;/strong&gt; drawing language and used a make-shift DSL for its input.&lt;/p&gt;
&lt;h2&gt;Today&lt;/h2&gt;
&lt;p&gt;The world moved on and settled on other tools for writing and drawing. That said, the fundamentals of computer design haven't changed and control registers are still a thing, so the need to draw them out is still a thing, and drawing them by hand is still painful.&lt;/p&gt;
&lt;p&gt;In the intervening time from the early '90s to 2022, I've run into times when I wished I had something like &lt;strong&gt;dformat&lt;/strong&gt; but &lt;em&gt;modern&lt;/em&gt; to use for writing technical documentation. What's modern you say? How about having:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a common vector graphics file format output such as &lt;code&gt;SVG&lt;/code&gt; which can then be easily converted to a raster format (&lt;code&gt;png&lt;/code&gt;, &lt;code&gt;jpg&lt;/code&gt;, etc.).&lt;/li&gt;
&lt;li&gt;an input specification that is based on a common data serialization language.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In the early summer of 2022, I got to thinking about &lt;strong&gt;dformat&lt;/strong&gt; and how it could be re-imagined for today and realized wow, all the pieces I needed were there:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use &lt;a href="https://en.wikipedia.org/wiki/Scalable_Vector_Graphics"&gt;SVG&lt;/a&gt; for the output format&lt;/li&gt;
&lt;li&gt;Use &lt;a href="https://en.wikipedia.org/wiki/YAML"&gt;YAML&lt;/a&gt; for the input format&lt;/li&gt;
&lt;li&gt;Use &lt;a href="https://en.wikipedia.org/wiki/CSS"&gt;CSS&lt;/a&gt; to style the output&lt;/li&gt;
&lt;li&gt;Implement in &lt;a href="https://www.python.org"&gt;Python&lt;/a&gt; which has support for all of the above.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In October 2022, I found the cycles to go to work on this.&lt;/p&gt;
&lt;h2&gt;Announcing &lt;strong&gt;regfmt&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;regfmt&lt;/strong&gt; is a Python command line utility to generate SVG diagrams for control register-style data formats. It is inspired by the &lt;em&gt;dformat&lt;/em&gt; command from the &lt;em&gt;troff&lt;/em&gt; family of tools, however re-imagined using contemporary (circa 2022) file formats.&lt;/p&gt;
&lt;p&gt;Python installation:
PyPI:  &lt;a href="https://pypi.org/project/regfmt/"&gt;https://pypi.org/project/regfmt/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Source Repository:
GitHub: &lt;a href="https://github.com/kickingvegas/regfmt"&gt;https://github.com/kickingvegas/regfmt&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;Example output of &lt;strong&gt;regfmt&lt;/strong&gt;&lt;/h3&gt;
&lt;p&gt;&lt;img alt="img" src="http://yummymelon.com/images/register-stair-left.svg"&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="img" src="http://yummymelon.com/images/register.svg"&gt;&lt;/p&gt;
&lt;h3&gt;Features&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;SVG output&lt;/li&gt;
&lt;li&gt;Modern configuration input file formats&lt;ul&gt;
&lt;li&gt;YAML for register configuration&lt;/li&gt;
&lt;li&gt;CSS for styling SVG output&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;Try it out!&lt;/h2&gt;
&lt;p&gt;If you need a tool like this, please take the time to try it out. Any &lt;a href="https://github.com/kickingvegas/regfmt/issues" title="regfmt issue tracker"&gt;feedback&lt;/a&gt; would be appreciated!&lt;/p&gt;
&lt;h3&gt;Requirements&lt;/h3&gt;
&lt;p&gt;Python: ≧ 3.9 &lt;/p&gt;
&lt;h3&gt;Installation&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;regfmt&lt;/strong&gt; supports installation via &lt;a href="https://pypi.org/project/regfmt/"&gt;PyPI&lt;/a&gt;. Is is recommend that you do this in a Python virtual environment. &lt;/p&gt;
&lt;div class="highlight"&gt;&lt;table class="highlighttable"&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt;&lt;span class="normal"&gt;1&lt;/span&gt;
&lt;span class="normal"&gt;2&lt;/span&gt;
&lt;span class="normal"&gt;3&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;$&lt;span class="w"&gt; &lt;/span&gt;python3&lt;span class="w"&gt; &lt;/span&gt;-m&lt;span class="w"&gt; &lt;/span&gt;venv&lt;span class="w"&gt; &lt;/span&gt;.venv
$&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nb"&gt;source&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;.venv/bin/activate
&lt;span class="o"&gt;(&lt;/span&gt;.venv&lt;span class="o"&gt;)&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;pip&lt;span class="w"&gt; &lt;/span&gt;install&lt;span class="w"&gt; &lt;/span&gt;regfmt
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;</content><category term="misc"/><category term="dev"/><category term="regfmt"/><category term="writing"/><category term="software"/><category term="computer"/><category term="unix"/></entry></feed>