From 80fbc9c49fd23fcf1900fe12ebdc6f43f8db7b7f Mon Sep 17 00:00:00 2001 From: Hossein Date: Wed, 7 Apr 2021 23:47:21 +0430 Subject: [PATCH] Fix problems with LibreOffice document generation (local and portal) * Fixed problems with LibreOffice local document generation script (mkdocs.sh) by interpreting backslash escapes when generating module links using "echo -e" and using double quotes around Markdown generated text. The result is placed at docs/ folder. * Fixed problems with LibreOffice portal document generation script (mkdocs_portal.sh and mkonedoc.sh) by doing above fixes and also adding code from the local document generation script. The result is placed at https://docs.libreoffice.org/ * Only the README.md files are processed, and not README* or readme.txt* * Fixed redmine #3515 "Remove non-necessary subfolders from docs.libreoffice.org" by excluding these 10 folders: "autom4te.cache dictionaries docs helpcompiler helpcontent2 include instdir lo translations workdir" Change-Id: Id230872b8583a575bfeb6fc77cc9f96d5982908f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113773 Tested-by: Jenkins Reviewed-by: Thorsten Behrens --- solenv/bin/mkdocs.sh | 19 +++++++++------- solenv/bin/mkdocs_portal.sh | 44 ++++++++++++++++++++++++++----------- 2 files changed, 42 insertions(+), 21 deletions(-) diff --git a/solenv/bin/mkdocs.sh b/solenv/bin/mkdocs.sh index 0f92ff87e532..4b70787787e8 100755 --- a/solenv/bin/mkdocs.sh +++ b/solenv/bin/mkdocs.sh @@ -85,8 +85,7 @@ function proc_text { } function proc_text_markdown { - sed -re ' s/\[\[([-_a-zA-Z0-9]+)\]\]/\1<\/a>/g' - \ - | sed -re ' s/\[git:([^]]+)\]/\1<\/a>/g' + sed -re ' s/\[git:([^]]+)\]/\1<\/a>/g' } function check_cmd { @@ -226,10 +225,10 @@ echo "generating index page" header "LibreOffice Modules" " " "$BASE_OUTPUT/index.html" for module_name in *; do if [ -d $module_name ]; then - cur_file=$(echo $module_name/README* $module_name/readme.txt*) + cur_file=$(echo $module_name/README.md) if [ -f "$cur_file" ]; then # write index.html entry - text="

${module_name}

\n" + text=$(echo -e "

${module_name}

\n") if [ ${cur_file: -3} == ".md" ]; then # This is a markdown file. @@ -239,7 +238,7 @@ for module_name in *; do else text="${text}$(head -n1 $cur_file | proc_text)" fi - echo -e $text >> "$BASE_OUTPUT/index.html" + echo -e "$text" >> "$BASE_OUTPUT/index.html" # write detailed module content header "$module_name" "LibreOffice » ${module_name}" "$BASE_OUTPUT/${module_name}.html" @@ -249,12 +248,12 @@ for module_name in *; do text="${text}   Doxygen" fi text="${text}

 

" - echo -e $text >> "$BASE_OUTPUT/${module_name}.html" + echo -e "$text" >> "$BASE_OUTPUT/${module_name}.html" if [ ${cur_file: -3} == ".md" ]; then # This is a markdown file. text="$(${markdown} $cur_file | proc_text_markdown)" - echo $text >> "$BASE_OUTPUT/${module_name}.html" + echo -e "$text" >> "$BASE_OUTPUT/${module_name}.html" else proc_text < $cur_file >> "$BASE_OUTPUT/${module_name}.html" fi @@ -265,9 +264,13 @@ for module_name in *; do fi done -if [ ${#empty_modules[*]} -gt 0 ]; then +if [ ${#empty_modules[*]} -gt 10 ]; then echo -e "

 

READMEs were not available for these modules:

\n" >> "$BASE_OUTPUT/index.html" diff --git a/solenv/bin/mkdocs_portal.sh b/solenv/bin/mkdocs_portal.sh index 852e3448179d..284af9e741f5 100755 --- a/solenv/bin/mkdocs_portal.sh +++ b/solenv/bin/mkdocs_portal.sh @@ -4,6 +4,7 @@ if [ -n "$debug" ] ; then set -x fi +markdown="markdown" SRCDIR="$1" BASE_OUTPUT="$2" @@ -88,6 +89,10 @@ function proc_text | awk 'BEGIN { print "

" } { print } END { print "

" }' } +function proc_text_markdown { + sed -re ' s/\[git:([^]]+)\]/\1<\/a>/g' +} + # generate entry page echo "generating index page" @@ -95,28 +100,37 @@ header "LibreOffice Modules" " " "$BASE_OUTPUT/index.html" for module_name in *; do if [ -d $module_name ]; then - cur_file= - if [ -f $module_name/readme.txt ] ; then - cur_file="$module_name/readme.txt" - elif [ -f $module_name/README ] ; then - cur_file="$module_name/README" - fi - if [ -n "$cur_file" ]; then + cur_file=$(echo $module_name/README.md) + if [ -f "$cur_file" ]; then # write index.html entry - text="

${module_name}

\n" - text="${text}$(head -n1 $cur_file | proc_text )" - echo -e $text >> "$BASE_OUTPUT/index.html" + text=$(echo -e "

${module_name}

\n") + if [ ${cur_file: -3} == ".md" ]; then + # This is a markdown file. + header_text="$(head -n1 $cur_file)" + header_text="$(echo ${header_text} | sed -e 's/^\#*//g')" + text="${text}${header_text}" + else + text="${text}$(head -n1 $cur_file | proc_text)" + fi + echo -e "$text" >> "$BASE_OUTPUT/index.html" # write detailed module content header "$module_name" "LibreOffice » ${module_name}" "$BASE_OUTPUT/${module_name}.html" text="

View module in:" text="${text}   cgit" - if [ -d ./docs/${module_name} ] ; then + if $(echo $INPUT_PROJECTS | grep -q $module_name); then text="${text}   Doxygen" fi text="${text}

 

" - echo -e $text >> "$BASE_OUTPUT/${module_name}.html" + echo -e "$text" >> "$BASE_OUTPUT/${module_name}.html" + + if [ ${cur_file: -3} == ".md" ]; then + # This is a markdown file. + text="$(${markdown} $cur_file | proc_text_markdown)" + echo -e "$text" >> "$BASE_OUTPUT/${module_name}.html" + else proc_text < $cur_file >> "$BASE_OUTPUT/${module_name}.html" + fi footer "$BASE_OUTPUT/${module_name}.html" else empty_modules[${#empty_modules[*]}]=$module_name @@ -124,9 +138,13 @@ for module_name in *; do fi done -if [ ${#empty_modules[*]} -gt 0 ]; then +if [ ${#empty_modules[*]} -gt 10 ]; then echo -e "

 

READMEs were not available for these modules:

\n" >> "$BASE_OUTPUT/index.html"