Giter Site home page Giter Site logo

formatting's Introduction

Formatting 源码格式自动化调整工具

如果喜欢请Star,这是对本开源项目最大的鼓励,谢谢


本文件会自动递归遍历指定文件夹下的所有文件或者指定的文件(默认对.c/.h/.cpp/.hpp,也可以改成你想要的文件类型)进行扫描:

  • 将源文件编码统一为UTF-8

  • 将TAB键替换为4空格

  • 将每行末尾多余的空格删除,并统一换行符为'\n'

  • 将RT-Thread版权信息的截至年份修改至今年(若文件不涉及此问题,程序会自动忽略)

  • 将上海睿赛德版权信息的截至年份修改至今年(若文件不涉及此问题,程序会自动忽略)

安装依赖软件包

pip install -r requirements.txt

本软件为python3源码

使用方法

方法一

直接运行脚本,根据提示信息,输入要扫描的文件夹或者文件名即可。

▸ python formatting.py
Please enter work path or file to format: test_dir

方法二

可以直接在命令行参数中指定需要格式化的文件夹或者文件名

▸ python formatting.py [dir/file_name]

[] 表示内容是可选的

教学视频

https://www.bilibili.com/video/BV1XN411Q7n3

注意

建议git的换行转换设置为:

git config --global core.autocrlf input
git config --global core.safecrlf false
git config --global core.filemode false

使用协议

本软件为MIT协议,可以自由免费使用,无论是个人目的还是商业目的,但是发现本脚本有任何问题,请提PR协助修复。

formatting's People

Contributors

bernardxiong avatar chenyingchun0312 avatar iysheng avatar mysterywolf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

formatting's Issues

open 需要指定 newline 参数

两句 file_temp = open(temp_file, 'w', encoding='utf-8') 应该改成 file_temp = open(temp_file, 'w', encoding='utf-8', newline='\n')

否则在 windows 上执行时文件后缀依然保持 '\r\n' 不变

python version

It might be useful to say that this tool only supports python 3 in readme.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.