summaryrefslogtreecommitdiff
path: root/solenv
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2017-05-19 20:41:08 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2017-05-19 20:43:52 -0400
commit78315e1da16da0466a8b5d564c63142b6b99f5b8 (patch)
treeb966a51e41c9d67cca6425a75dcebf837740822c /solenv
parent07381c017cd2b4e3ce643d17ae7cbb11ddef2228 (diff)
Support markdown format for module README file.
Now you can author a module README file in markdown format. To distinguish it from the existing format, you need to save it as README.md then it'll be treated as a markdown file. Change-Id: Iebf3ae32608d348768b2da7157d122954a7b72f7
Diffstat (limited to 'solenv')
-rwxr-xr-xsolenv/bin/mkdocs.sh46
1 files changed, 36 insertions, 10 deletions
diff --git a/solenv/bin/mkdocs.sh b/solenv/bin/mkdocs.sh
index 84b137900470..cd2a33f6d485 100755
--- a/solenv/bin/mkdocs.sh
+++ b/solenv/bin/mkdocs.sh
@@ -84,6 +84,21 @@ function proc_text {
| awk 'BEGIN { print "<p>" } { print } END { print "</p>" }'
}
+function proc_text_markdown {
+ sed -re ' s/\[\[([-_a-zA-Z0-9]+)\]\]/<a href="\1.html">\1<\/a>/g' - \
+ | sed -re ' s/\[git:([^]]+)\]/<a href="http:\/\/cgit.freedesktop.org\/libreoffice\/core\/tree\/\1">\1<\/a>/g'
+}
+
+function check_cmd {
+ cmd_needed="$1"
+ error_msg="$2"
+
+ which $cmd_needed > /dev/null 2>&1 || {
+ echo "$error_msg" >&2
+ exit 1
+ }
+}
+
function setup {
parm=$1
if [ -z "${!parm}" ] ; then
@@ -98,14 +113,9 @@ function setup {
}
# binaries that we need
-which doxygen > /dev/null 2>&1 || {
- echo "You need doxygen for doc generation" >&2
- exit 1
-}
-which dot > /dev/null 2>&1 || {
- echo "You need the graphviz tools to create the nice inheritance graphs" >&2
- exit 1
-}
+check_cmd doxygen "You need doxygen for doc generation"
+check_cmd dot "You need the graphviz tools to create the nice inheritance graphs"
+check_cmd markdown "You need markdown in order to convert README.md into html"
# suck setup
setup "SOLARINC"
@@ -212,7 +222,15 @@ for module_name in *; do
if [ -f "$cur_file" ]; then
# write index.html entry
text="<h2><a href=\"${module_name}.html\">${module_name}</a></h2>\n"
- text="${text}$(head -n1 $cur_file | proc_text )"
+
+ 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
@@ -224,13 +242,21 @@ for module_name in *; do
fi
text="${text} </p><p>&nbsp;</p>"
echo -e $text >> "$BASE_OUTPUT/${module_name}.html"
- proc_text < $cur_file >> "$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"
+ else
+ proc_text < $cur_file >> "$BASE_OUTPUT/${module_name}.html"
+ fi
footer "$BASE_OUTPUT/${module_name}.html"
else
empty_modules[${#empty_modules[*]}]=$module_name
fi
fi
done
+
if [ ${#empty_modules[*]} -gt 0 ]; then
echo -e "<p>&nbsp;</p><p>READMEs were not available for these modules:</p><ul>\n" >> "$BASE_OUTPUT/index.html"
for module_name in "${empty_modules[@]}"; do