docs: Divorcing tools for the main and docs build

Change-Id: Ica15c40b54cde1cf0ae365ed80c38d2f086f6b2f
Signed-off-by: Anton Komlev <anton.komlev@arm.com>
diff --git a/cmake/Common/Utils.cmake b/cmake/Common/Utils.cmake
deleted file mode 100644
index 452d0bf..0000000
--- a/cmake/Common/Utils.cmake
+++ /dev/null
@@ -1,105 +0,0 @@
-#-------------------------------------------------------------------------------
-# Copyright (c) 2017-2019, Arm Limited. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-3-Clause
-#
-#-------------------------------------------------------------------------------
-
-
-#Print a message and exit with failure
-#
-#Examples:
-#   failure("Something is wrong!")
-
-function(failure)
-	message(FATAL_ERROR "${ARGN}")
-endfunction()
-
-#Append a value to a string if not already present
-#
-#Append an item to a string if no item with matching key is already on the string.
-#This function's intended purpose is to append unique flags to command line switches.
-#
-#Examples:
-#   string_append_unique_item(STRING C_FLAGS KEY "--target" VAL "--target=armv8m-arm-none-eabi")
-#
-#INPUTS:
-#   STRING  - (mandatory) - name of the string to operate on
-#   KEY     - (mandatory) - string to look for
-#   VAL     - (mandatory) - value to put be added to the string
-#
-#OUTPUTS
-#   STRING is modified as needed.
-#
-function(string_append_unique_item)
-	#Parse our arguments
-	set( _OPTIONS_ARGS )                    #No option (on/off) arguments (e.g. IGNORE_CASE)
-	set( _ONE_VALUE_ARGS  STRING KEY VAL)   #Single option arguments (e.g. PATH "./foo/bar")
-	set( _MULTI_VALUE_ARGS )                #List arguments (e.g. LANGUAGES C ASM CXX)
-	cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} )
-
-	#Check mandatory parameters
-	if(NOT _MY_PARAMS_STRING)
-		failure("string_append_unique_item(): Missing STRING parameter!")
-	endif()
-	set(_STRING ${_MY_PARAMS_STRING})
-
-	if(NOT _MY_PARAMS_KEY)
-		failure("string_append_unique_item(): Missing KEY parameter!")
-	endif()
-	set(_KEY ${_MY_PARAMS_KEY})
-
-	if(NOT _MY_PARAMS_VAL)
-		failure("string_append_unique_item(): Missing VAL parameter!")
-	endif()
-	set(_VAL ${_MY_PARAMS_VAL})
-
-	#Scan the string.
-	STRING(REGEX MATCH "( |^) *${_KEY}" _FOUND "${${_STRING}}")
-	if("${_FOUND}" STREQUAL "")
-		set(${_STRING} "${${_STRING}}  ${_VAL}" PARENT_SCOPE)
-	endif()
-endfunction()
-
-
-#Convert \ directory separators to / on windows systems
-#
-#Convert the directory separators to forward slash on windows. Avoid
-#conversion if path contains any forward slashes to avoid mixing up cygwin or
-#mingw paths where an extra caharacter is escaped (i.e. "/c/Program\ Files/")
-#
-#Examples:
-#   set(MY_PATH "C:\foo\bar")
-#   win_fix_dir_sep(PATH MY_PATH)
-#
-#INPUTS:
-#   PATH  - (mandatory) - name of the string variable to operate on
-#
-#OUTPUTS
-#   PATH is modified as needed.
-#
-function(win_fix_dir_sep)
-	#Parse our arguments
-	set( _OPTIONS_ARGS )            #No option (on/off) arguments (e.g. IGNORE_CASE)
-	set( _ONE_VALUE_ARGS  PATH )    #Single option arguments (e.g. PATH "./foo/bar")
-	set( _MULTI_VALUE_ARGS )        #List arguments (e.g. LANGUAGES C ASM CXX)
-	cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} )
-
-	#Check mandatory parameters
-	if(NOT _MY_PARAMS_PATH)
-		failure("win_fix_dir_sep(): Missing mandatory parameter PATH!")
-	endif()
-	set(_PATH ${_MY_PARAMS_PATH})
-
-	#To avoid trouble on windows change directory separator.
-	if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
-		#Do not convert directory separator if there are forward slashes
-		#present. This is to avoid mixing up escaped characters in cygwin
-		#or mingw paths (i.e. c:/Program\ Files/something)
-		string(FIND "${${_PATH}}" "/" _is_found)
-		if (_is_found LESS 0)
-			string(REPLACE "\\" "/" ${_PATH} "${${_PATH}}")
-			set(${_PATH} "${${_PATH}}" PARENT_SCOPE)
-		endif()
-	endif()
-endfunction()
diff --git a/docs/CMakeLists.txt b/docs/CMakeLists.txt
index f1a2b2d..b17780a 100644
--- a/docs/CMakeLists.txt
+++ b/docs/CMakeLists.txt
@@ -9,7 +9,7 @@
 
 add_custom_target(docs)
 
-list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/../cmake)
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
 
 find_package(Python3)
 find_package(Sphinx)
diff --git a/cmake/FindPlantUML.cmake b/docs/cmake/FindPlantUML.cmake
similarity index 98%
rename from cmake/FindPlantUML.cmake
rename to docs/cmake/FindPlantUML.cmake
index f6ad027..82df16c 100644
--- a/cmake/FindPlantUML.cmake
+++ b/docs/cmake/FindPlantUML.cmake
@@ -31,7 +31,7 @@
 #   PLANTUML_FOUND          = Was the .jar file found and sucesfuly executed.
 #
 
-include(Common/Utils)
+include(Utils)
 
 find_package(Java 1.8 COMPONENTS Runtime)
 if(Java_Runtime_FOUND)
diff --git a/cmake/FindPythonModules.cmake b/docs/cmake/FindPythonModules.cmake
similarity index 98%
rename from cmake/FindPythonModules.cmake
rename to docs/cmake/FindPythonModules.cmake
index bb8d4fb..6f889c6 100644
--- a/cmake/FindPythonModules.cmake
+++ b/docs/cmake/FindPythonModules.cmake
@@ -36,7 +36,7 @@
 	message(FATAL_ERROR "FindPythonModules: mandatory parameter PYTHON_EXECUTABLE is missing.")
 endif()
 
-include(Common/Utils)
+include(Utils)
 
 foreach(_mod ${PythonModules_FIND_COMPONENTS})
 	string(TOUPPER ${_mod} _mod_upper)
diff --git a/cmake/FindSphinx.cmake b/docs/cmake/FindSphinx.cmake
similarity index 100%
rename from cmake/FindSphinx.cmake
rename to docs/cmake/FindSphinx.cmake
diff --git a/docs/cmake/Utils.cmake b/docs/cmake/Utils.cmake
new file mode 100644
index 0000000..f422895
--- /dev/null
+++ b/docs/cmake/Utils.cmake
@@ -0,0 +1,58 @@
+#-------------------------------------------------------------------------------
+# Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+#-------------------------------------------------------------------------------
+
+
+#Print a message and exit with failure
+#
+#Examples:
+#   failure("Something is wrong!")
+
+function(failure)
+	message(FATAL_ERROR "${ARGN}")
+endfunction()
+
+#Convert \ directory separators to / on windows systems
+#
+#Convert the directory separators to forward slash on windows. Avoid
+#conversion if path contains any forward slashes to avoid mixing up cygwin or
+#mingw paths where an extra caharacter is escaped (i.e. "/c/Program\ Files/")
+#
+#Examples:
+#   set(MY_PATH "C:\foo\bar")
+#   win_fix_dir_sep(PATH MY_PATH)
+#
+#INPUTS:
+#   PATH  - (mandatory) - name of the string variable to operate on
+#
+#OUTPUTS
+#   PATH is modified as needed.
+#
+function(win_fix_dir_sep)
+	#Parse our arguments
+	set( _OPTIONS_ARGS )            #No option (on/off) arguments (e.g. IGNORE_CASE)
+	set( _ONE_VALUE_ARGS  PATH )    #Single option arguments (e.g. PATH "./foo/bar")
+	set( _MULTI_VALUE_ARGS )        #List arguments (e.g. LANGUAGES C ASM CXX)
+	cmake_parse_arguments(_MY_PARAMS "${_OPTIONS_ARGS}" "${_ONE_VALUE_ARGS}" "${_MULTI_VALUE_ARGS}" ${ARGN} )
+
+	#Check mandatory parameters
+	if(NOT _MY_PARAMS_PATH)
+		failure("win_fix_dir_sep(): Missing mandatory parameter PATH!")
+	endif()
+	set(_PATH ${_MY_PARAMS_PATH})
+
+	#To avoid trouble on windows change directory separator.
+	if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
+		#Do not convert directory separator if there are forward slashes
+		#present. This is to avoid mixing up escaped characters in cygwin
+		#or mingw paths (i.e. c:/Program\ Files/something)
+		string(FIND "${${_PATH}}" "/" _is_found)
+		if (_is_found LESS 0)
+			string(REPLACE "\\" "/" ${_PATH} "${${_PATH}}")
+			set(${_PATH} "${${_PATH}}" PARENT_SCOPE)
+		endif()
+	endif()
+endfunction()
diff --git a/docs/technical_references/instructions/documentation_generation.rst b/docs/technical_references/instructions/documentation_generation.rst
index 72e7e55..b8bd9ca 100644
--- a/docs/technical_references/instructions/documentation_generation.rst
+++ b/docs/technical_references/instructions/documentation_generation.rst
@@ -39,6 +39,11 @@
             # For PDF generation
             sudo apt-get install -y doxygen-latex
 
+            # Additional Python dependencies for documentation
+            pip3 install --upgrade pip
+            cd trusted-firmware-m
+            pip3 install -r tools/requirements_docs.txt
+
         2. Currently, there are two ways of building TF-M reference manual:
 
             - Using the CMake build system as custom targets
@@ -93,6 +98,11 @@
 
         .. code-block:: bash
 
+            # Additional Python dependencies for documentation
+            pip3 install --upgrade pip
+            cd trusted-firmware-m
+            pip3 install -r tools\requirements_docs.txt
+
             set PLANTUML_JAR_PATH=<plantuml_Path>\plantuml.jar
             set PATH=$PATH;<ARM_DS_PATH>\sw\java\bin
 
diff --git a/tools/requirements.txt b/tools/requirements.txt
index 89c8c64..993dbc0 100644
--- a/tools/requirements.txt
+++ b/tools/requirements.txt
@@ -2,15 +2,6 @@
 click
 cryptography
 pyasn1
-graphviz
 imgtool>=1.6.0
 Jinja2>=2.10.3
-latex
 PyYAML
-Sphinx==2.0.1
-m2r
-sphinx-rtd-theme
-sphinxcontrib-plantuml
-sphinxcontrib-svg2pdfconverter
-sphinx-tabs
-docutils==0.16
diff --git a/tools/requirements_docs.txt b/tools/requirements_docs.txt
new file mode 100644
index 0000000..762208e
--- /dev/null
+++ b/tools/requirements_docs.txt
@@ -0,0 +1,10 @@
+graphviz
+Jinja2>=2.10.3
+latex
+Sphinx==2.0.1
+m2r
+sphinx-rtd-theme
+sphinxcontrib-plantuml
+sphinxcontrib-svg2pdfconverter
+sphinx-tabs==1.1.13
+docutils==0.16