Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A tool to check and fix coding style according to .editorconfig file. It passes the fixing tasks to specific language beautifiers.

License

NotificationsYou must be signed in to change notification settings

xuhdev/editorconfig-cf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

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!

Usage

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.

How It Works

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.

Contribution

How Can I Add Beautifier for My Favorite language?

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.

Add Handling Function for Your Beautifier

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_fshows 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.

Add Meta Information of Beautifier

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.

Add Tests in thetests Directory

This should be fairly straightforward. Simply refer the other tests and modify it.

Contribution License

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.

License

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

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp