-
Notifications
You must be signed in to change notification settings - Fork 25
/
doc_usage.sh
executable file
·99 lines (77 loc) · 3.05 KB
/
doc_usage.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
#
# Documents usage screens (generated with the -H option) for all of
# the projects hosted by the repo --- Synoptic, CSight, InvariMint,
# Perfume. These are written to wiki pages (e.g.,
# 'DocsSynopticCmdLineHelpScreen') and can be found online, e.g.,:
# https://github.com/ModelInference/synoptic/wiki
#
# This script must be run manually, and will only work if executed
# from within the default synoptic code branch. This script assume
# that the working copy is at the tip.
#
# Preferably this script will be run whenever command line options
# change.
#
if [ -z "$1" ]
then
echo "Usage: ./doc_usage.sh [wiki-path]"
echo " wiki-path : path of local working copy of the wiki hg repository"
exit
fi
# Assumes that the current dir is the synoptic repo.
code_repo=`pwd`
# First argument is the location of the Synoptic wiki repo.
wiki_repo=$1
# 1. Pull and update the wiki repository
cd ${wiki_repo} && git checkout master && git pull
###########################################################
function gen_wiki_page() {
local usagef=$1
local cmd=$2
local prj=$3
local escapeName=$4
# 2. Wipe out the old usage wiki page.
cd ${wiki_repo} && rm $usagef
# 3. Generate the new wiki page
if [ "$escapeName" = true ]; then
echo "# !$prj Command Line Options #" >> $usagef
else
echo "# $prj Command Line Options #" >> $usagef
fi
echo '```' >> $usagef
cd ${code_repo} && $cmd >> $usagef
echo '```' >> $usagef
echo >> $usagef
# 4. Determine the current revision for the synoptic repository
# (assumed to be the current dir)
echo "As of revision: " >> $usagef
cd ${code_repo} && git log -n 1 origin/master --pretty=format:"%H" >> $usagef
echo >> $usagef
echo >> $usagef
echo "**Note: this page is auto-generated. Do not edit.**" >> $usagef
}
###########################################################
# Location of the usage screen wiki pages.
syn_usagef=${wiki_repo}/DocsSynopticCmdLineHelpScreen.md
dyn_usagef=${wiki_repo}/DocsCSightCmdLineHelpScreen.md
invmint_usagef=${wiki_repo}/DocsInvariMintCmdLineHelpScreen.md
perfume_usagef=${wiki_repo}/DocsPerfumeCmdLineHelpScreen.md
############################## Synoptic usage
# Generate the synoptic usage:
gen_wiki_page $syn_usagef "./synoptic.sh -H" "Synoptic" false;
############################## CSight usage
# Generate the csight usage:
gen_wiki_page $dyn_usagef "./csight.sh -H" "CSight" false;
############################## InvariMint usage
# Generate the invarimint usage:
gen_wiki_page $invmint_usagef "./invarimint.sh -H" "InvariMint" true;
############################## InvariMint usage
# Generate the perfume usage:
gen_wiki_page $perfume_usagef "./perfume.sh -H" "Perfume" false;
# 5. (An extra step for synoptic) Determine the synoptic version by
# running synoptic.sh (assuming the current dir is the synoptic repo).
# cd ${code_repo} && ./synoptic.sh -V >> $syn_usagef
# echo >> $syn_usagef
# 6. Commit and push the edited wiki pages
cd ${wiki_repo} && git commit -a -m 'Updated usage screen docs for all projects' && git push