#!/bin/bash

if [ $0 != "doc/README" ]; then
   echo "$0:  this should be run from one level up (in src/)."
   exit 1
fi

#This directory contains some of the source for the Doxygen documentation (the
#code itself, and its comments, is the rest of the source).  Doxygen will create
#the actual documentation in ../html/ (e.g. open ../html/index.html in a browser).
#To run doxygen, type "doxygen" from one directory above this.  If this does
#not work, search for "Kaldi main page" online and you will hopefully get a
#version of the documentation.

# Note: I generally run this file by typing "doc/README" from src/,
# but this relies on having dsa encryption set up  with Sourceforge.
# instructions (from Vassil Panayotov) on how to do this:
# type
#ssh-keygen -t dsa -C "vpanayotov@shell.sf.net"
#ssh-add
# end then import the contents of .ssh/id_dsa.pub into
# http://sourceforge.net/account/services

#(from Dan:) The commands below show how I compile the documentation and copy it
#to the homepage at sourceforge.  I do this from JHU at the current time.

# cd to src/
doc/make_tools.sh

echo "$0: running doc/get_version_info.sh"
doc/get_version_info.sh
echo "$0: done"


rm -r html
doxygen
cp doc/*.pptx html/;
# get the style sheet in the html/ directory.
# note, we actually use a modified version of the header, which is checked into
# doc/.
doxygen -w html header.html footer.html stylesheet.css
rm header.html footer.html
mv stylesheet.css html/

if [[ $(hostname -f) == *.clsp.jhu.edu ]]; then
   cp ../misc/logo/KaldiIco.png html/favicon.ico
   tar -czf html.tar.gz html

   # Copy to kaldi-asr.org/docs2/
   scp html.tar.gz newrelay:/var/www/kaldi-asr

   echo 'cd /var/www/kaldi-asr/; rm -rf html doc.old;
        tar -xzf html.tar.gz; mv doc doc.old; mv html doc; rm -rf doc.old; rm html.tar.gz' \
           | ssh newrelay bash
fi


# You could uncomment and run the lines below as an example of how to figure out
# the amount of posts to the Kaldi forums on Sourceforge, per month.
#curl 'http://sourceforge.net/p/kaldi/discussion/stats_data?forum=&begin=2011-04-14&end=2014-06-13'  > foo
#cat foo |  perl -ane ' s/.*://; @A = split("]");
#   foreach $a(@A){ $a =~ s/[,\[]//g; print "$a\n"; }' | \
# perl -e 'while(<>) { @A = split; if (@A == 2) { ($date, $count) = @A;  $date /= 1000;
#  @date_array = gmtime $date; $month = $date_array[4]; $year = 1900 + $date_array[5]; $count{$year. " " .sprintf("%02d", $month+1)} +=  $count; }}
#  foreach $k (sort keys %count) { print "$k $count{$k}\n"; } '

# I added figures that I manually excerpted from https://sourceforge.net/p/kaldi/mailman/kaldi-users/?viewmonth=201203
# and https://sourceforge.net/p/kaldi/mailman/kaldi-developers/?viewmonth=201203
# this is june 13, 2014, 6:11pm, check my email.

# Note (RE adding favicon): I generated the default header files like this (from
# src/) doxygen -w html header.html footer.html stylesheet.css Doxyfile then
# moved the header.html to doc/ and edited it to include the following snippet,
# and added it to the repo.
#<link rel="icon" type="image/png" href="http://kaldi.sf.net/favicon.ico">
