常用控制台指令
1. 代码检查
- 使用默认configuration检查文件中的代码格式
vsg -f [file_path]
- 使用自定义configuration检查代码格式
vsg -f [file_path] -c [configuration_path]
2. 代码格式化
- 使用默认configuration修复文件中的代码格式
vsg --fix [file_path]
- 使用自定义configuration中的rules修复文件中的代码格式,若configuration文件中的rules不全,缺少的rules使用默认rules
vsg --fix -f [file_path] -c [configuration_path]
或
vsg --fix [configuration_path] -f [file_path]
3. fix_only
- 仅使用 fix_only_configuration_path 中的rules修复文件中的代码格式,fix_only_configuration_path 文件中未提及的rules不做处理。命令如下:
vsg --fix -f [file_path] --fix_only [fix_only_configuration_path]
或
vsg --fix --fix_only [fix_only_configuration_path] -f [file_path]
- fix_only_configuration_path 仅仅指定了所使用的rule和需要格式化的行位置,无法自定义使用的rule的具体配置。在后面加上 configuration_path 就可以自定义rule的具体配置。命令如下:
vsg --fix --fix_only [fix_only_configuration_path] -f [file_path] -c [configuration_path]
注意:fix_only_configuration_path 文件有格式要求,必须按照该要求写js文件才能正常生效
来自 https://vhdl-style-guide.readthedocs.io/en/latest/tool_integration/generic.html
{
"fix": {
"rule": {
"<rule_id>": [ <number> ]
}
}
}
< rule_id > 指定要用到的规则
< number > 指定对哪一行进行格式化,如果值为all,则代表对所有行格式化
参考官方使用文档:Overview — vhdl-style-guide 3.18.0 documentation
对多个文件批量处理看 Usage — vhdl-style-guide 3.18.0 documentation
VSG所使用的所有规则看Rules — vhdl-style-guide 3.18.0 documentation