Skip to content

Linting Clang documentation #65725

@cor3ntin

Description

@cor3ntin

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
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clangClang issues not falling into any other categorydocumentationinfrastructureBugs about LLVM infrastructure

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions