[PATCH] D106734: Eliminate clang man page generation warning for missing .rst files

Tony Tye via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 23 18:51:06 PDT 2021


t-tye created this revision.
t-tye added reviewers: kzhuravl, scott.linder.
Herald added a subscriber: mgorny.
t-tye requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Update `clang/docs/CMakeLists.txt` for Sphinx man builder to do the same as for
the html builder to ensure .td generated .rst files are available to prevent
warnings of missing .rst files.

Document `SOURCE_DIR` named argument to `add_sphinx_target` function.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106734

Files:
  clang/docs/CMakeLists.txt
  llvm/cmake/modules/AddSphinxTarget.cmake


Index: llvm/cmake/modules/AddSphinxTarget.cmake
===================================================================
--- llvm/cmake/modules/AddSphinxTarget.cmake
+++ llvm/cmake/modules/AddSphinxTarget.cmake
@@ -20,6 +20,9 @@
 # ``project`` should be the project name
 #
 # Named arguments:
+# ``SOURCE_DIR`` source directory for Sphinx files. Defaults to
+#                ${CMAKE_CURRENT_SOURCE_DIR}.
+#
 # ``ENV_VARS`` should be a list of environment variables that should be set when
 #              running Sphinx. Each environment variable should be a string with
 #              the form KEY=VALUE.
Index: clang/docs/CMakeLists.txt
===================================================================
--- clang/docs/CMakeLists.txt
+++ clang/docs/CMakeLists.txt
@@ -103,19 +103,26 @@
 if (LLVM_ENABLE_SPHINX)
   include(AddSphinxTarget)
   if (SPHINX_FOUND)
+
+    # Copy rst files to build directory before generating the
+    # documentation.  Some of the rst files are generated, so they
+    # only exist in the build directory.  Sphinx needs all files in
+    # the same directory in order to generate the files, so we need to
+    # copy all the non-generated rst files from the source to the build
+    # directory before we run Sphinx.
+    add_custom_target(copy-clang-rst-docs
+      COMMAND "${CMAKE_COMMAND}" -E copy_directory
+      "${CMAKE_CURRENT_SOURCE_DIR}"
+      "${CMAKE_CURRENT_BINARY_DIR}")
+
+    # Generated files
+    gen_rst_file_from_td(AttributeReference.rst -gen-attr-docs ../include/clang/Basic/Attr.td copy-clang-rst-docs)
+    gen_rst_file_from_td(DiagnosticsReference.rst -gen-diag-docs ../include/clang/Basic/Diagnostic.td copy-clang-rst-docs)
+    gen_rst_file_from_td(ClangCommandLineReference.rst -gen-opt-docs ../include/clang/Driver/ClangOptionDocs.td copy-clang-rst-docs)
+
     if (${SPHINX_OUTPUT_HTML})
       add_sphinx_target(html clang SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
 
-      # Copy rst files to build directory before generating the html
-      # documentation.  Some of the rst files are generated, so they
-      # only exist in the build directory.  Sphinx needs all files in
-      # the same directory in order to generate the html, so we need to
-      # copy all the non-gnerated rst files from the source to the build
-      # directory before we run sphinx.
-      add_custom_target(copy-clang-rst-docs
-        COMMAND "${CMAKE_COMMAND}" -E copy_directory
-        "${CMAKE_CURRENT_SOURCE_DIR}"
-        "${CMAKE_CURRENT_BINARY_DIR}")
       add_dependencies(docs-clang-html copy-clang-rst-docs)
 
       add_custom_command(TARGET docs-clang-html POST_BUILD
@@ -123,13 +130,12 @@
         "${CMAKE_CURRENT_SOURCE_DIR}/LibASTMatchersReference.html"
         "${CMAKE_CURRENT_BINARY_DIR}/html/LibASTMatchersReference.html")
 
-      # Generated files
-      gen_rst_file_from_td(AttributeReference.rst -gen-attr-docs ../include/clang/Basic/Attr.td docs-clang-html)
-      gen_rst_file_from_td(DiagnosticsReference.rst -gen-diag-docs ../include/clang/Basic/Diagnostic.td docs-clang-html)
-      gen_rst_file_from_td(ClangCommandLineReference.rst -gen-opt-docs ../include/clang/Driver/ClangOptionDocs.td docs-clang-html)
     endif()
+
     if (${SPHINX_OUTPUT_MAN})
-      add_sphinx_target(man clang)
+      add_sphinx_target(man clang SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+      add_dependencies(docs-clang-man copy-clang-rst-docs)
     endif()
+
   endif()
 endif()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106734.361401.patch
Type: text/x-patch
Size: 3443 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210724/a2c68364/attachment.bin>


More information about the llvm-commits mailing list