From 22cdeafe0d334070cd735723d659191df8a11296 Mon Sep 17 00:00:00 2001 From: Aiden Grossman Date: Fri, 25 Oct 2024 21:25:37 +0000 Subject: [PATCH 1/3] [clang-format][CMake] Generate formatting options docs during build This patch changes up the CMake configuration so that ClangFormatStyleOptions.rst has the format style options section generated by the dump_format_style.py python script during the build rather than manually. This allows us to remove ~6000 lines of automatically generated documentation from the repository. If the context of the options is needed while generating the docs, it is easy enough to open up the generated file with the options from within the build directory after the clang-format-style-options target has been built. --- clang/docs/CMakeLists.txt | 11 +- clang/docs/ClangFormatStyleOptions.rst | 6651 +----------------------- clang/docs/tools/dump_format_style.py | 2 +- 3 files changed, 13 insertions(+), 6651 deletions(-) diff --git a/clang/docs/CMakeLists.txt b/clang/docs/CMakeLists.txt index 4fecc007f5995..313b0efd1dbd6 100644 --- a/clang/docs/CMakeLists.txt +++ b/clang/docs/CMakeLists.txt @@ -143,8 +143,17 @@ if (LLVM_ENABLE_SPHINX) gen_rst_file_from_td(DiagnosticsReference.rst -gen-diag-docs ../include/clang/Basic/Diagnostic.td "${docs_targets}") gen_rst_file_from_td(ClangCommandLineReference.rst -gen-opt-docs ../include/clang/Driver/ClangOptionDocs.td "${docs_targets}") + add_custom_target(clang-format-style-options + COMMAND "${Python3_EXECUTABLE}" "${CLANG_SOURCE_DIR}/docs/tools/dump_format_style.py" + WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + DEPENDS "${CLANG_SOURCE_DIR}/include/clang/Format/Format.h" + "${CLANG_SOURCE_DIR}/include/clang/Tooling/Inclusions/IncludeStyle.h" + "${CLANG_SOURCE_DIR}/docs/tools/dump_format_style.py" + copy-clang-rst-docs + ) + foreach(target ${docs_targets}) - add_dependencies(${target} copy-clang-rst-docs) + add_dependencies(${target} copy-clang-rst-docs clang-format-style-options) endforeach() endif() endif() diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst index 9ef1fd5f36d1d..508a058de6f76 100644 --- a/clang/docs/ClangFormatStyleOptions.rst +++ b/clang/docs/ClangFormatStyleOptions.rst @@ -1,9 +1,3 @@ -.. - !!!!NOTE!!!! - This file is automatically generated, in part. Do not edit the style options - in this file directly. Instead, modify them in include/clang/Format/Format.h - and run the docs/tools/dump_format_style.py script to update this file. - .. raw:: html