<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/65725>65725</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Linting Clang documentation
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            infrastructure,
            clang,
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          cor3ntin
      </td>
    </tr>
</table>

<pre>
    It would be nice to be able to catch and report during Pre Commit checks syntax errors in the RsT as these are frequents and easy to miss.

![image](https://github.com/llvm/llvm-project/assets/1409019/7abf74c7-3111-4628-93e2-0e2d286b8486)
Some Clang RsT files are created by TableGen, so that leaves us with 2 options:

## Only checking the non-generated documentation files.
This is fairly easy, we can run an existing action to run `sphinx-build` in `clang/docs`, and there are pre-existing actions that could
be adapted to make this work, at least once #65664 is fixed. 

Unfortunately, for that we would have to ignore all references / missing files errors as some of the generated files would not exist.

## Build the docs as part of the existing CI checks

The idea would be to run both `check-clang` and `docs-clang-html` in the same job.
This would be enough to fail CI on invalid docs, which is not bad.
To report errors, we can:
  - Force sphinx to log the errors in a file in addition of the output using the env variable `SPHINXOPTS`
  - Add an action after the build that parse that logs and turn it into annotations. I started to looking into the viability of that
 https://github.com/cor3ntin/llvm-sphinx-log-collector/blob/main/src/index.ts - it seems doable
    Linting would appear as a check in github's PR interface
 - This would require installing sphinx and requirements on the build agent.

The issue with that approach is that it's more work, and each project would have to adapt slightly.
But talking to @AaronBallman we are eventually going to make sure we don't ignore generated files, so we might as well start now.
LLDB also has different requirements.

Not sure when I'll have time to do more thinkering there (if you are interesting on taking on that work let me know!), but i wanted to write up what I found.

Reporting formatting, compilation and clang-tidy errors in the same way would be neat too.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVkuP6jwS_TVmUwIFAwksWPRDzLR09d3WvT3SbCtJhfi2YzN2BZp_Pyo79Eujkb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