t-tye updated this revision to Diff 361407.
t-tye added a comment.

Factor out documentation and CMake file changes unrelated to adding DOCX 
support to D106736 <https://reviews.llvm.org/D106736>.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106339/new/

https://reviews.llvm.org/D106339

Files:
  clang-tools-extra/docs/CMakeLists.txt
  clang-tools-extra/docs/conf.py
  clang-tools-extra/docs/make.bat
  clang/docs/CMakeLists.txt
  clang/docs/Makefile.sphinx
  clang/docs/analyzer/conf.py
  clang/docs/analyzer/make.bat
  clang/docs/conf.py
  clang/docs/make.bat
  flang/docs/CMakeLists.txt
  flang/docs/conf.py
  libcxx/docs/CMakeLists.txt
  libcxx/docs/Makefile.sphinx
  libcxx/docs/conf.py
  libunwind/docs/CMakeLists.txt
  libunwind/docs/conf.py
  lld/docs/CMakeLists.txt
  lld/docs/conf.py
  lld/docs/make.bat
  lld/docs/sphinx_intro.rst
  lldb/docs/CMakeLists.txt
  lldb/docs/conf.py
  lldb/docs/resources/build.rst
  llvm/cmake/modules/AddSphinxTarget.cmake
  llvm/cmake/modules/FindSphinx.cmake
  llvm/docs/CMake.rst
  llvm/docs/CMakeLists.txt
  llvm/docs/Makefile.sphinx
  llvm/docs/README.txt
  llvm/docs/conf.py
  llvm/docs/make.bat
  openmp/docs/CMakeLists.txt
  openmp/docs/README.txt
  openmp/docs/conf.py
  polly/docs/CMakeLists.txt
  polly/docs/conf.py

Index: polly/docs/conf.py
===================================================================
--- polly/docs/conf.py
+++ polly/docs/conf.py
@@ -28,6 +28,9 @@
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['sphinx.ext.todo', 'sphinx.ext.mathjax']
 
+if tags.has('builder-docx'):
+    extensions.append('docxbuilder')
+
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
 
Index: polly/docs/CMakeLists.txt
===================================================================
--- polly/docs/CMakeLists.txt
+++ polly/docs/CMakeLists.txt
@@ -98,6 +98,9 @@
     if (${SPHINX_OUTPUT_MAN})
       add_sphinx_target(man polly)
     endif()
+    if (${SPHINX_OUTPUT_DOCX})
+      add_sphinx_target(docx polly)
+    endif()
   endif()
 endif()
 
Index: openmp/docs/conf.py
===================================================================
--- openmp/docs/conf.py
+++ openmp/docs/conf.py
@@ -28,6 +28,9 @@
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['sphinx.ext.todo', 'sphinx.ext.mathjax', 'sphinx.ext.intersphinx']
 
+if tags.has('builder-docx'):
+    extensions.append('docxbuilder')
+
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
 
Index: openmp/docs/README.txt
===================================================================
--- openmp/docs/README.txt
+++ openmp/docs/README.txt
@@ -58,3 +58,23 @@
 
 Other projects (such as openmp)
     `https://<project>.llvm.org/docs/CommandGuide/Foo.html`
+
+DOCX Output
+===========
+
+Building the DOCX files is similar to building the HTML documentation. The
+primary difference is to use the `docx` makefile target, instead of the
+default (which is `html`). Sphinx then produces the DOCX files in the
+directory `<build-dir>/docs/docx/`.
+
+    cd <build-dir>
+    cmake -DLLVM_ENABLE_SPHINX=true -DSPHINX_OUTPUT_DOCX=true <src-dir>
+    make
+
+The correspondence between reStructuredText files and generated DOCX files is:
+
+LLVM project
+    `llvm/docs/index.rst` <-> `<build-dir>/docs/docx/LLVM.docx` <-> `<install-dir>/share/doc/llvm/LLVM.docx`
+
+Other projects
+    `<project>/docs/index.rst` <-> `<build-dir>/tools/<project>/docs/docx/<project>.docx` <-> `<install-dir>/share/doc/<project>/<project>.docx`
Index: openmp/docs/CMakeLists.txt
===================================================================
--- openmp/docs/CMakeLists.txt
+++ openmp/docs/CMakeLists.txt
@@ -99,5 +99,8 @@
     if (${SPHINX_OUTPUT_MAN})
       add_sphinx_target(man openmp)
     endif()
+    if (${SPHINX_OUTPUT_DOCX})
+      add_sphinx_target(docx openmp)
+    endif()
   endif()
 endif()
Index: llvm/docs/make.bat
===================================================================
--- llvm/docs/make.bat
+++ llvm/docs/make.bat
@@ -31,6 +31,7 @@
 	echo.  text       to make text files
 	echo.  man        to make manual pages
 	echo.  texinfo    to make Texinfo files
+	echo.  docx       to make DOCX files
 	echo.  gettext    to make PO message catalogs
 	echo.  changes    to make an overview over all changed/added/deprecated items
 	echo.  linkcheck  to check all external links for integrity
@@ -153,6 +154,14 @@
 	goto end
 )
 
+if "%1" == "docx" (
+	%SPHINXBUILD% -b docx %ALLSPHINXOPTS% %BUILDDIR%/docx
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The DOCX files are in %BUILDDIR%/docx.
+	goto end
+)
+
 if "%1" == "gettext" (
 	%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
 	if errorlevel 1 exit /b 1
Index: llvm/docs/conf.py
===================================================================
--- llvm/docs/conf.py
+++ llvm/docs/conf.py
@@ -28,6 +28,9 @@
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['sphinx.ext.intersphinx', 'sphinx.ext.todo']
 
+if tags.has('builder-docx'):
+    extensions.append('docxbuilder')
+
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
 
Index: llvm/docs/README.txt
===================================================================
--- llvm/docs/README.txt
+++ llvm/docs/README.txt
@@ -59,6 +59,26 @@
 Other projects
     `https://<project>.llvm.org/docs/CommandGuide/Foo.html`
 
+DOCX Output
+===========
+
+Building the DOCX files is similar to building the HTML documentation. The
+primary difference is to use the `docx` makefile target, instead of the
+default (which is `html`). Sphinx then produces the DOCX files in the
+directory `<build-dir>/docs/docx/`.
+
+    cd <build-dir>
+    cmake -DLLVM_ENABLE_SPHINX=true -DSPHINX_OUTPUT_DOCX=true <src-dir>
+    make -j3 docs-llvm-docx
+
+The correspondence between reStructuredText files and generated DOCX files is:
+
+LLVM project
+    `llvm/docs/index.rst` <-> `<build-dir>/docs/docx/LLVM.docx` <-> `<install-dir>/share/doc/llvm/LLVM.docx`
+
+Other projects
+    `<project>/docs/index.rst` <-> `<build-dir>/tools/<project>/docs/docx/<project>.docx` <-> `<install-dir>/share/doc/<project>/<project>.docx`
+
 Checking links
 ==============
 
Index: llvm/docs/Makefile.sphinx
===================================================================
--- llvm/docs/Makefile.sphinx
+++ llvm/docs/Makefile.sphinx
@@ -14,7 +14,7 @@
 # the i18n builder cannot share the environment and doctrees with the others
 I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
 
-.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext docx
 
 all:	html
 
@@ -34,6 +34,7 @@
 	@echo "  text       to make text files"
 	@echo "  man        to make manual pages"
 	@echo "  texinfo    to make Texinfo files"
+	@echo "  docx       to make DOCX files"
 	@echo "  info       to make Texinfo files and run them through makeinfo"
 	@echo "  gettext    to make PO message catalogs"
 	@echo "  changes    to make an overview of all changed/added/deprecated items"
@@ -127,6 +128,11 @@
 	@echo "Run \`make' in that directory to run these through makeinfo" \
 	      "(use \`make info' here to do that automatically)."
 
+docx:
+	$(SPHINXBUILD) -b docx $(ALLSPHINXOPTS) $(BUILDDIR)/docx
+	@echo
+	@echo "Build finished. The DOCX files are in $(BUILDDIR)/docx."
+
 info:
 	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
 	@echo "Running Texinfo files through makeinfo..."
Index: llvm/docs/CMakeLists.txt
===================================================================
--- llvm/docs/CMakeLists.txt
+++ llvm/docs/CMakeLists.txt
@@ -109,13 +109,16 @@
       add_sphinx_target(html llvm)
     endif()
 
-
     if (${SPHINX_OUTPUT_MAN})
       add_sphinx_target(man llvm)
       add_sphinx_target(man llvm-dwarfdump)
       add_sphinx_target(man dsymutil)
     endif()
 
+    if (${SPHINX_OUTPUT_DOCX})
+      add_sphinx_target(docx llvm)
+    endif()
+
   endif()
 endif()
 
Index: llvm/docs/CMake.rst
===================================================================
--- llvm/docs/CMake.rst
+++ llvm/docs/CMake.rst
@@ -482,8 +482,8 @@
 
 **LLVM_ENABLE_SPHINX**:BOOL
   If specified, CMake will search for the ``sphinx-build`` executable and will make
-  the ``SPHINX_OUTPUT_HTML`` and ``SPHINX_OUTPUT_MAN`` CMake options available.
-  Defaults to OFF.
+  the ``SPHINX_OUTPUT_HTML``, ``SPHINX_OUTPUT_MAN`` and ``SPHINX_OUTPUT_DOCX`` CMake options
+  available. Defaults to OFF.
 
 **LLVM_ENABLE_THREADS**:BOOL
   Build with threads support, if available. Defaults to ON.
@@ -507,8 +507,8 @@
   Defaults to ON.
 
 **LLVM_EXPERIMENTAL_TARGETS_TO_BUILD**:STRING
-  Semicolon-separated list of experimental targets to build and linked into 
-  llvm. This will build the experimental target without needing it to add to the 
+  Semicolon-separated list of experimental targets to build and linked into
+  llvm. This will build the experimental target without needing it to add to the
   list of all the targets available in the LLVM's main CMakeLists.txt.
 
 **LLVM_EXTERNAL_{CLANG,LLD,POLLY}_SOURCE_DIR**:PATH
@@ -570,6 +570,11 @@
   either be absolute or relative to the CMAKE_INSTALL_PREFIX. Defaults to
   `share/doc/llvm/html`.
 
+**LLVM_INSTALL_SPHINX_DOCX_DIR**:STRING
+  The path to install Sphinx-generated DOCX documentation to. This path can
+  either be absolute or relative to the CMAKE_INSTALL_PREFIX. Defaults to
+  `share/doc/llvm`.
+
 **LLVM_INSTALL_UTILS**:BOOL
   If enabled, utility binaries like ``FileCheck`` and ``not`` will be installed
   to CMAKE_INSTALL_PREFIX.
@@ -586,7 +591,7 @@
 
     $ D:\git> git clone https://github.com/mjansson/rpmalloc
     $ D:\llvm-project> cmake ... -DLLVM_INTEGRATED_CRT_ALLOC=D:\git\rpmalloc
-  
+
   This flag needs to be used along with the static CRT, ie. if building the
   Release target, add -DLLVM_USE_CRT_RELEASE=MT.
 
@@ -719,6 +724,13 @@
   is enabled). Currently the only target added is ``docs-llvm-man``. Defaults
   to ON.
 
+**SPHINX_OUTPUT_DOCX**:BOOL
+  If enabled (and ``LLVM_ENABLE_SPHINX`` is enabled) the targets for building
+  the DOCX files are added (but not built by default unless ``LLVM_BUILD_DOCS``
+  is enabled). Requires that the Sphinx DOCX builder is installed using ``pip
+  install docxbuilder``. Currently the only target added is ``docs-llvm-docx``.
+  Defaults to OFF.
+
 **SPHINX_WARNINGS_AS_ERRORS**:BOOL
   If enabled then sphinx documentation warnings will be treated as
   errors. Defaults to ON.
Index: llvm/cmake/modules/FindSphinx.cmake
===================================================================
--- llvm/cmake/modules/FindSphinx.cmake
+++ llvm/cmake/modules/FindSphinx.cmake
@@ -23,5 +23,6 @@
 # Provide options for controlling different types of output
 option(SPHINX_OUTPUT_HTML "Output standalone HTML files" ON)
 option(SPHINX_OUTPUT_MAN "Output man pages" ON)
+option(SPHINX_OUTPUT_DOCX "Output DOCX files" OFF)
 
 option(SPHINX_WARNINGS_AS_ERRORS "When building documentation treat warnings as errors" ON)
Index: llvm/cmake/modules/AddSphinxTarget.cmake
===================================================================
--- llvm/cmake/modules/AddSphinxTarget.cmake
+++ llvm/cmake/modules/AddSphinxTarget.cmake
@@ -101,6 +101,20 @@
                                    DEPENDS ${SPHINX_TARGET_NAME}
                                    COMPONENT "${project}-sphinx-html")
         endif()
+      elseif (builder STREQUAL docx)
+        string(TOUPPER "${project}" project_upper)
+        set(${project_upper}_INSTALL_SPHINX_DOCX_DIR "${CMAKE_INSTALL_DATADIR}/doc/${project}"
+            CACHE STRING "DOCX documentation install directory for ${project}")
+
+        install(DIRECTORY "${SPHINX_BUILD_DIR}/"  # Slash indicates contents of
+                COMPONENT "${project}-sphinx-docx"
+                DESTINATION "$CACHE{${project_upper}_INSTALL_SPHINX_DOCX_DIR}")
+
+        if(NOT LLVM_ENABLE_IDE)
+          add_llvm_install_targets("install-${SPHINX_TARGET_NAME}"
+                                   DEPENDS "${SPHINX_TARGET_NAME}"
+                                   COMPONENT "${project}-sphinx-docx")
+        endif()
       else()
         message(WARNING Installation of ${builder} not supported)
       endif()
Index: lldb/docs/resources/build.rst
===================================================================
--- lldb/docs/resources/build.rst
+++ lldb/docs/resources/build.rst
@@ -393,6 +393,7 @@
 
   > sudo apt-get install doxygen graphviz python3-sphinx
   > sudo pip install epydoc
+  > sudo pip install docxbuilder
 
 To build the documentation, configure with ``LLVM_ENABLE_SPHINX=ON`` and build the desired target(s).
 
@@ -400,6 +401,7 @@
 
   > ninja docs-lldb-html
   > ninja docs-lldb-man
+  > ninja docs-lldb-docx
   > ninja lldb-cpp-doc
   > ninja lldb-python-doc
 
Index: lldb/docs/conf.py
===================================================================
--- lldb/docs/conf.py
+++ lldb/docs/conf.py
@@ -44,6 +44,9 @@
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['sphinx.ext.todo', 'sphinx.ext.mathjax', 'sphinx.ext.intersphinx']
 
+if tags.has('builder-docx'):
+    extensions.append('docxbuilder')
+
 autodoc_default_options = {
     'special-members': '__int__, __len__, __hex__, __oct__, __iter__',
 }
Index: lldb/docs/CMakeLists.txt
===================================================================
--- lldb/docs/CMakeLists.txt
+++ lldb/docs/CMakeLists.txt
@@ -50,4 +50,9 @@
   if (${SPHINX_OUTPUT_MAN})
     add_sphinx_target(man lldb)
   endif()
+
+  if (${SPHINX_OUTPUT_DOCX})
+    add_sphinx_target(docx lldb)
+  endif()
+
 endif()
Index: lld/docs/sphinx_intro.rst
===================================================================
--- lld/docs/sphinx_intro.rst
+++ lld/docs/sphinx_intro.rst
@@ -52,6 +52,8 @@
     See the `setuptools <http://pypi.python.org/pypi/setuptools>`_ package web
     page for instructions.
 
+If building DOCX documentation, then the Sphinx DOCX builder must be installed
+using ``pip install docxbuilder``.
 
 .. _building_the_documentation:
 
Index: lld/docs/make.bat
===================================================================
--- lld/docs/make.bat
+++ lld/docs/make.bat
@@ -31,6 +31,7 @@
 	echo.  text       to make text files
 	echo.  man        to make manual pages
 	echo.  texinfo    to make Texinfo files
+	echo.  docx       to make DOCX files
 	echo.  gettext    to make PO message catalogs
 	echo.  changes    to make an overview over all changed/added/deprecated items
 	echo.  linkcheck  to check all external links for integrity
@@ -153,6 +154,14 @@
 	goto end
 )
 
+if "%1" == "docx" (
+	%SPHINXBUILD% -b docx %ALLSPHINXOPTS% %BUILDDIR%/docx
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The DOCX files are in %BUILDDIR%/docx.
+	goto end
+)
+
 if "%1" == "gettext" (
 	%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
 	if errorlevel 1 exit /b 1
Index: lld/docs/conf.py
===================================================================
--- lld/docs/conf.py
+++ lld/docs/conf.py
@@ -27,6 +27,9 @@
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['sphinx.ext.intersphinx', 'sphinx.ext.todo']
 
+if tags.has('builder-docx'):
+    extensions.append('docxbuilder')
+
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
 
Index: lld/docs/CMakeLists.txt
===================================================================
--- lld/docs/CMakeLists.txt
+++ lld/docs/CMakeLists.txt
@@ -4,5 +4,8 @@
     if (${SPHINX_OUTPUT_HTML})
       add_sphinx_target(html lld)
     endif()
+    if (${SPHINX_OUTPUT_DOCX})
+      add_sphinx_target(docx lld)
+    endif()
   endif()
 endif()
Index: libunwind/docs/conf.py
===================================================================
--- libunwind/docs/conf.py
+++ libunwind/docs/conf.py
@@ -27,6 +27,9 @@
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['sphinx.ext.intersphinx', 'sphinx.ext.todo']
 
+if tags.has('builder-docx'):
+    extensions.append('docxbuilder')
+
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
 
Index: libunwind/docs/CMakeLists.txt
===================================================================
--- libunwind/docs/CMakeLists.txt
+++ libunwind/docs/CMakeLists.txt
@@ -4,4 +4,7 @@
   if (${SPHINX_OUTPUT_HTML})
     add_sphinx_target(html libunwind)
   endif()
+  if (${SPHINX_OUTPUT_DOCX})
+    add_sphinx_target(docx libunwind)
+  endif()
 endif()
Index: libcxx/docs/conf.py
===================================================================
--- libcxx/docs/conf.py
+++ libcxx/docs/conf.py
@@ -27,6 +27,9 @@
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['sphinx.ext.intersphinx', 'sphinx.ext.todo']
 
+if tags.has('builder-docx'):
+    extensions.append('docxbuilder')
+
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
 
Index: libcxx/docs/Makefile.sphinx
===================================================================
--- libcxx/docs/Makefile.sphinx
+++ libcxx/docs/Makefile.sphinx
@@ -17,7 +17,7 @@
 # the i18n builder cannot share the environment and doctrees with the others
 I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
 
-.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext default
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man docx changes linkcheck doctest gettext default
 
 default: html
 
Index: libcxx/docs/CMakeLists.txt
===================================================================
--- libcxx/docs/CMakeLists.txt
+++ libcxx/docs/CMakeLists.txt
@@ -5,5 +5,8 @@
     if (${SPHINX_OUTPUT_HTML})
       add_sphinx_target(html libcxx)
     endif()
+    if (${SPHINX_OUTPUT_DOCX})
+      add_sphinx_target(docx libcxx)
+    endif()
   endif()
 endif()
Index: flang/docs/conf.py
===================================================================
--- flang/docs/conf.py
+++ flang/docs/conf.py
@@ -33,6 +33,9 @@
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['sphinx.ext.todo', 'sphinx.ext.mathjax', 'sphinx.ext.intersphinx']
 
+if tags.has('builder-docx'):
+    extensions.append('docxbuilder')
+
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
 
Index: flang/docs/CMakeLists.txt
===================================================================
--- flang/docs/CMakeLists.txt
+++ flang/docs/CMakeLists.txt
@@ -100,6 +100,9 @@
     if (${SPHINX_OUTPUT_MAN})
       add_sphinx_target(man flang)
     endif()
+    if (${SPHINX_OUTPUT_DOCX})
+      add_sphinx_target(docx flang)
+    endif()
   endif()
 endif()
 
Index: clang/docs/make.bat
===================================================================
--- clang/docs/make.bat
+++ clang/docs/make.bat
@@ -31,6 +31,7 @@
 	echo.  text       to make text files
 	echo.  man        to make manual pages
 	echo.  texinfo    to make Texinfo files
+	echo.  docx       to make DOCX files
 	echo.  gettext    to make PO message catalogs
 	echo.  changes    to make an overview over all changed/added/deprecated items
 	echo.  linkcheck  to check all external links for integrity
@@ -153,6 +154,14 @@
 	goto end
 )
 
+if "%1" == "docx" (
+	%SPHINXBUILD% -b docx %ALLSPHINXOPTS% %BUILDDIR%/docx
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The DOCX files are in %BUILDDIR%/docx.
+	goto end
+)
+
 if "%1" == "gettext" (
 	%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
 	if errorlevel 1 exit /b 1
Index: clang/docs/conf.py
===================================================================
--- clang/docs/conf.py
+++ clang/docs/conf.py
@@ -29,6 +29,9 @@
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['sphinx.ext.todo', 'sphinx.ext.mathjax']
 
+if tags.has('builder-docx'):
+    extensions.append('docxbuilder')
+
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
 
Index: clang/docs/analyzer/make.bat
===================================================================
--- clang/docs/analyzer/make.bat
+++ clang/docs/analyzer/make.bat
@@ -31,6 +31,7 @@
 	echo.  text       to make text files
 	echo.  man        to make manual pages
 	echo.  texinfo    to make Texinfo files
+	echo.  docx       to make DOCX files
 	echo.  gettext    to make PO message catalogs
 	echo.  changes    to make an overview over all changed/added/deprecated items
 	echo.  linkcheck  to check all external links for integrity
@@ -153,6 +154,14 @@
 	goto end
 )
 
+if "%1" == "docx" (
+	%SPHINXBUILD% -b docx %ALLSPHINXOPTS% %BUILDDIR%/docx
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The DOCX files are in %BUILDDIR%/docx.
+	goto end
+)
+
 if "%1" == "gettext" (
 	%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
 	if errorlevel 1 exit /b 1
Index: clang/docs/analyzer/conf.py
===================================================================
--- clang/docs/analyzer/conf.py
+++ clang/docs/analyzer/conf.py
@@ -28,6 +28,9 @@
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['sphinx.ext.todo', 'sphinx.ext.mathjax']
 
+if tags.has('builder-docx'):
+    extensions.append('docxbuilder')
+
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
 
Index: clang/docs/Makefile.sphinx
===================================================================
--- clang/docs/Makefile.sphinx
+++ clang/docs/Makefile.sphinx
@@ -34,6 +34,7 @@
 	@echo "  text       to make text files"
 	@echo "  man        to make manual pages"
 	@echo "  texinfo    to make Texinfo files"
+	@echo "  docx       to make DOCX files"
 	@echo "  info       to make Texinfo files and run them through makeinfo"
 	@echo "  gettext    to make PO message catalogs"
 	@echo "  changes    to make an overview of all changed/added/deprecated items"
@@ -135,6 +136,11 @@
 	@echo "Run \`make' in that directory to run these through makeinfo" \
 	      "(use \`make info' here to do that automatically)."
 
+docx:
+	$(SPHINXBUILD) -b docx $(ALLSPHINXOPTS) $(BUILDDIR)/docx
+	@echo
+	@echo "Build finished. The DOCX files are in $(BUILDDIR)/docx."
+
 info:
 	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
 	@echo "Running Texinfo files through makeinfo..."
Index: clang/docs/CMakeLists.txt
===================================================================
--- clang/docs/CMakeLists.txt
+++ clang/docs/CMakeLists.txt
@@ -137,5 +137,10 @@
       add_dependencies(docs-clang-man copy-clang-rst-docs)
     endif()
 
+    if (${SPHINX_OUTPUT_DOCX})
+      add_sphinx_target(docx clang SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+      add_dependencies(docs-clang-docx copy-clang-rst-docs)
+    endif()
+
   endif()
 endif()
Index: clang-tools-extra/docs/make.bat
===================================================================
--- clang-tools-extra/docs/make.bat
+++ clang-tools-extra/docs/make.bat
@@ -31,6 +31,7 @@
 	echo.  text       to make text files
 	echo.  man        to make manual pages
 	echo.  texinfo    to make Texinfo files
+	echo.  docx       to make DOCX files
 	echo.  gettext    to make PO message catalogs
 	echo.  changes    to make an overview over all changed/added/deprecated items
 	echo.  linkcheck  to check all external links for integrity
@@ -153,6 +154,14 @@
 	goto end
 )
 
+if "%1" == "docx" (
+	%SPHINXBUILD% -b docx %ALLSPHINXOPTS% %BUILDDIR%/docx
+	if errorlevel 1 exit /b 1
+	echo.
+	echo.Build finished. The DOCX files are in %BUILDDIR%/docx.
+	goto end
+)
+
 if "%1" == "gettext" (
 	%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
 	if errorlevel 1 exit /b 1
Index: clang-tools-extra/docs/conf.py
===================================================================
--- clang-tools-extra/docs/conf.py
+++ clang-tools-extra/docs/conf.py
@@ -28,6 +28,9 @@
 # coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
 extensions = ['sphinx.ext.todo', 'sphinx.ext.mathjax']
 
+if tags.has('builder-docx'):
+    extensions.append('docxbuilder')
+
 # Add any paths that contain templates here, relative to this directory.
 templates_path = ['_templates']
 
Index: clang-tools-extra/docs/CMakeLists.txt
===================================================================
--- clang-tools-extra/docs/CMakeLists.txt
+++ clang-tools-extra/docs/CMakeLists.txt
@@ -98,5 +98,8 @@
     if (${SPHINX_OUTPUT_MAN})
       add_sphinx_target(man clang-tools)
     endif()
+    if (${SPHINX_OUTPUT_DOCX})
+      add_sphinx_target(docx clang-tools)
+    endif()
   endif()
 endif()
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to