Debian Codegraph @

script/api-docs/generate

raw symbols SCIP
1 #!/usr/bin/envscip-shell filesystem . . `/usr/bin/env`. bash
2 #
3 # Usage: generate repo_path output_path
4 #
5 # Example: generate https://github.com/libgit2/libgit2 path_to_output
6 # to clone the repository from GitHub and produce documentation;
7 # the repo_path can also be a local path
8
9 set -eo pipefail
10
11 source_path=$(mktempscip-shell system . . mktemp. -d)
12 verbose=
13 force=
14
15 for var in "$@"; do
16 if [scip-shell system . . `[`. "${var}" == "--verbose" ]; then
17 verbose=true
18 elif [scip-shell system . . `[`. "${var}" == "--force" ]; then
19 force=true
20 elif [scip-shell system . . `[`. "${repo_path}" == "" ]; then
21 repo_path="${var}"
22 elif [scip-shell system . . `[`. "${output_path}" == "" ]; then
23 output_path="${var}"
24 else
25 repo_path=""
26 output_path=""
27 fi
28 done
29
30 if [scip-shell system . . `[`. "${repo_path}" = "" -o "${output_path}" = "" ]; then
31 echoscip-shell system . . echo. "usage: $0 [--verbose] [--force] repo_path output_path" 1>&2
32 exit 1
33 fi
34
35 function do_checkoutscip-shell shell shell-project 0.0.0 do_checkout(). {
36 if [scip-shell system . . `[`. "$1" = "" ]; then
37 echoscip-shell system . . echo. "usage: $0 source_path" 1>&2
38 exit 1
39 fi
40
41 if [scip-shell system . . `[`. "${verbose}" ]; then
42 echoscip-shell system . . echo. ":: Checking out source trees..."
43 echoscip-shell system . . echo. ""
44 fi
45
46 source_path=$1
47
48 mkdirscip-shell system . . mkdir. -p "${source_path}"
49 gitscip-shell system . . git. clone "${repo_path}" "${source_path}/main" --no-checkout
50 ( cd "${source_path}/main" && gitscip-shell system . . git. sparse-checkout set --no-cone 'include/*' )
51 ( cd "${source_path}/main" && gitscip-shell system . . git. read-tree origin/main )
52 ( cd "${source_path}/main" && gitscip-shell system . . git. checkout -- include )
53
54 for tag in $(gitscip-shell system . . git. --git-dir="${source_path}/main/.git" tag -l); do
55 gitscip-shell system . . git. --git-dir="${source_path}/main/.git" worktree add -f "${source_path}/${tag}" "${tag}" --no-checkout
56 ( cd "${source_path}/${tag}" && gitscip-shell system . . git. sparse-checkout set --no-cone 'include/*' )
57 ( cd "${source_path}/${tag}" && gitscip-shell system . . git. read-tree HEAD )
58
59 if [scip-shell system . . `[`. "${tag}" == "v0.1.0" ]; then
60 ( cd "${source_path}/${tag}" && gitscip-shell system . . git. checkout -- src/git )
61 elif [scip-shell system . . `[`. "${tag}" == "v0.2.0" -o "${tag}" == "v0.3.0" ]; then
62 ( cd "${source_path}/${tag}" && gitscip-shell system . . git. checkout -- src/git2 )
63 else
64 ( cd "${source_path}/${tag}" && gitscip-shell system . . git. checkout -- include )
65 fi
66 done
67 }
68
69 do_checkoutscip-shell shell shell-project 0.0.0 do_checkout(). ${source_path}
70
71 if [scip-shell system . . `[`. "${verbose}" ]; then
72 echoscip-shell system . . echo. ""
73 echoscip-shell system . . echo. ":: Generating raw API documentation..."
74 echoscip-shell system . . echo. ""
75 fi
76
77 for version in ${source_path}/*; do
78 version=$(echoscip-shell system . . echo. "${version}" | sedscip-shell system . . sed. -e "s/.*\///")
79 commit=$( cd "${source_path}/${version}" && gitscip-shell system . . git. rev-parse HEAD )
80
81 if [scip-shell system . . `[`. -f "${output_path}/api/${version}.json" ]; then
82 existing_commit=$(jqscip-shell system . . jq. -r .info.commit < "${output_path}/api/${version}.json")
83
84 if [scip-shell system . . `[`. "${existing_commit}" == "${commit}" -a ! "${force}" ]; then
85 if [scip-shell system . . `[`. "${verbose}" ]; then
86 echoscip-shell system . . echo. "Raw API documentation for ${version} exists; skipping..."
87 fi
88
89 continue
90 fi
91 fi
92
93 echoscip-shell system . . echo. "Generating raw API documentation for ${version}..."
94 mkdirscip-shell system . . mkdir. -p "${output_path}/api"
95 nodescip-shell system . . node. ./api-generator.js "${source_path}/${version}" > "${output_path}/api/${version}.json"
96 done
97
98 if [scip-shell system . . `[`. "${verbose}" ]; then
99 echoscip-shell system . . echo. ""
100 echoscip-shell system . . echo. ":: Generating HTML documentation..."
101 echoscip-shell system . . echo. ""
102 fi
103
104 search_options=""
105 docs_options=""
106 if [scip-shell system . . `[`. "${verbose}" ]; then
107 search_options="${search_options} --verbose"
108 docs_options="${docs_options} --verbose"
109 fi
110 if [scip-shell system . . `[`. "${force}" ]; then
111 docs_options="${docs_options} --force"
112 fi
113
114 nodescip-shell system . . node. ./search-generator.js ${search_options} "${output_path}/api" "${output_path}/search-index"
115 nodescip-shell system . . node. ./docs-generator.js ${docs_options} --jekyll-layout default "${output_path}/api" "${output_path}/reference"