Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added setting to select indentation type #9

Merged
merged 3 commits into from
Oct 11, 2018

Conversation

LeChuck42
Copy link
Contributor

This adds indentation control settings (tabs or spaces) in the config menu.
I don't know how to update the tests though...

Cheers!

@LeChuck42
Copy link
Contributor Author

Fixes #7

@sneakypete81
Copy link
Owner

Thanks very much for doing this. I'll try to take a closer look shortly.

Copy link
Owner

@sneakypete81 sneakypete81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much for submitting this, it looks good to me.
Regarding tests, you can add the following to templates-spec.js to check tabs and a variable number of spaces:

  it("can create a component with tabbed indent", function () {
    const text = componentTemplate(entities.adder, {indentType: "Tabs"})
    expect(text).toEqual(loadFixture("component/adder_indent_tab.vhd"))
  })

  it("can create a component with indent of three spaces", function () {
    const text = componentTemplate(entities.adder,
      {indentType: "Spaces", indentSpaceCnt: 3})
    expect(text).toEqual(loadFixture("component/adder_indent_3spaces.vhd"))
  })

(repeating for the instance and signal templates)

Then create files in the fixture directories with the correct indentation style.
For example, fixture/component/adder_indent_3spaces.vhd would be:

component add
generic (
   WIDTH  : integer := 3;
   HEIGHT : integer := 2
);
port (
   clk    : in  std_logic;
   in     : in  std_logic_vector(WIDTH-1 downto 0);
   output : out std_logic_vector(WIDTH-1 downto 0)
);
end component add;

Does that make sense?

See https://flight-manual.atom.io/hacking-atom/sections/package-word-count/#running-tests for how to run the test suite from within Atom, and let me know if you have any problems.

lib/config.js Outdated
enum: ["Spaces", "Tabs"],
order: 2
},
indentSpaceCnt: {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit: no need to abbreviate Count to Cnt.

@LeChuck42
Copy link
Contributor Author

Thanks for pointing me to the flight manual and providing the examples. I had some trouble on my Windows machine with git checking out files with CR+LF line endings. With the autocrlf feature disabled however, all tests complete successfully!

@sneakypete81 sneakypete81 merged commit 7e3f086 into sneakypete81:master Oct 11, 2018
@sneakypete81
Copy link
Owner

Great stuff, thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants