diff options
-rw-r--r-- | Documentation/sphinx/convert_template.sed | 15 | ||||
-rw-r--r-- | Documentation/sphinx/post_convert.sed | 7 | ||||
-rw-r--r-- | Documentation/sphinx/tmplcvt | 16 |
3 files changed, 38 insertions, 0 deletions
diff --git a/Documentation/sphinx/convert_template.sed b/Documentation/sphinx/convert_template.sed new file mode 100644 index 000000000000..fbf3b2828544 --- /dev/null +++ b/Documentation/sphinx/convert_template.sed @@ -0,0 +1,15 @@ +# +# Pandoc doesn't grok <function> or <structname>, so convert them +# ahead of time. +# +# Use "$bq" instead of "`" so that pandoc won't mess with it. +# +s%<function>\([^<(]\+\)()</function>%:c:func:$bq\1$bq%g +s%<function>\([^<(]\+\)</function>%:c:func:$bq\1$bq%g +s%<structname>struct *\([^<]\+\)</structname>%:ref:$bqstruct \1$bq%g +s%<structname>\([^<]\+\)</structname>%:ref:$bqstruct \1$bq%g +# +# If we put paragraph markers between docproc directives hopefully pandoc +# won't mess with them. +# +s%^\(!.*\)$%<para>\1</para>% diff --git a/Documentation/sphinx/post_convert.sed b/Documentation/sphinx/post_convert.sed new file mode 100644 index 000000000000..d5443ad5be74 --- /dev/null +++ b/Documentation/sphinx/post_convert.sed @@ -0,0 +1,7 @@ +# +# pandoc thinks that both "_" needs to be escaped. Remove the extra +# backslashes. Also put in proper backquotes now that pandoc won't quote +# them. +# +s/$bq/`/g +s/\\_/_/g diff --git a/Documentation/sphinx/tmplcvt b/Documentation/sphinx/tmplcvt new file mode 100644 index 000000000000..b3b85f67497b --- /dev/null +++ b/Documentation/sphinx/tmplcvt @@ -0,0 +1,16 @@ +#!/bin/bash +# +# Convert a template file into something like RST +# +# fix <function> +# feed to pandoc +# fix \_ +# title line? +# +tmp=${1/tmpl/rst_tmp} +rst=${1/tmpl/rtmpl} +cp ../DocBook/$1 $tmp +sed --in-place -f convert_template.sed $tmp +pandoc -s -S -f docbook -t rst -o $rst $tmp +sed --in-place -f post_convert.sed $rst +rm $tmp |