Unibeautify / unibeautify

One Beautifier to rule them all, One Beautifier to clean them, One Beautifier to bring them all and in the darkness sheen them
https://unibeautify.com/
MIT License
545 stars 41 forks source link

Better usage description #188

Open muuvmuuv opened 6 years ago

muuvmuuv commented 6 years ago

In the README.md We should better describe the usage. So everyone better understands how to implement this. Something Like:

"First you need to import Unibeautify and load a beautifier to it, so Unibeautify can use beautifier to beautify your text/file that you give it later. Next you need to specfiy some options, have a look here [LINK] to see all available options for the beautifier and language. After that you pass the test/file to the beautifier and wait for the result."

import { Unibeautify } from "unibeautify";
import beautifier from "@unibeautify/beautifier-eslint";

const unibeautify = Unibeautify();

unibeautify.loadBeautifier(beautifier);

const text = `if (foo) {bar();} else {baz();}`;

unibeautify
  .beautify({
    languageName: "JavaScript",
    options: {
      JavaScript: {
        brace_style: "collapse",
        indent_style: "tab"
      }
    },
    text
  })
  .then(results => {
    console.log(results);
  });
muuvmuuv commented 6 years ago

Related to: #102

lassik commented 6 years ago

Could we have an examples directory in the repo with some sample code? We could start with a very minimal example as @muuvmuuv wrote above. Example sourcefiles would have the benefit that they are runnable directly.

Of course, if there's a predecent in the Node JS community of laying out documentation and examples in a different way, then we should follow that convention (I'm sure you know better than me).

Glavin001 commented 6 years ago

Open to receiving Pull Requests enhancing the documentation and developer experience 😃 .