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

Added stdlib documentation and updated builtins #39

Merged
merged 14 commits into from
Sep 26, 2024

Conversation

Mte90
Copy link
Member

@Mte90 Mte90 commented Sep 5, 2024

image

Ref: #34

The english text was reviewed/improved with ChatGPT (not written from that).

The stuff in /doc is generated from the stdlib comments so for changes refer to https://github.com/amber-lang/amber

@Mte90 Mte90 linked an issue Sep 5, 2024 that may be closed by this pull request
@b1ek
Copy link
Member

b1ek commented Sep 5, 2024

im not sure that's a good idea to use ai generated text as the documentation

@Mte90
Copy link
Member Author

Mte90 commented Sep 5, 2024

im not sure that's a good idea to use ai generated text as the documentation

It isn't generated, I used it to improve what I already written.

@mks-h
Copy link
Member

mks-h commented Sep 5, 2024

Please go through the text using LanguageTool or Grammarly — it contains too many mistakes to review.

@Mte90
Copy link
Member Author

Mte90 commented Sep 5, 2024

Please go through the text using LanguageTool or Grammarly — it contains too many mistakes to review.

What files? because the stdlib is generated from the code in the amber repo

mks-h

This comment was marked as off-topic.

docs/advanced_syntax/builtins.md Outdated Show resolved Hide resolved
docs/advanced_syntax/builtins.md Outdated Show resolved Hide resolved
docs/stdlib/doc.md Outdated Show resolved Hide resolved
docs/stdlib/doc.md Outdated Show resolved Hide resolved
sync-stdlib-doc.sh Outdated Show resolved Hide resolved
Copy link

@Hoverth Hoverth left a comment

Choose a reason for hiding this comment

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

Just a quick review, it seems a lot of work will have to be done in the main repo to make the generated docs more consistent

docs/index.json Outdated Show resolved Hide resolved
@Mte90
Copy link
Member Author

Mte90 commented Sep 6, 2024

Also I enabled GFM so we can have more MD stuff like breaking line with ending double spaces.

@Mte90 Mte90 requested a review from KrosFire September 11, 2024 13:16
Copy link
Member

@Ph0enixKM Ph0enixKM left a comment

Choose a reason for hiding this comment

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

Let's not include .sh files as it's a compilation product of the main amber script. We can run .ab with shebang now #!/usr/bin/env amber.

README.md Outdated Show resolved Hide resolved
sync-stdlib-doc.ab Outdated Show resolved Hide resolved
@Mte90 Mte90 dismissed stale reviews from Ph0enixKM and KrosFire September 12, 2024 13:08

done

KrosFire
KrosFire previously approved these changes Sep 13, 2024
Copy link
Member

@KrosFire KrosFire left a comment

Choose a reason for hiding this comment

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

LGTM

Ph0enixKM
Ph0enixKM previously approved these changes Sep 19, 2024
Copy link
Member

@Ph0enixKM Ph0enixKM left a comment

Choose a reason for hiding this comment

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

LGTM

@Mte90 Mte90 dismissed stale reviews from Ph0enixKM and KrosFire via e29e4c2 September 20, 2024 08:20
@Mte90
Copy link
Member Author

Mte90 commented Sep 20, 2024

I sorted alphabetically using amber-lang/amber#470

b1ek
b1ek previously requested changes Sep 20, 2024
docs/advanced_syntax/builtins.md Outdated Show resolved Hide resolved
docs/advanced_syntax/builtins.md Outdated Show resolved Hide resolved
Comment on lines 47 to 49
unsafe ${nameof variable}=12$
// Which is the same as:
let variable = 12
Copy link
Member

Choose a reason for hiding this comment

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

are you sure this is good practice? even though its for demonstration purposes, people will still use it if you put it in docs

Copy link
Member Author

Choose a reason for hiding this comment

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

it was something written by @Ph0enixKM, I think that is the only way to explain nameof

This comment was marked as resolved.

Comment on lines 1 to 5
## Builtin VS StdLib

[Builtins](/advanced_syntax/builtins) are method that are included in the Amber compiler and don't need to be imported in the code.

In contrast, the standard library (stdlib) is a collection of Amber functions that are embedded in every Amber release. Each version of Amber may include changes to the standard library and you need to import these functions in your code. These functions are more advanced and can accept various parameters.
Copy link
Member

Choose a reason for hiding this comment

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

i fail to see the point of this paragraph

Copy link
Member Author

Choose a reason for hiding this comment

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

we need to explain the difference between those, we discussed internally why something should became a builtin or a stdflib so deserve a mention in the docs

Copy link
Member

Choose a reason for hiding this comment

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

But this section doesn't explain when something should be builtin or stdlib. It just says that you don't need to import builtin and stdlib you have to import. It's basic truth and I too don't see much sense in writing this

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that this section is important to explain the difference between the two.
Maybe the wording is not the best one but it's a start.

If you have a suggestion on how to improve it right now I will change it as I already did since the PR started.

docs/stdlib/doc.md Outdated Show resolved Hide resolved
docs/stdlib/doc/date.md Show resolved Hide resolved
Comment on lines +14 to +33
```ab
import { download } from "std/http"
import { split, contains } from "std/text"
import { file_exist } from "std/fs"

unsafe $rm -fr /tmp/amber-git$
if silent download("https://github.com/amber-lang/amber/archive/refs/heads/master.zip", "/tmp/amber-git.zip") {
unsafe $unzip "/tmp/amber-git.zip" -d /tmp/amber-git$

let std = unsafe $/usr/bin/ls "/tmp/amber-git/amber-master/src/std/"$
let stdlib = split(std, "\n")

loop v in stdlib {
if (contains(v, ".ab") and file_exist("/tmp/amber-git/amber-master/src/std/{v}")) {
unsafe $amber --docs "/tmp/amber-git/amber-master/src/std/{v}" "./docs/stdlib/doc"$
echo "\n"
}
}
}
```
Copy link
Member

Choose a reason for hiding this comment

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

its a bad idea to hardcode this. if the reader wants to see the code, they should click on the link and open it in github

Copy link
Member Author

Choose a reason for hiding this comment

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

Right now github doens't highlight amber code so it is better to put on the documentation website.

docs/stdlib/doc.md Show resolved Hide resolved
docs/advanced_syntax/builtins.md Outdated Show resolved Hide resolved
Comment on lines 23 to 36
## Mv

If you need to move files you can use the `mv` builtin, requires two `Text` parameters.

```ab
mv "/tmp/a" "/tmp/b"
```

This builtin is `failable`, meaning you can handle errors like this:
```ab
mv "/tmp/a" "/tmp/b" failed {
echo "Error"
}
```
Copy link
Member

Choose a reason for hiding this comment

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

what about -r? is it supported? if it is, how do i specify it? if it is not, how do i move a directory?

Copy link
Member Author

Choose a reason for hiding this comment

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

this is something we should address in Amber and not in the doc website

Copy link
Member

Choose a reason for hiding this comment

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

this is also something that should be thoroughly explained in the documentation

@b1ek
Copy link
Member

b1ek commented Sep 20, 2024

the way i see it, documentation must be mostly self sufficient, leave no confusion in interpretation and have no useless text in it

@Hoverth
Copy link

Hoverth commented Sep 21, 2024

the way i see it, documentation must be mostly self sufficient, leave no confusion in interpretation and have no useless text in it

You're correct, though this is perhaps the wrong place to take issue with some of this.

This PR is primarily a script that generates stdlib docs via the doc comments in the main amber repo, so any issue with the content of the stdlib markdown files here, should be addressed in the main repo and then this one can be updated.

Comment on lines 47 to 49
unsafe ${nameof variable}=12$
// Which is the same as:
let variable = 12

This comment was marked as resolved.

docs/stdlib/doc.md Outdated Show resolved Hide resolved
docs/stdlib/doc.md Outdated Show resolved Hide resolved
@Mte90 Mte90 merged commit f3c1237 into amber-lang:master Sep 26, 2024
@Mte90 Mte90 deleted the stdlib branch September 26, 2024 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Updating documentation for the next release
7 participants