Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sync-stdlib-doc.ab to v0.4.0 #77

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions sync-stdlib-doc.ab
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
#!/usr/bin/env amber
import { download } from "std/http"
import { split, contains } from "std/text"
import { file_exist } from "std/fs"
import { file_download } from "std/http"
import { split, text_contains } from "std/text"
import { file_extract, file_glob } from "std/fs"

trust $rm -fr /tmp/amber-git$
if silent download("https://github.com/amber-lang/amber/archive/refs/heads/master.zip", "/tmp/amber-git.zip") {
trust $unzip "/tmp/amber-git.zip" -d /tmp/amber-git$
let std_path = "/tmp/amber-git/amber-master/src/std/"
if silent file_download("https://github.com/amber-lang/amber/archive/refs/heads/master.zip", "/tmp/amber-git.zip") {
trust file_extract("/tmp/amber-git.zip", "/tmp/amber-git")
const stdlib = trust file_glob("/tmp/amber-git/amber-master/src/std/**.ab")

let std = trust $/usr/bin/ls "{std_path}"$
let stdlib = split(std, "\n")

loop v in stdlib {
if (contains(v, ".ab") and file_exist("{std_path}{v}")) {
echo "Parsing {std_path}{v}"
trust $amber --docs "{std_path}{v}" "./docs/stdlib/doc/"$
echo "\n"
}
for v in stdlib {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to check if it is a ".ab" file

Copy link
Contributor Author

@lens0021 lens0021 Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it still required even though you're considering the line 9 uses a glob pattern ends with *.ab?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I've seen I made a mistake on the glob pattern. Let me try to fix it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've edited the glob pattern and replace with $ shopt -s globstar $ and $ ls …/**/*.ab $

echo "Parsing {v}"
trust $ amber docs --usage -- "{v}" "./docs/stdlib/doc/" $
echo "\n"
}
}