Giter VIP home page Giter VIP logo

examples-styler-ex's Introduction

examples-styler-ex

Format elixir code examples in your docs!

click to see build pipeline click to see build pipeline click to see build pipeline

Hex version Documentation

ExamplesStyler is a Mix.Tasks.Format plugin to bring the same styling rules to your docstrings and markdown files!

Usage

This package implements a mix format plugin. Add the following plugins value to your .formatter.exs file:

[
  plugins: [ExamplesStyler],
  inputs: ...
]

If you use a non-default plugin like adobe/elixir-styler to style your code, it will also need to be added:

[
  plugins: [Styler, ExamplesStyler],
  inputs: ...
]

Don't forget to add any .md or .cheatmd files you want examples styled for!

What gets styled

We follow the same approach as ExUnit doc tests: example code must be prefaced by iex> .

iex> # Input
iex> 1 +     1
iex> # Output
iex> 1 + 1

Code found on contiguous lines is styled together:

iex> # Input
iex> def add(a, b),
iex> do: a + b
iex> # Input
iex> def add(a, b),
iex>   do: a + b

Any lines prefaced with iex> that are separated in any way will be styled separately.

Caution is advised

This package is still in very early development; be sure to back up your code before running the formatter!

Installation

If available in Hex, the package can be installed by adding examples_styler to your list of dependencies in mix.exs:

def deps do
  [
    {:examples_styler, "~> 0.2", only: [:dev, :test], runtime: false}
  ]
end

examples-styler-ex's People

Contributors

peake100 avatar

Stargazers

 avatar

Watchers

 avatar

examples-styler-ex's Issues

Use `...>` for multi-line expressions

It would be cool to use ...> instead of iex> as prompt for multi-line expressions:

Expected

iex> Example.say_hello(
...>   "Belly",
...>   "Peak"
...> )
"Hello Belly Peak!"

Actual

iex> Example.say_hello(
iex>   "Belly",
iex>   "Peak"
iex> )
"Hello Belly Peak!"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.