From 54c0dd605a6dade9e928ea53f556cf314b1fddc0 Mon Sep 17 00:00:00 2001
From: Abdussalam SALEH MGHIR <salehma@visu02.sis.cnes.fr>
Date: Thu, 7 Oct 2021 13:31:18 +0000
Subject: [PATCH] ENH : generate rst files in temporary repertory

---
 doc_cookbook/README.md            |  2 +-
 doc_cookbook/script_doc_sphinx.sh | 26 +++++++++++++++-----------
 2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/doc_cookbook/README.md b/doc_cookbook/README.md
index 0d5dca1..1b5a5da 100644
--- a/doc_cookbook/README.md
+++ b/doc_cookbook/README.md
@@ -2,7 +2,7 @@ To generate quickly the wiki, the process to follow is made up of multiple steps
 
 However, before it is executed, the module conda must be loaded and the environment sphinx and diapotb must be ready to be loaded.
 
-The environment sphinx can be created with the file .yml or we can follow the following steps:
+The environment sphinx can be created with the file doc_sphinx_wiki.yml or we can follow the following steps:
 ```shell
 conda create -n <name_env_sphinx> python=3.7.2
 conda activate <name_env_sphinx>
diff --git a/doc_cookbook/script_doc_sphinx.sh b/doc_cookbook/script_doc_sphinx.sh
index 0f82778..ea14322 100755
--- a/doc_cookbook/script_doc_sphinx.sh
+++ b/doc_cookbook/script_doc_sphinx.sh
@@ -10,28 +10,32 @@ fi
 
 # Path directory of the current script
 path_dir=$(dirname $0)
-# Creation if non existant of the repository used to generate the wiki
-mkdir -p $path_dir/rst_tmp
-# Copy of the C++ source files and the static files to the temporary repository from which will be generated the wiki
-cp -R $path_dir/rst/* $path_dir/rst_tmp
 # Generate the source files for the python scripts of the processing chains 
-sphinx-apidoc -f -o $path_dir/rst_API_Python/ $path_dir/../python_src/
+sphinx-apidoc -f -o $path_dir/rst_tmp/ $path_dir/../python_src/
 # Copy of the interesting source files to rst_tmp
 # Deletion of some lines uninteresting inside utils.rst
-line_submodule_utils_start=$(grep -wn 'Submodules' $path_dir/rst_API_Python/utils.rst | cut -d: -f1)
+line_submodule_utils_start=$(grep -wn 'Submodules' $path_dir/rst_tmp/utils.rst | cut -d: -f1)
 line_submodule_utils_end=$(($line_submodule_utils_start + 1))
-line_modcont_utils_start=$(grep -wn 'Module contents' $path_dir/rst_API_Python/utils.rst | cut -d: -f1)
+line_modcont_utils_start=$(grep -wn 'Module contents' $path_dir/rst_tmp/utils.rst | cut -d: -f1)
 line_modcont_utils_end=$(($line_modcont_utils_start + 6))
 # Copy of the modified utils.rst to rst_tmp
-sed "${line_submodule_utils_start},${line_submodule_utils_end}d;${line_modcont_utils_start},${line_modcont_utils_end}d" $path_dir/rst_API_Python/utils.rst > $path_dir/rst_tmp/PythonAPI/utils.rst
+sed "${line_submodule_utils_start},${line_submodule_utils_end}d;${line_modcont_utils_start},${line_modcont_utils_end}d" $path_dir/rst_tmp/utils.rst > $path_dir/rst_tmp/PythonAPI/utils.rst
 
 # Deletion of some lines uninteresting inside processings.rst
-line_submodule_processing_start=$(grep -wn 'Submodules' $path_dir/rst_API_Python/processings.rst | cut -d: -f1)
+line_submodule_processing_start=$(grep -wn 'Submodules' $path_dir/rst_tmp/processings.rst | cut -d: -f1)
 line_submodule_processing_end=$(($line_submodule_processing_start + 1))
-line_modcont_processing_start=$(grep -wn 'Module contents' $path_dir/rst_API_Python/processings.rst | cut -d: -f1)
+line_modcont_processing_start=$(grep -wn 'Module contents' $path_dir/rst_tmp/processings.rst | cut -d: -f1)
 line_modcont_processing_end=$(($line_modcont_processing_start + 6))
 # Copy of the modified processings.rst to rst_tmp
-sed "${line_submodule_processing_start},${line_submodule_processing_end}d;${line_modcont_processing_start},${line_modcont_processing_end}d" $path_dir/rst_API_Python/processings.rst > $path_dir/rst_tmp/PythonAPI/processings.rst
+sed "${line_submodule_processing_start},${line_submodule_processing_end}d;${line_modcont_processing_start},${line_modcont_processing_end}d" $path_dir/rst_tmp/processings.rst > $path_dir/rst_tmp/PythonAPI/processings.rst
+# Delete all th uninteresting rst files
+for file in $path_dir/rst_tmp/*.rst
+do
+  if [ -f $file ] && [ $file != "${path_dir}/rst_tmp/Applications.rst" ]
+  then
+    rm $file
+  fi
+done
 # Generate the wiki repository from the source repository
 sphinx-build -M markdown $path_dir/rst_tmp/ $wiki_output_path/diapotb_wiki/ -c $path_dir
 #sphinx-build -b html $path_dir/rst_tmp/ $wiki_output_path/diapotb_wiki_html/ -c $path_dir
-- 
GitLab