-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_docs.sh
More file actions
executable file
·105 lines (82 loc) · 3.34 KB
/
Copy pathbuild_docs.sh
File metadata and controls
executable file
·105 lines (82 loc) · 3.34 KB
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
98
99
100
101
102
103
104
105
#!/bin/bash
# Fail if any sub-command fails
set -e
source /opt/ros/$ROS_DISTRO/setup.bash
# Install documentation dependencies if not already available
! rosdoc_lite --help > /dev/null && sudo apt-get install -y ros-$ROS_DISTRO-rosdoc-lite
! doxygen -v > /dev/null && sudo apt-get install -y doxygen
! sphinx-build --version > /dev/null && sudo apt-get install python3-sphinx
# Set up environment
mkdir -p ~/autonomous-twizy/docs
cd ~/autonomous-twizy/docs
# Clear out docs directory
find "." ! -path "." ! -path "./.git/*" ! -path "./.git" ! -path "./.nojekyll" ! -path "./README.md" -exec rm -rf {} +
commit_hash=`git -C ../src log -n 1 --pretty=format:"%H"`
commit_message=`git -C ../src log -n 1 --pretty=format:"%s"`
# Fetch stylesheet along with its licence from online source
curl https://raw.githubusercontent.com/sindresorhus/github-markdown-css/main/license | awk '{print "// " $0}' > index.css
echo -e "\n\n" >> index.css
curl https://raw.githubusercontent.com/sindresorhus/github-markdown-css/main/github-markdown.css >> index.css
echo "\
<html>
<head>
<title>Autonomous-Twizy Code API</title>
<link type='text/css' rel='stylesheet' href='index.css' />
<meta charset='UTF-8'>
</head>
<body>
<div class='markdown-body' />
<h1>Index of autonomous-twizy Documentation</h1>
<p>
The code API documentation listed here has been automatically generated by a script running <a href='http://wiki.ros.org/rosdoc_lite'>rosdoc_lite</a> on all packages present in the repo.
ROS API is contained in package READMEs and is manually updated by pushing to the master branch.
For information on internal code functionality, please see comments in the <a href='https://github.com/OssianEriksson/autonomous-twizy'>source code</a>.
</p>
<h2>Documented ROS Packages</h2>
" > index.html
for pkg in ../src/*; do
# Skip directories which do not contain ROS packages
if [ ! -f "$pkg/package.xml" ]; then
continue
fi
# Build documentation for a single package
name=`basename $pkg`
rosdoc_lite -o "$name" "$pkg"
# Extract package description
description=`cat "$pkg/package.xml" | grep -oPm1 "(?<=<description>)[^<]+"`
# Add link to code API if src or include directory exists
[ -d "$pkg/src" ] || [ -d "$pkg/include" ] &&
code_api="<li><a href='$name/html/index.html'>Code API</a></li>" ||
code_api=""
# Add link to msg/srv API if msg or srv directory exists
[ -d "$pkg/msg" ] || [ -d "$pkg/srv" ] &&
msg_srv_api="<li><a href='$name/html/index-msg.html'>Msg/Srv API</a></li>" ||
msg_srv_api=""
# Add package entry to index.md
echo "\
<h3><a href='https://github.com/OssianEriksson/autonomous-twizy/tree/master/$name'>$name</a></h3>
<p>
$description
</p>
<p>
<ul>
<li><a href='https://github.com/OssianEriksson/autonomous-twizy/tree/master/$name#readme'>ROS API</a> (view on Github)</li>
$code_api
$msg_srv_api
</ul>
</p>
" >> index.html
done
echo "\
<hr>
<small>The latest commit included in this documentation is <a href='https://github.com/OssianEriksson/autonomous-twizy/tree/$commit_hash'>$commit_message</a> (view on Github)</small>
</div>
</body>
</html>
" >> index.html
if [[ -z "${GITHUB_ACTION}" ]]; then # If running on a local computer
docs_abspath=`pwd`
echo -e "\n\nThe code API documentation has been built to $docs_abspath"
echo -e "\nYou can view the documentation in your browser, e.g. using firefox:"
echo -e "\n firefox $docs_abspath/index.html\n"
fi