clang-tidy-html
clang-tidy-html copied to clipboard
Don't fail if clang-tidy-checks.py can't be written
Hello and thanks for this awesome tool!
To be honest, I don't fully understand why clang-tidy-checks.py is written and what it is for. But I think it should be possible to write the generated HTML to stdout, like it is common in Unix tools. For example allow a syntax as follows:
clang-tidy-html <file> -o -
Of course I can work around that using process substitution:
clang-tidy-html clang-tidy.log -o >(cat)
however that fails, because clang-tidy-checks.py
can't be written:
Traceback (most recent call last):
File "/home/weisbach/.local/bin/clang-tidy-html", line 8, in <module>
sys.exit(main())
File "/home/weisbach/.local/lib/python3.10/site-packages/clang_html/clang_visualizer.py", line 89, in main
clang_tidy_visualizer(tidy_log_lines, output_path, args.checks_dict_url)
File "/home/weisbach/.local/lib/python3.10/site-packages/clang_html/clang_visualizer.py", line 110, in clang_tidy_visualizer
write_checks_file(
File "/home/weisbach/.local/lib/python3.10/site-packages/clang_html/clang_visualizer.py", line 221, in write_checks_file
with open(to_file, 'w') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/dev/fd/clang-tidy-checks.py'
which is really unfortunate.
Currently I'm working around this issue with the code change:
try:
write_checks_file(
checks_list, to_file=output_html_file.parent / "clang-tidy-checks.py")
except FileNotFoundError:
print(f"Could not create {output_html_file.parent}/clang-tidy-checks.py", file=sys.stderr)
But that is very clunky and I'd rather have a stock solution.
Perhaps generation of clang-tidy-checks.py
can be omitted if writing to stdout? Or generation of clang-tidy-checks.py
can be enabled/disabled via a command line option? I'd be willing to make the necessary changes and submit a PR.
Best regards, Hannes
(At the same time it would probably be nice to have clang-tidy-html read the log from stdin)