sphinx-contrib / sphinx-lint

Check for stylistic and formal issues in .rst and .py files included in the documentation
https://pypi.org/project/sphinx-lint/
Other
75 stars 20 forks source link

[feature request] Add option to store output in file as well #125

Open rffontenelle opened 1 month ago

rffontenelle commented 1 month ago

When running sphinx-lint in CI environment, I'd like to have the syntax issues to be both printed to the output and stored in a log file, because the output will be annotated with sphinx-lint-problem-matcher in the GitHub Actions output, and the log file will be upload as an artifact to notify outside GitHub.

In this scenario, If I simply redirect sphinx-lint > file I get no output, if I redirect using tee (to get both console and log) I won't get my Shell script to quit after the error status when set -e (If I set -o pipefail, tee wouldn't be run as sphinx-lint would exit with error before).

Taking Sphinx as example, its -w flag store warnings in log file but still print to output.

JulienPalard commented 1 month ago

What about:

sphinx-lint > file
status=$?
cat file
exit $status

?

rffontenelle commented 1 month ago

If set -e (exit on error), it will quit after the first line. Surely this flag can be unset temporarily, but then it would mask other issues like e.g. sphinx-lint accidentally being not installed in a CI environment.

Today sphinx-lint already print syntax errors to stdout and exit with 1 when there syntax errors. With this other feature (flag to save to file as well), no other lines would be necessary to save the synax errors to a file as well.

By the way, sphinx-lint 2> logfile would be the correct redirect since my PR for sending errors to stderr