GithubHelp home page GithubHelp logo

exsamples's People

Contributors

josecfreittas avatar malian avatar msaraiva avatar tiagoefmoraes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

exsamples's Issues

Long table is not formatted properly

The following code:

      samples do
        :id | :name | :currency | :language | :population | :inflation | :continent | :main_sport | :independence_day
        1 | "Brazil" | "Real (BRL)" | "Portuguese" | 204451000 | 7.70 | "South America" | "Football" | ~D["1822-09-07"]
      end

is formatted like this:

      samples do
        :id |            :name | :currency | :language | :population | :inflation | :continent | :main_sport | :independence_day
           
          1
            |         "Brazil"
            |     "Real (BRL)"
            |     "Portuguese"
            |      204_451_000
            |             7.70
            |  "South America"
            |       "Football"
            | ~D["1822-09-07"]
      end

Here is a test that reproduce the error

  test "very long table" do
    code = """
    samples do
      :id | :name | :currency | :language | :population | :inflation | :continent | :main_sport | :independence_day
      1 | "Brazil" | "Real (BRL)" | "Portuguese" | 204451000 | 7.70 | "South America" | "Football" | ~D["1822-09-07"]
    end
    """

    assert Samples.FormatterPlugin.format(code, []) == """
           samples do
             :id | :name    | :currency    | :language    | :population | :inflation | :continent      | :main_sport | :independence_day
               1 | "Brazil" | "Real (BRL)" | "Portuguese" | 204_451_000 |       7.70 | "South America" | "Football"  | ~D["1822-09-07"]
           end
           """
  end

I am suspecting the line_length to be the cause of this behaviour.

I believe we should override the line_length to properly render the table. WDYT? ping @msaraiva

Feature request: binary keys for maps

I am using this stuff to functionally test api endpoints, and keys there are always strings and not atoms.

Right now I have to Enum.into every sample I use.

Trailing white-space are added after comments in the middle of a table

Formatting the following code

samples do
      :fuel_type | :co2 | :year | :percentage
      # 2020
      :diesel    |  105 |  2020 |       0.069
end

Will result in:

samples do
      :fuel_type | :co2 | :year | :percentage
      # 2020----
      :diesel    |  105 |  2020 |       0.069
end

WIth 4 whitespaces after # 2020. I represented them with -

Here is a test that reproduces the bug:

  test "handle comments" do
    code = """
    samples do
      :fuel_type | :co2 | :year | :percentage
      # 2020
      :diesel | 105 | 2020 | 0.069
      :petrol | 110 | 2020 | 0.054
    end
    """

    assert Samples.FormatterPlugin.format(code, []) == """
           samples do
             :fuel_type | :co2 | :year | :percentage
             # 2020
             :diesel    |  105 |  2020 |       0.069
             :petrol    |  110 |  2020 |       0.054
           end
           """
  end

This is due to the offset we add to the first column

{col_index, value} ->
offset = if col_index == 0, do: String.duplicate(" ", column_offset), else: ""
offset <> align_value(value, cols_info[col_index], false)

A solution could be to pattern match on # in the walk function.

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.