-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[clang-format] Add cmake target clang-format-style-options for updating ClangFormatStyleOptions.rst #111513
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
Conversation
… up-to-date. As discussed in llvm#96804 (comment)
Add a change to clang/include/clang/Format/Format.h so we can see the new CI check working.
This reverts commit 584828b.
…rmat-style * llvm-trunk/main: (5932 commits) [AArch64] NFC: rename subreg zsub to qsub (llvm#111154) [libomp][AIX] Use SO version "1" for AIX libomp (llvm#111384) [clang][Sema] Bad register variable type error should point to the type (llvm#110239) [AMDGPU] Include WWM register spill into BB Prolog (llvm#111496) [lldb][test] Fix typo in TestSharedLibStrippedSymbols [RISCV] Add cost tests for more interleave factors. NFC [NFC][EarlyIfConverter] Rename SSAIfConv::runOnMachineFunction to SSAIfConv::init (llvm#111500) [Clang] [NFC] Remove trailing whitespace in release notes (llvm#111506) [Clang][AArch64] Fix checkArmStreamingBuiltin for 'sve-b16b16' (llvm#109420) [llvm][docs] Improve the formatting of the Common Problems section (llvm#108522) [lldb][test] Remove xfails from static lib tests on Windows [lldb][test] Fix unexpected pass of TestBSDArchives on Windows Fix comment typo in ExpandFCOPYSIGN (llvm#111489) Revert "[NFC][EarlyIfConverter] Turn SSAIfConv into a local variable (llvm#107390)" (llvm#111385) Recommit "[RISCV][FMV] Support target_version" (llvm#111096)" (llvm#111333) [mlir][SCF][NFC] `scf.for`/`scf.while`: rename builder args (llvm#111493) [libc++][CI] Replace LLDB test targets with libc++ test category (llvm#110856) [Clang] [Sema] Effects: Correctly detect `(x ? a : b)` as nonblocking when a and b are (llvm#111224) [ConstantFPRange] Implement `ConstantFPRange::makeExactFCmpRegion` (llvm#111490) [AArch64][GlobalISel] Scalarize i128/fp128 vector loads/stores. ...
@owenca, see what you think. |
@llvm/pr-subscribers-clang-format @llvm/pr-subscribers-clang Author: Iuri Chaer (ichaer) Changes
As discussed in #96804 (comment) Full diff: https://github.com/llvm/llvm-project/pull/111513.diff 2 Files Affected:
diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml
index 800e9291573533..f559fbd237a99d 100644
--- a/.github/workflows/docs.yml
+++ b/.github/workflows/docs.yml
@@ -75,6 +75,9 @@ jobs:
- 'clang/include/clang/Basic/AttrDocs.td'
- 'clang/include/clang/Driver/ClangOptionDocs.td'
- 'clang/include/clang/Basic/DiagnosticDocs.td'
+ clang-format_style-headers:
+ - 'clang/include/clang/Format/Format.h'
+ - 'clang/include/clang/Tooling/Inclusions/IncludeStyle.h'
clang-tools-extra:
- 'clang-tools-extra/docs/**'
lldb:
@@ -122,6 +125,16 @@ jobs:
run: |
cmake -B clang-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_SPHINX=ON ./llvm
TZ=UTC ninja -C clang-build docs-clang-html docs-clang-man
+ - name: Confirm ClangFormatStyleOptions.rst is up-to-date
+ if: steps.docs-changed-subprojects.outputs.clang-format_style-headers_any_changed == 'true'
+ run: |
+ cmake -B clang-build -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang" -DLLVM_ENABLE_SPHINX=ON ./llvm
+ TZ=UTC ninja -C clang-build clang-format-style-options
+ GIT_STATUS="$(git status --porcelain=v1 clang/docs/ClangFormatStyleOptions.rst)"
+ if [ ! -z "${GIT_STATUS}" ]; then
+ echo "Error: you must build the 'clang-format-style-options' target and commit any changes to 'clang/docs/ClangFormatStyleOptions.rst'"
+ exit 1
+ fi
- name: Build clang-tools-extra docs
if: steps.docs-changed-subprojects.outputs.clang-tools-extra_any_changed == 'true'
run: |
diff --git a/clang/docs/CMakeLists.txt b/clang/docs/CMakeLists.txt
index 4fecc007f59954..93a4356c1d53bb 100644
--- a/clang/docs/CMakeLists.txt
+++ b/clang/docs/CMakeLists.txt
@@ -1,3 +1,9 @@
+add_custom_target(clang-format-style-options
+ COMMAND "${Python3_EXECUTABLE}" dump_format_style.py
+ WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/tools"
+ DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/../include/clang/Format/Format.h"
+ "${CMAKE_CURRENT_SOURCE_DIR}/../include/clang/Tooling/Inclusions/IncludeStyle.h")
+add_dependencies(clang-format clang-format-style-options)
if (DOXYGEN_FOUND)
if (LLVM_ENABLE_DOXYGEN)
|
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.
The documentation build workflow is not really the correct place to put this.
Also, why can't we just run the python script as part of building the docs instead of committing the result of the script to the repository?
Yeah, I agree, but I couldn't find a place which looked correct 😅. This thing of adding built artifacts to the repo always introduces sadness... the documentation build workflow looked like the least bad place. I'll gladly take input on this!
That's an excellent question, maybe @owenca will know! I should have asked in #96804 (comment); what I did instead was try to reason out an explanation based on what I could see, and I came up with two theories. The first one is that we want for Anyhow, I'm proposing this because in #96804 (comment) I thought that it was an unreasonable burden for project maintainers having to manually gate on changes which may affect |
Based on the commit history (d278e0e, https://reviews.llvm.org/D1597), it seems like the real answer might be that it just never got implemented. That looks like it was from the time where there were two build systems that both needed to be maintained at the same time, so maybe somewhat understandable it wasn't implemented that way. There is precedent for generating docs from other files (several clang docs pages are generated through tablegen. So I'd prefer to see a patch doing that rather than just asserting that it is the same. I don't think there should be issues with the Python requirement either. Most importantly, we already require a relatively recent Python in CMake, so its guaranteed to be available, and secondly building That is my read on it, although I'm not a
Yeah, I saw the thread. Thanks for looking into process improvements here. |
@boomanaiden154, I'm willing to do that, but could we confirm with a clang-format maintainer first? In the course of that code review I referenced I did introduce an error in the documentation through a valid change to the header files, and @mydeveloperday was able to catch it by looking at the file generated. The error I introduced would have been hard to catch through automation. I suppose the same could be said for all of the human-consumable artifacts, all the docs, but my impression is that this is a special case, user-facing documentation produced from comments in the source code. My instinct is to agree with you and not version-control artifacts, I just want to make sure that the folks who are dealing with that part of the codebase more frequently agree that change would be net positive. |
Because only part of the doc is generated by
|
IMO it would be more helpful to add the build target to
I'm ok with not adding the CI check though. |
Moving the target from
IMO that would be sad, I would really like to free maintainers up from having to remember this dependency themselves. Is this because you feel |
I wasn't suggesting a different name as
Actually, I like the Anyway, my current workflow is:
It would be nice if I didn't have to run step 4 manually.
I'm not opposed to adding the CI check either. |
… gets picked up by `FormatTests` as well.
Got it! So ideally we'd move I've made it a dependency of the |
It should still be possible to only include the non-generated parts in the repo and then modify the script to add all the generated components on afterwards as a build step? Not sure if I'm missing something here. |
Sometimes we need to edit the non-generated parts, and it would be easier to have the entire contexts. Anyway, don't we need the generated RST file in the repo so that the corresponding HTML file (e.g. https://clang.llvm.org/docs/ClangFormatStyleOptions.html) will be readily available? |
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.
@ichaer I suggest that you split the workflow part to another patch so that we can get the cmake part approved.
#113739 should fix this problem by just adding the options as part of the build and omitting them from the documentation source. |
Co-authored-by: Owen Pan <[email protected]>
It's a bit sad, but I get your point, let's make it more focused. |
clang-format-style-options
, for updating ClangFormatStyleOptions.rst.
clang-format-style-options
, for updating ClangFormatStyleOptions.rst.
If CLANG_INCLUDE_DOCS=OFF then this should be skipped, otherwise the build will fail if llvm/clang/docs doesn't exist. |
Reverted this because it breaks the build. I initially assumed this is due to disabled docs per the previous comment, but I think in my case the problem is actually that this seems to be trying to write to the source directory, which is forbidden. If you need to write out files, that has to happen in the build directory.
|
Reading back here, the general thing you are trying to do here is not allowed. At best you can add this as a manually invoked target that is not implicitly called by anything else. Though the actually correct way to handle this is what was proposed in #113739. |
Changed the mode to read-only in 74d29c6. |
This was fixed in f0b09df, which also addressed an issue that ClangFormatStyleOptions.rst would be deleted by |
clang-format-style-options
build target which re-generates ClangFormatStyleOptions.rst from its source header files.As discussed in #96804 (comment)