Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Aug 30, 2024. It is now read-only.
/coder-v1-cliPublic archive

Commitd469991

Browse files
committed
Aggregate generated docs into one file
1 parent82282b1 commitd469991

File tree

6 files changed

+814
-4
lines changed

6 files changed

+814
-4
lines changed

‎.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ ci/bin
33
cmd/coder/coder
44
ci/integration/bin
55
ci/integration/env.sh
6-
coder-sdk/env.sh
6+
coder-sdk/env.sh
7+
.vscode

‎ci/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
-`steps/gendocs.sh` generates CLI documentation into`/docs` from the command specifications.
88
-`steps/lint.sh` lints all Go source files based on the rules set fourth in`/.golangci.yml`.
99

10-
1110
##integration tests
1211

1312
###`tcli`

‎ci/image/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ ENV CI=true
55

66
RUN go get golang.org/x/tools/cmd/goimports
77
RUN go get github.com/mattn/goveralls
8-
RUN apt update && apt install grep
8+
9+
RUN apt update && apt install zip curl grep
10+
RUN curl -fsSL https://deno.land/x/install/install.sh | sh
11+
ENV PATH="/root/.deno/bin:${PATH}"

‎ci/scripts/aggregate_docs.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// join all /docs files into a single markdown file
2+
// fix all hyperlinks
3+
4+
constnewFilename="coder_cli_all_docs.md"
5+
constnewPath=`./docs/${newFilename}`
6+
Deno.chdir(`${newURL(".",import.meta.url).pathname}/../../`)
7+
8+
constdirs=[]
9+
forawait(constdirofDeno.readDir("./docs")){
10+
dirs.push(dir)
11+
}
12+
13+
constfilenames=dirs.map(({ name})=>name).filter((f)=>f!==newFilename)
14+
constfilenameParts=filenames
15+
.map((f)=>f.split("_"))
16+
.sort((a,b)=>a.length-b.length)
17+
.sort((a,b)=>{
18+
for(letiina.length>b.length ?a :b){
19+
if(a[i]!=b[i])returna>b ?-1 :1
20+
}
21+
return1
22+
})
23+
24+
letaggregated=""
25+
for(letiinfilenameParts){
26+
constfilename=filenameParts[i].join("_")
27+
constfile=awaitDeno.readFile(`./docs/${filename}`)
28+
aggregated+=`\n${newTextDecoder().decode(file)}`
29+
}
30+
for(letiinfilenames){
31+
aggregated=aggregated.replaceAll(
32+
filenames[i],
33+
`#${filenames[i].replace(".md","").split("_").join("-")}`
34+
)
35+
}
36+
37+
try{
38+
awaitDeno.remove(newPath)
39+
}catch{}
40+
awaitDeno.writeFile(newPath,newTextEncoder().encode(aggregated))

‎ci/steps/gendocs.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
set -euo pipefail
44

5-
echo"Generating docs..."
5+
echo"--Generating docs"
66

77
cd"$(dirname"$0")"
88
cd ../../
@@ -11,6 +11,14 @@ rm -rf ./docs
1111
mkdir ./docs
1212
go run ./cmd/coder gen-docs ./docs
1313

14+
if!command -v deno>/dev/null;then
15+
"deno is required to compile the docs into a single file"
16+
exit 1
17+
fi
18+
19+
echo"-- Aggregating docs"
20+
deno run --allow-read --allow-write ./ci/scripts/aggregate_docs.ts
21+
1422
if [[${CI-}&&$(git ls-files --other --modified --exclude-standard) ]];then
1523
echo"Documentation needs generation:"
1624
git -c color.ui=always status| grep --color=no'\e\[31m'

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp