- Notifications
You must be signed in to change notification settings - Fork1
A tool to check and fix coding style according to .editorconfig file. It passes the fixing tasks to specific language beautifiers.
License
xuhdev/editorconfig-cf
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This python program uses the rule given inEditorConfig files to check and fix your coding style.
It is still under development, but your contribution is highly appreciated, since I do not use all languages!
python /path/to/editorconfig_cf.py [check|format] [file1] [file2] [file3] ...
where[file1]
,[file2]
,[file3]
, ... are the source files you want to check or format.
This script does not touch your code directly; instead, it calls language specific beautifier to check and fix.
When given a file, it first see what type this file is according to its extension. After determining the type of thesource file, EditorConfig-cf tries to call the corresponding beautifiers it knows. If a beautifier is found to beusable, EditorConfig-cf calls the beautifier to check or fix the source code and outputs the fixed code into a file with.ecfmt
extension.
For example, when dealing with a C source file namedmain.c
, EditorConfig-cf tries to calluncrustify. Ifuncrustify is available, it will be used to format this C source file, and write the output intomain.c.ecfmt
.
The framework is already there, what you need is to add your own handling function to handle this type of file with thebeautifier in thehandling
directory, then insert a few lines to tell some information about the beautifier (such as name,for what language).
Here are the details.
Create a new file for your beautifier in thehandling
directory. You need to define a function with the following prototype:
handling(executable, input_file_path, output_file_path, editorconfig_properties)
Whereexecutable
is theexecutable
of the beautifier to be passed in,input_file_path
is the file needs to beformatted,output_file_path
is where the formatted file should be written into,editorconfig_properties
is theoutput of EditorConfig library passed in (seeEditorConfig Python Core Document for what this variable is),c_or_f
shows whether this is checking ('c') or formatting ('f'). You need to fill this function so that the framework can callthis function to handle the specific type of file with the specific beautifier. You will tell the location of thisfunction later.
Editeditorconfig_cf.py
, check the functionget_language_info
andget_beautifier_info
. Check the existingbeautifier and insert meta info of the beautifier you are going to add.
This should be fairly straightforward. Simply refer the other tests and modify it.
If you added any new files, remember you need to add a license header as the other files do. If you code is less than 50effective lines, you can simply copy a header from another file and copyright it under my name. If you do not want tocopyright the code under my name, I will not be against copyright under your name. I encourage you to license underLGPLv3+, but at least your license must be compatible with the other part of the project, that is, a permissive license(Apache v2, BSD, MIT, etc.) or LGPLv3+. LGPLv2 or GPL are not acceptable.
Copyright (C) Hong Xuhong@topbug.net
Unless otherwise stated, most files are licensed underGNU Lesser General Public License Version 3 or later. See theheader of each file for license details.
About
A tool to check and fix coding style according to .editorconfig file. It passes the fixing tasks to specific language beautifiers.
Resources
License
Uh oh!
There was an error while loading.Please reload this page.