pcdshub / pre-commit-hooks

Pre-commit hooks for PCDS projects (https://pre-commit.com/)
Other
10 stars 7 forks source link

TwinCAT POU Pre/Post Newlines Hook #10

Closed ZLLentz closed 6 months ago

ZLLentz commented 4 years ago

I'm considering making a pre-commit hook that inserts newlines at the start and end of TwinCAT POUs (and some of the other files?). When a TwinCAT POU starts and ends with a newline, it is much easier to review in github. Snippit from a current PR of mine that does not do this:

    <Implementation>
      <ST><![CDATA[fbNCErrorFFO(
    stMotionStage := stMotionStage,
    fbFFHWO := fbFFHWO,
    bReset := bReset,
    sName := sName,
    bTripped => bTripped);]]></ST>
    </Implementation>

With pre and post newlines:

    <Implementation>
      <ST><![CDATA[
fbNCErrorFFO(
    stMotionStage := stMotionStage,
    fbFFHWO := fbFFHWO,
    bReset := bReset,
    sName := sName,
    bTripped => bTripped);
]]></ST>
    </Implementation>

With two pre and two post newlines:

    <Implementation>
      <ST><![CDATA[

fbNCErrorFFO(
    stMotionStage := stMotionStage,
    fbFFHWO := fbFFHWO,
    bReset := bReset,
    sName := sName,
    bTripped => bTripped);

]]></ST>
    </Implementation>
klauer commented 4 years ago

Seems reasonable to me 👍 (DUT, GVL, POU is our normal set of "source files" I believe)

ZLLentz commented 4 years ago

Forgot to add, the idea for having these newlines at all comes from some old @slacAWallace PR or comment on a PR of some kind. It's a pain to maintain manually, but as an automatic hook...

ZLLentz commented 6 months ago

closed by #23