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

Add Julia support #84

Open
wants to merge 82 commits into
base: main
Choose a base branch
from

Conversation

josephsdavid
Copy link

@josephsdavid josephsdavid commented Mar 30, 2022

Slowly figuring out how to add julia support, currently just for functions and structs as that is all i know how to do, but eventually maybe macro docs... todos:

  • struct documentation (much easier since there aren't 10 million types of arguments)
  • function documentation

{
retrieve = "all",
node_type = "typed_parameter",
subtree = { { retrieve = "all", node_type = "identifier", extract = true } },
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe try with

subtree = {
  {
    position = 1,
    extract = true,
    as = I.Identifier
  },
    {
    position = 2,
    extract = true,
    as = ...
  },
}

Copy link
Owner

Choose a reason for hiding this comment

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

if this doesn't work, just retrieve the parent node aka typed_parameter and do a Lua separation with ::.

lua/neogen/configurations/julia.lua Outdated Show resolved Hide resolved
end,
})
:add_default_annotation("google_docstrings")
:add_annotation("numpydoc")
Copy link
Owner

Choose a reason for hiding this comment

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

Be sure to create your own Julia convention when it progresses

@josephsdavid
Copy link
Author

actually hold on that, after reading https://docs.julialang.org/en/v1/manual/documentation/ more thoroughly i have some changes

@josephsdavid
Copy link
Author

I think for now this is probably sufficient but I will need to add more as I understand how julia documentation works!

@danymat
Copy link
Owner

danymat commented Apr 4, 2022

Hello ! Very cool ! Can you share me some code examples of your features, and tell me which convention you used ?

@danymat
Copy link
Owner

danymat commented Apr 21, 2022

Hello @josephsdavid , what's the state of the integration ?

@josephsdavid
Copy link
Author

Oh! I have forgotten to finish the job here, let me make these things!

@josephsdavid
Copy link
Author

So as far as conventions, Julia does not have established conventions like numpydoc jsdoc emmylua etc, so I guess we could just call it something like "Julia Alternative" or "Julia unspecified", it is based off of how we document open source stuff at my job, example, so I guess we could call it "Beacon format" for lack of a better name!

import Base: +, *, /

"""
    Point

A type representing a point in 2d space

Where...

    x::Number is the x coordinate
    y::Number is the y coordinate
"""
struct Point
    x::Number
    y::Number
end

# Open question: Generate docs for this type of function
+(a::Point, b::Point) =  Point(a.x + b.x, a.y + b.y)

+(a::Point, b::Number) = Point(a.x + b, a.y + b)

*(a::Point, b::Point) = Point(a.x * b.x, a.y * b.y)

/(a::Point, b::Number) = Point(a.x / b, a.y / b)



"""
    f(x,y,z,w)

f does some operations on some points and numbers

Where...

    z::Number is a shift factor, which shifts a point
    w::Number is a scaling factor, which scales the output
    x is the first point
    y is the second point
"""
function f(x, y, z::Number = 1, w::Number = 3)
    return (x * (y + z)) / w
end

above is a little code demo, two sort of open questions are:

  1. how to document the f(x) = 2 * x syntax
  2. Need to be able to grab the function title and arguments, currently this is done manually

@f3fora
Copy link

f3fora commented Apr 22, 2022

Actually Julia defines some conventions in the documentation or more accurately in Documenter.jl.

Arguments are actually introduced with:

"""
...
# Arguments
- `n::Integer`: the number of elements to compute.
- `dim::Integer=1`: the dimensions along which to perform the computation.
...
"""

@josephsdavid
Copy link
Author

josephsdavid commented Apr 22, 2022

Actually Julia defines some conventions in the documentation or more accurately in Documenter.jl.

Arguments are actually introduced with:

"""
...
# Arguments
- `n::Integer`: the number of elements to compute.
- `dim::Integer=1`: the dimensions along which to perform the computation.
...
"""

Ah let me change this! Should be resolved in latest commit

@f3fora
Copy link

f3fora commented Apr 22, 2022

the format is currently wrong ("- \t%s::%s is $1")
It should be "- %s::%s : $1"

@josephsdavid
Copy link
Author

Here we go! Thank you by the way :)

@josephsdavid
Copy link
Author

new code sample!

import Base: +, *, /

"""
    Point(x,y)

A struct representing a 2d point

# Arguments

- `x::Number` is the x coordinate
- `y::Number` is the y coordinate
"""
struct Point
    x::Number
    y::Number
end

# Open question: Generate docs for this type of function
+(a::Point, b::Point) =  Point(a.x + b.x, a.y + b.y)

+(a::Point, b::Number) = Point(a.x + b, a.y + b)

*(a::Point, b::Point) = Point(a.x * b.x, a.y * b.y)

/(a::Point, b::Number) = Point(a.x / b, a.y / b)



"""
    f(x,y,z,w)

f does some operations on some points and numbers

# Arguments

- `z::Number` is a shift factor, which shifts a point
- `w::Number` is a scaling factor, which scales the output
- `x` is the first point
- `y` is the second point
"""
function f(x, y, z::Number = 1, w::Number = 3)
    return (x * (y + z)) / w
end

a = Point(1,2)
b = Point(1,3)

f(a,b)

@f3fora
Copy link

f3fora commented Apr 22, 2022

According to the documentation:

  • in struct each field can be documented independently with no need of adding arguments in the struct docstring.
  • in arguments there is a : instead of is.

Moreover, the default argument value should be included and the arguments should be in order.

@josephsdavid
Copy link
Author

According to the documentation:

  • in struct each field can be documented independently with no need of adding arguments in the struct docstring.
  • in arguments there is a : instead of is.

Moreover, the default argument value should be included and the arguments should be in order.

Thanks! I will knock this out after work :)

@josephsdavid
Copy link
Author

So need to figure out how to get the arguments in order, it is tricky because I have to parse typed and nontyped arguments separately, and default arguments I need to figure out as well (and typed default arguments 🤯 !) So this will likely turn into a weekend project!

@danymat
Copy link
Owner

danymat commented May 5, 2022

So need to figure out how to get the arguments in order, it is tricky because I have to parse typed and nontyped arguments separately, and default arguments I need to figure out as well

I'm afraid that's a limitation at the moment..
What's the state of the PR ?

@josephsdavid
Copy link
Author

So need to figure out how to get the arguments in order, it is tricky because I have to parse typed and nontyped arguments separately, and default arguments I need to figure out as well

I'm afraid that's a limitation at the moment.. What's the state of the PR ?

if thats the limitation, it seems i just need to get the default arguments to show up and then it is good!

@josephsdavid
Copy link
Author

So need to figure out how to get the arguments in order, it is tricky because I have to parse typed and nontyped arguments separately, and default arguments I need to figure out as well

I'm afraid that's a limitation at the moment.. What's the state of the PR ?

if thats the limitation, it seems i just need to get the default arguments to show up and then it is good!

Still stuck here lol but have not forgotten

@danymat
Copy link
Owner

danymat commented Jun 23, 2022

Hello, what's the current state of this PR ? What are the current things I can catch on and try to merge it ?

@danymat
Copy link
Owner

danymat commented Dec 28, 2022

Hello @josephsdavid, I can finish implementing this PR if you think it's in a good progress. If so, could you pinpoint me what needs to be continued ?

EDIT:

iirc, thats the only thing missing ?:

if thats the limitation, it seems i just need to get the default arguments to show up and then it is good!

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.

None yet

3 participants