Amber icon indicating copy to clipboard operation
Amber copied to clipboard

[Feature/Bug] No stdlib comments in bash generated

Open Mte90 opened this issue 1 year ago • 3 comments

After ~~#367~~ now when you compile a bash script that include a stdlib there are comments from that stdlib.

An example:

import * from "std/math"

// Output 
// 1
// 1

main {
    echo abs(1);
    echo abs(-1);
}
#!/usr/bin/env bash
# Written in [Amber](https://amber-lang.com/)
# version: 0.3.4-alpha
# date: 2024-08-08 14:52:58
# Returns the number rounded to the nearest integer
# Returns the largest integer less than or equal to the number
# Returns the smallest integer greater than or equal to the number
# Returns the absolute value of the number
function abs__4_v0 {
    local number=$1
    if [ $(echo ${number} '<' 0 | bc -l | sed '/\./ s/\.\{0,1\}0\{1,\}$//') != 0 ]; then
        __AF_abs4_v0=$(echo '-' ${number} | bc -l | sed '/\./ s/\.\{0,1\}0\{1,\}$//')
        return 0
    fi
    __AF_abs4_v0=${number}
    return 0
}

abs__4_v0 1
__AF_abs4_v0__8_10="$__AF_abs4_v0"
echo "$__AF_abs4_v0__8_10"
abs__4_v0 $(echo '-' 1 | bc -l | sed '/\./ s/\.\{0,1\}0\{1,\}$//')
__AF_abs4_v0__9_10="$__AF_abs4_v0"
echo "$__AF_abs4_v0__9_10"

As we can see now includes all the documentation for the math stdlib also for the stuff unused. I think that if we are talking about stdlib there should be no comments and also that if you import something the comments shouldn't be there for stuff that you are not using.

Mte90 avatar Aug 08 '24 12:08 Mte90

No I checked the issues was happening also before that PR. Probably the PR that added the documentation generator had that issue too. @Ph0enixKM this is for you

Mte90 avatar Aug 08 '24 13:08 Mte90

So the /// should be persisted in code as #? Will do.

Ph0enixKM avatar Aug 08 '24 14:08 Ph0enixKM

I think so, but also there is the issue that printed the whole comments in the file not just the one involved in the function so there is a bug somewhere.

Mte90 avatar Aug 08 '24 14:08 Mte90