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

feat: python documentation-like output #8

Open
ghostsquad opened this issue Jul 15, 2020 · 3 comments
Open

feat: python documentation-like output #8

ghostsquad opened this issue Jul 15, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@ghostsquad
Copy link

I think it would be helpful to allow each parameter, and return value to be explained. Additionally, whether or not an error or assertion could be raised (outside of the usual suspects)

Reference

https://pillow.readthedocs.io/en/stable/reference/Image.html#functions

image


fn pkg.something

something(o, x)

something does some stuff

PARAMETERS

  • o (object) - an object
  • x (any) - an array or string for blah

RETURNS

object - a fizzbuzz

ASSERTIONS

  • If o or x are null

### fn pkg.something

```ts
something(o, x)
```

`something` does some stuff

> `PARAMETERS`

* `o (object)` - an object
* `x (any)` - an array or string for blah

> `RETURNS`

`object` - a fizzbuzz

> `ASSERTIONS`

* If `o` or `x` are null
@sh0rez
Copy link
Member

sh0rez commented Jul 16, 2020

Loving this!!

For parameters, we would need to extend d.arg():

- d.argument.new(name, type, default=null)
+ d.argument.new(name, type, default=null, help="")

For both assertions and return value, d.function.new could have new parameters asserts=[] and returns=null.

In Jsonnet, this could look like this:

{
  "#greet": d.fn("`greet` says hello",
    args=[d.arg("name", d.T.string, "Name of the (person) to greet")],
    asserts=["name is a string"],
    returns=d.val(d.T.string, "A friendly message"),
  greet(name): "Hello %s!" % name,
}

d.val above does not exist, but could be introduced as a way to also document regular exposed values (#10)

@sh0rez sh0rez added the enhancement New feature or request label Jul 16, 2020
@ghostsquad
Copy link
Author

Is this a "good first issue" you think? or something you would want to tackle? I filed a bunch of issues the other night just to start the conversations. I'm more than willing to submit some PRs too. Let me know.

@sh0rez
Copy link
Member

sh0rez commented Jul 16, 2020

Sure, give it a go!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants