New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: fix warnings for documentation build, use a linter #16407
Conversation
Why aren't the doc tests picking up on these in the PR that introduced the lines? Docs warnings are intended to break the build so we can give the feedback to the original developer so they will learn and get these things right before we merge, rather than relying on folks like you to follow up. |
Ok so there are several things here.
I marked as draft and will rework this PR:
|
[Apparently, adding rstcheck to requirements.txt is not enough to be able to call the binary :/] [EDIT] Hmm or do we need the PR to be merged first to have docs-builder updated with the new requirements? 🤔 |
@@ -85,4 +85,11 @@ fi | |||
# fi | |||
|
|||
echo "Building documentation (${target})..." | |||
exec sphinx-build -M "${target}" "${script_dir}" "${build_dir}" $@ | |||
sphinx-build -M "${target}" "${script_dir}" "${build_dir}" $@ -q 2> >(tee "${warnings}" >&2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious, what's the difference between having the exec
at the start vs. not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked the author of the code (Ilya) about that before doing the change, and he answered that it was mostly a “stylistic thing”, that “when a script calls one command at the end and that command is relatively heavyweight, [he] tends to use exec to sort of signify the purpose of the script”.
But I had to remove it because exec
-ing into the command substitutes that command to the shell, and we wouldn't return to run the new instructions that my commit adds below.
#16474 (better) addresses some |
The check-build.sh script would check for warnings produced by running "sphinx-build -b spelling", but not those produced when generating the documentation with "sphinx-build -M html". Let's reuse the warnings.txt file to store these warnings, if any, and to return with a non-0 exit code in that case. Notes: The file can be safely truncated (we won't reach that step if warnings were generated from "sphinx-build -b spelling"). Also we do not have to care of errors produced by "sphinx-build -M html", as they would translate in an error exit code that would make the script return before we look at the warnings. Signed-off-by: Quentin Monnet <quentin@isovalent.com>
"txt" is not a valid language to pass to "code-block" directives. Passing "none" instead of "txt" would work; but there is no need to mark the snippet as a "code-block" if no syntax highlighting is required, simply using a literal block is enough. Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Use rstcheck (https://github.com/myint/rstcheck/) as a linter for the RST Documentation files. Run the linter before syntax and spelling validation by Sphinx, because it goes much faster, so we fail faster if an error happens at that stage. Ignore the following items: - Custom directives: tabs (from Sphinx extensions). - Custom roles: any role added with the extlinks extension. - Language: skip linting for bash in ".. code-block:: bash" snippets. - Messages: - Skip an error on ordinated lists in bpf.rst (we have list with decreasing numbers, and there is also a small indent issue in a bit enumerated list in the file, but Sphinx handles it well so let's leave it untouched). - Hyperlink target not referenced: rstcheck does not seem able to recognise when targets are referenced from a different file. - Duplicate implicit target name: this happens when HTML anchors generated from section titles collide with explicit targets (or other section titles on the same page). This is harmless and we are not looking to fix those. - Malformed tables: it would be useful to have these reports if rstcheck would support ignoring substitution ("|PATTERN|") in grid tables. I reported a bug on rstcheck's tracker. - Substitutions: any custom substitution defined in conf.py. Note the existence of an alternative tool, rst-lint (https://github.com/twolfson/restructuredtext-lint), but from my experiments it does not integrate well with Sphinx at the moment. Signed-off-by: Quentin Monnet <quentin@isovalent.com>
The syntax for inline hyperlinks can take one or two underscores at the end of the marker. With one underscore, it is an explicit target, which means that the text for the link can be reused elsewhere without having to copy the URL again. With two underscores, the reference is anonymous and cannot be reused elsewhere. Avoid having multiple explicit targets in the documentation. Let's go for the easiest possible fix: add an additional underscore to make the targets anonymous. Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Following a report from rstcheck, indent the code blocks used in enumerated list items, to make them part of these items instead of "breaking" the list. Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Rebased, now that #16474 has been merged. |
I pulled this PR, build a new cilium/docs-builder image (tagged with |
A JSON snippet in alibabacloud-eni.rst is not valid JSON, there is a spurious comma after the last element of an array. Let's remove it to make the JSON valid. Let's also update the declaration for two blocks that were recently marked as JSON. The ouptut contained in these blocks is made of JSON fragments, but each block contains _several_ fragments without a root object or array, making the entire snippet invalid JSON and trigerring reports from the linter. Let's simply use literal blocks instead. Signed-off-by: Quentin Monnet <quentin@isovalent.com>
A snippet of code was recently marked as C, but it actually contains both C and a sample output from the kernel verifier (which is not C code). Sphinx raises a warning as it fails to apply syntax highlighting for C for that snippet. Let's split the C code from the verifier output. Signed-off-by: Quentin Monnet <quentin@isovalent.com>
Four big steps in the PR:
Please refer to individual commit logs for details.