Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
August 11, 2022 02:21 am GMT

Run README.md in your terminal

Documentation has always been a crucial part of onboarding onto a non-trivial system. For this reason, developers of packaged software started including README files as part of their distribution documentation dating back to the mid-1970s.

Today, the readme is still around but has morphed into a markdown-based README.md file that lives in your repos version control. It has become part of modern development culture, and you will find them everywhere.

retro.png

Swordfish90s Apple2 retro terminal viewing rdmes README.md

Lowering entry barriers for developers

At Stateful, we want to lower development onboarding barriers and make prerequisites, setup, and workflows as approachable as possible. Source code hosting platforms such as GitHub have already elevated the README.md as a repos primary entry point in their UX, but they still diverge from code and documentation and we want to see more.

Run README commands straight from my terminal?

Primarily born out of the annoyance of never-ending README copy & paste, our teammate Adam Babik decided to utilize a Markdown Abstract Syntax Tree parser to generate a naive digest of README snippets and make them easily runnable. This is a prototype (take the happy path!), but we are pleased with the initial results. Illustrated here using Husky - a popular solution to manage git hooks:

We skipped $ rdme run npm-install for brevity

Running through huskys example with ease

Running through huskys example with ease

Let's run through it

The parsing is still far from perfect, but with best-effort pattern-matching of the AST into a data structure of command snippet pairs, we are often able to capture commands and their implied description. The outputted list tries to maintain the order initially defined in the README.md. Feel free to copy & paste the following step-by-step breakdown. You really shouldnt have to, though, now that you have rdme .

Simply list all commands

$ rdme list

List all commands in your README

Prepare package.jsons scripts for git-pre-commit hook

$ rdme run npm-pkg

Prepare package.jsons scripts for git-pre-commit hook

Now install example pre-commit husky hook

$ rdme run npx-husky

 raw `rdme run npx-husky` endraw  which will install an example husky hook

Trigger the pre-commit hook

$ rdme run git-commit

 raw `rdme run git-commit` endraw

Using a simple rdme run <name> you can run command blocks (check out the tab completion too) without much fuzz (as illustrated above making a sample commit to trigger the git-pre-commit hook). For a simple CLI tool, we have been pleasantly surprised at how natural the experience feels for interacting with tasks (if you like the terminal). You can find some additional examples inside of rdmes repo.

Maybe in the future we will employ automation to execute the READMEs commands continuously and detect outdated docs, but for now let's catch those issues by running them regularly with rdme!

Go ahead and take rdme for a spin

If you are on MacOS and using homebrew, its as easy as installing rdme from our tap:

$ brew install stateful/tap/rdme

You can use scoop to install a version of rdme on Windows. However, please note that currently only shell environments (PowerShell is not supported yet) are supported.

$ scoop bucket add stateful https://github.com/stateful/scoop-bucket.git && scoop install stateful/rdme

For all other platforms, please check out the install section in rdmes README.md.

Much more rdme could do

Using rdme internally has led to a lengthy list of possible improvements, but weve intentionally decided to keep it simple and release rdme's codebase as alpha.

Heres a list of possible improvements:

  • more robust parsing, configurability and/or ML/AI
  • annotating markdown to achieve deterministic snippets
  • introducing interactivity and color into CLI experience
  • embedding run controls&output in README markdown viewer
  • automated ENV resolution, injection of user runtime config
  • C/I testability, as in always know when you are breaking docs
  • deterministic order of commands, without building Makefile inside of READMEs
  • what else?

Check out rdmes GitHub issues to get a better sense of what projects are on the agenda.

Let us know how it goes

If rdme struck the same cord with you or, if you have strong feelings in one way or another, we would love to hear about it. Using the tool you will likely uncover edge cases. Please don't be shy to tell us about them on Discord or just drop a line in the comments below.


Original Link: https://dev.to/sourishkrout/run-readmemd-in-your-terminal-19i

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To