{"id":16573436,"url":"https://github.com/roald87/tcblack","last_synced_at":"2025-06-13T01:04:21.458Z","repository":{"id":41039346,"uuid":"262730195","full_name":"Roald87/TcBlack","owner":"Roald87","description":"Opnionated code formatter for TwinCAT.","archived":false,"fork":false,"pushed_at":"2022-12-25T11:38:08.000Z","size":2060,"stargazers_count":109,"open_issues_count":18,"forks_count":11,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-05-15T23:41:50.001Z","etag":null,"topics":["beckhoff","beckhoff-twincat","beckhoff-twincat-plc","formatter","industrial-automation","plc","plc-programming","twincat","twincat3"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Roald87.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":"roald87","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2020-05-10T06:57:38.000Z","updated_at":"2025-05-13T14:41:25.000Z","dependencies_parsed_at":"2023-01-30T22:01:15.901Z","dependency_job_id":null,"html_url":"https://github.com/Roald87/TcBlack","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/Roald87/TcBlack","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Roald87%2FTcBlack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Roald87%2FTcBlack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Roald87%2FTcBlack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Roald87%2FTcBlack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Roald87","download_url":"https://codeload.github.com/Roald87/TcBlack/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Roald87%2FTcBlack/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259559625,"owners_count":22876494,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["beckhoff","beckhoff-twincat","beckhoff-twincat-plc","formatter","industrial-automation","plc","plc-programming","twincat","twincat3"],"created_at":"2024-10-11T21:42:10.739Z","updated_at":"2025-06-13T01:04:21.406Z","avatar_url":"https://github.com/Roald87.png","language":"C#","funding_links":["https://ko-fi.com/roald87"],"categories":[],"sub_categories":[],"readme":"![Official TcBlack logo](logo/TcBlack_logo_small.png)\n\n# TcBlack: TwinCAT code formatter\n\nOpinionated code formatter for TwinCAT. Currently in the **alpha state**. Use at your **own risk** and only with files which are under source control.\n\n_TcBlack_ is available as a command line tool ([TcBlackCLI](https://github.com/Roald87/TcBlack/releases/tag/v0.2.0)) as well as a visual studio extension ([TcBlackExtension](https://github.com/Roald87/TcBlack/releases/tag/TcBlackExtension_v0.1.0)).\n\n## Current state\n\n`FB_Child` from ShowcaseProject formatted using the _TcBlackExtension_ for Visual Studio.\n\n![tcblack_extension](tcblack_extension.gif)\n\n## _TcBlackCLI_ usage\n\n1. [Download](https://github.com/Roald87/TcBlack/releases/latest) the latest release.\n1. Open the windows command prompt and navigate to the folder containing `TcBlack.exe`.\n1. Reformat one or more file by giving their full path names:\n\n    ```\n    \u003e TcBlack --safe --file C:\\Full\\Path\\To\\Filename.TcPOU C:\\Full\\Path\\To\\AnotherFilename.TcPOU\n    ```\n\n    or using the short version and format a single file:\n\n    ```\n    \u003e TcBlack --safe -f C:\\Full\\Path\\To\\Filename.TcPOU\n    ```\n\n    or format a whole project at once and replace all indentation by a two spaces:\n\n    ```\n    \u003e TcBlack --safe -f C:\\Full\\Path\\To\\Project.plcproj --indentation \"  \"\n    ```\n\nFor more info enter `\u003e TcBlack --help` in the command prompt or check the\n[manual](docs/manual.md).\n\n## Installing the extension\n\nTo install the VSIX extension in Visual Studio or TcXaeShell please see the [installation guide](docs/vsix_installation.md).\n\n## Idea\n\nChange\n\n```\nFUNCTION_BLOCK  FB_Child EXTENDS FB_Base  IMPLEMENTS I_Interface,I_Interface2\n\nVAR_INPUT\nEND_VAR\nVAR\n\nSomeText: STRING;\n\tCounter\t\t: DINT:= 1 ;\n  Result\t\t: DINT :=2;\n\n\n      Base:FB_Base;\nEND_VAR\n===================================\nSomeText:= 'Current counts';\n\nIF Conditions[1] AND Conditions[2]  AND Conditions[3] AND Conditions[4] AND Conditions[5]AND Conditions[6] THEN\n\tCounter :=Counter+ 1;\n\n\tIF Counter \u003e 2 THEN\n\tCounter := Counter + 5 ;\n\tEND_IF\nEND_IF\n\nBase(Variable1:=2, Variable2:=3 , Variable3:= 5,Sentence:='Entropy is a real bitch.', Conditions :=Conditions);\n\n\nAddTwoInts(    Variable1 :=4,\n    Variable2:=4);\n```\n\nInto\n\n```\nFUNCTION_BLOCK FB_Child\nEXTENDS FB_Base\nIMPLEMENTS I_Interface, I_Interface2\nVAR\n    SomeText : STRING;\n    Counter : DINT := 1;\n    Result : DINT := 2;\n\n    Base : FB_Base;\nEND_VAR\n\n===================================\nSomeText := 'Current counts';\n\nIF\n    Conditions[1]\n    AND Conditions[2]\n    AND Conditions[3]\n    AND Conditions[4]\n    AND Conditions[5]\n    AND Conditions[6]\nTHEN\n    Counter := Counter + 1;\n\n    IF Counter \u003e 2 THEN\n        Counter := Counter + 5 ;\n    END_IF\nEND_IF\n\nBase(\n    Variable1:=2,\n    Variable2:=3 ,\n    Variable3:=5,\n    Sentence:='Entropy is a real bitch.',\n    Conditions:=Conditions\n);\n\nAddTwoInts(Variable1:=4, Variable2:=4);\n\n```\n\n## Why\n\nGet a consistent style across your project, without having to go through all the code. Focus on the logic and structure of the code, not the formatting.\n\n## How\n\nBy making a command line tool which can be either used manually on individual files, a whole project or added as a pre-hook commit which automatically reformats before making a commit.\n\n## Style\n\nFollow the same style rules as [Black](https://github.com/psf/black/) for Python (where applicable). Why try to reinvent the wheel, when Black offers a popular rule base which has been tested and tried? For more info see the [style guide](docs/style.md).\n\n## _TcBlackCLI_ implementation\n\nThere are two modes for the _TcBlackCLI_. A safe mode which checks if the code did not undergo unwanted changes after reformatting. The non-safe mode is faster, but it could be that there were unwanted changes to the code. _TcBlackExtension_ always operates in the non-safe mode.\n\nThe safe mode builds the project before and after formatting. It then compares the generated number (a sort of checksum?) which is used as the name of the `*.compileinfo` file. This file is generated in the _\\_CompileInfo_ folder of a project each time it is build.\n\nThe number doesn't change when you alter whitespaces, add/change comments or add brackets around a long if statement. Only if the actual code changes then the number also changes. For example, if you add a variable, add a line of code or change the order of variables.\n\n## Contributing\n\nYou're more then welcome to help if you'd like! See the [contributing guidelines](CONTRIBUTING.md) for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froald87%2Ftcblack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froald87%2Ftcblack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froald87%2Ftcblack/lists"}