|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +if [ $# != 1 ]; then |
| 4 | + echo "Usage: $0 <output_dir>" |
| 5 | + exit 1; |
| 6 | +fi |
| 7 | + |
| 8 | +output_dir=$1 |
| 9 | +if [ ! -d $output_dir ]; then |
| 10 | + echo $output_dir is not a directory |
| 11 | + exit 1; |
| 12 | +fi |
| 13 | + |
| 14 | +index_file=$output_dir/index.html; |
| 15 | + |
| 16 | +echo "Output dir: $output_dir"; |
| 17 | +echo "Index file: $index_file"; |
| 18 | + |
| 19 | +cat << 'EOF' > $index_file |
| 20 | +<html> |
| 21 | +<head> |
| 22 | +<title>Plugin config files for the Open Lighting Architecture</title> |
| 23 | +</head> |
| 24 | +<body> |
| 25 | +<h1>Plugin config files for the <a href="https://openlighting.org/ola/">Open Lighting Architecture</a></h1> |
| 26 | +<ul> |
| 27 | +EOF |
| 28 | + |
| 29 | +config_prefix=$(grep ::OLA_CONFIG_PREFIX ../olad/plugin_api/Preferences.cpp | sed -e 's/const char FileBackedPreferences::OLA_CONFIG_PREFIX\[\] = "//' -e 's/";$//'); |
| 30 | +echo "Config prefix: $config_prefix"; |
| 31 | +config_suffix=$(grep ::OLA_CONFIG_SUFFIX ../olad/plugin_api/Preferences.cpp | sed -e 's/const char FileBackedPreferences::OLA_CONFIG_SUFFIX\[\] = "//' -e 's/";$//'); |
| 32 | +echo "Config suffix: $config_suffix"; |
| 33 | + |
| 34 | +for readme_file in */README.md; do |
| 35 | + echo "Generating from $readme_file"; |
| 36 | + plugin_dir=$(dirname $readme_file); |
| 37 | + echo "Plugin dir: $plugin_dir"; |
| 38 | + plugin_name=$(grep ::PLUGIN_NAME $plugin_dir/*Plugin.cpp | sed -e 's/const char .*Plugin::PLUGIN_NAME\[\] = "//' -e 's/";$//'); |
| 39 | + echo "Plugin name: $plugin_name"; |
| 40 | + plugin_prefix=$(grep ::PLUGIN_PREFIX $plugin_dir/*Plugin.cpp | sed -e 's/const char .*Plugin::PLUGIN_PREFIX\[\] = "//' -e 's/";$//'); |
| 41 | + echo "Plugin prefix: $plugin_prefix"; |
| 42 | + config_file=$config_prefix$plugin_prefix$config_suffix; |
| 43 | + output_file=$output_dir/$config_file.html; |
| 44 | + page_title="$plugin_name Plugin ($config_file)"; |
| 45 | + echo "Config file: $config_file"; |
| 46 | + pandoc -f markdown_github -t html -s $plugin_dir/README.md -B pandoc-html-index.html -A pandoc-html-index.html -o $output_file -T "$page_title" |
| 47 | + sed -i -e 's/ – <\/title>/<\/title>/' $output_file |
| 48 | + chmod a+r $output_file; |
| 49 | + echo "<li><a href='./$config_file.html'>$page_title</a></li>" >> $index_file |
| 50 | +done |
| 51 | + |
| 52 | +cat << 'EOF' >> $index_file |
| 53 | +</ul> |
| 54 | +</body> |
| 55 | +</html> |
| 56 | +EOF |
0 commit comments