-
Notifications
You must be signed in to change notification settings - Fork 0
/
stashgen.sh
executable file
·47 lines (37 loc) · 1.26 KB
/
stashgen.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
#!/usr/bin/bash
# require argument for package name
if [ -z "$1" ]; then
echo "Usage: $0 <package name>"
exit 1
fi
# take in argument for package name
pkgname=$1
DOCPATH=/home/colin/docs
# confirm that package directory exists in "/home/colin/.local/lib/python3.10/site-packages/"
if [ -d "/home/colin/.local/lib/python3.10/site-packages/$pkgname" ]; then
echo "Package directory exists"
else
echo "Package directory does not exist"
exit 1
fi
pkg_path="/home/colin/.local/lib/python3.10/site-packages/$pkgname"
# get list of modules in package
modules=$(find $pkg_path -type f -name "*.py" | sed "s|$pkg_path/||" | sed "s|\.py$||" | sed "s|/|.|g")
echo "Modules:"
# print list of modules separated by newline
for module in $modules; do
echo $module
done
# create docs/$pkgname directory if it does not exist
if [ -d "$DOCPATH/$pkgname" ]; then
echo "Documentation directory for $pkgname already exists"
else
echo "Creating documentation directory for $pkgname"
mkdir $DOCPATH/$pkgname
fi
for module in $modules; do
echo "Generating documentation for $module"
pydoc-markdown -m $pkgname.$module --render-toc > $DOCPATH/$pkgname/$module.md
done
echo "-------------------"
echo "Documentation generated for $pkgname in $DOCPATH/$pkgname"