2021-08-10 11:24:18 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-08-12 16:50:42 +08:00
|
|
|
#==============================================================#
|
|
|
|
# File : doc
|
|
|
|
# Ctime : 2021-08-10
|
|
|
|
# Mtime : 2021-08-12
|
|
|
|
# Desc : Serve local doc with docsify, python3, python
|
|
|
|
# Path : bin/doc
|
|
|
|
# Deps : docsify or python3 or python2
|
|
|
|
# Copyright (C) 2018-2021 Ruohang Feng
|
|
|
|
#==============================================================#
|
|
|
|
|
2021-08-10 11:24:18 +08:00
|
|
|
PROG_DIR="$(cd $(dirname $0) && pwd)"
|
2021-08-12 15:42:58 +08:00
|
|
|
DOCS_DIR="$(cd $(dirname ${PROG_DIR}) && pwd)"
|
|
|
|
|
|
|
|
# node.js (docsify) > python3 (http.server) > python2 (SimpleHTTPServer)
|
2021-08-10 11:24:18 +08:00
|
|
|
|
|
|
|
if command -v docsify; then
|
2021-08-12 15:42:58 +08:00
|
|
|
echo "serve with docsify (click url to view in browser)"
|
|
|
|
cd ${DOCS_DIR} && docsify serve
|
|
|
|
elif command -v python3; then
|
|
|
|
echo "serve http://localhost:3001 (python3 http.server)"
|
|
|
|
cd ${DOCS_DIR} && python3 -m http.server 3001
|
|
|
|
elif command -v python2; then
|
|
|
|
echo "serve http://localhost:3001 (python2 SimpleHTTPServer)"
|
|
|
|
cd ${DOCS_DIR} && python2 -m SimpleHTTPServer 3001
|
2021-08-10 11:24:18 +08:00
|
|
|
else
|
2021-08-12 15:42:58 +08:00
|
|
|
echo "no available server"
|
2021-08-10 11:24:18 +08:00
|
|
|
fi
|