aboutsummaryrefslogtreecommitdiff
path: root/.init/generate.docs.sh
blob: 5571f28a60464fc4b7182970a854eeb02da8e6ea (plain) (blame)
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
#!/bin/bash
set -eo pipefail

DOC_ROOT="../doc"
CLIENT_DOC="${DOC_ROOT}/client-documents"
CORE_DOC="${DOC_ROOT}/core-documents"

clean_dirs() {
    for dir in "${CLIENT_DOC}" "${CORE_DOC}"; do
        if [ -d "${dir}" ]; then
            echo "Cleaning: ${dir}"
            rm -rf "${dir}" || return 1
        fi
    done
}

gen_client_docs() {
    echo "Generating client docs..."
    pushd ../client >/dev/null
    if ! cargo doc --no-deps > /dev/null 2>&1; then
        echo "[ERROR] Client docs generation failed"
        return 1
    fi

    local src_path="../shared/target/doc/there_is_nopads_client"
    if [ -d "${src_path}" ]; then
        mkdir -p "${CLIENT_DOC%/*}"
        mv "${src_path}" "${CLIENT_DOC}" && \
        echo "[SUCCESS] Client docs moved to: ${CLIENT_DOC}"
    else
        echo "[ERROR] Client docs not found at ${src_path}"
        return 1
    fi
    popd >/dev/null
}

gen_core_docs() {
    echo "Generating core docs..."
    pushd ../core >/dev/null
    if ! cargo doc --no-deps > /dev/null 2>&1; then
        echo "[ERROR] Core docs generation failed"
        return 1
    fi

    local src_path="../shared/target/doc/there_is_nopads_core"
    if [ -d "${src_path}" ]; then
        mkdir -p "${CORE_DOC%/*}"
        mv "${src_path}" "${CORE_DOC}" && \
        echo "[SUCCESS] Core docs moved to: ${CORE_DOC}"
    else
        echo "[ERROR] Core docs not found at ${src_path}"
        return 1
    fi
    popd >/dev/null
}

main() {
    clean_docs
    gen_client_docs
    gen_core_docs
}

main