GithubHelp home page GithubHelp logo

docsonnet's People

Contributors

duologic avatar malcolmholmes avatar matthiaswinzeler avatar maxaudron avatar sh0rez avatar woozymasta avatar xvzf avatar yorinasub17 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

docsonnet's Issues

feat: support constants

It is useful to support constants in libraries like (in fact doc-utils does this)

{  
   colors: {
     '#green': d.const("the color green")
     green: "green"
   }
}

As such, I'd like to be able to document these constants. Possible look for this:


Constants

  • colors.green (string) : "green" - the color green

Update embedded jsonnet code.

Testing using the docker master image, but I believe the pkger.go code is using old jsonnet files that don't have the "filename" and "version" parameters in the d.pkg() function.

Given that the most recent changes appear to allow rendering the docs directly using jsonnet, is the recommended path forward to directly use: jsonnet -S -c -m docs/ docs.jsonnet instead of the docsonnet binary?

function `std.manifestYamlDoc` has no parameter `quote_keys`

Hello!

I ran into a problem the std.manifestYamlDoc function does not have a quote_keys parameter

Apparently because the project uses an older version of jsonnet 0.15

github.com/google/go-jsonnet v0.15.1-0.20200415122941-8a0084e64395

Are there any restrictions for upgrading to jsonnet 0.18?


Below is an example of how I discovered the issue:

  '#new'+: d.fn(
    help=
    |||
      Some function

      Optional arguments can be passed as an array of `args`

      ```yaml
      %(defaults)s
      ```
    ||| % { defaults: std.manifestYamlDoc({args: defaults}, quote_keys=false) },
    args=[
      d.arg('name', d.T.string),
      d.arg('args', d.T.array, {}),
    ]
  ),
  new(name=error 'Application name is unset', args={})::
docsonnet -o docs/ main.libsonnet
Extracting: RUNTIME ERROR: function has no parameter quote_keys

Also I tried using docsonnet versions:

  • v0.0.4-0.20220713111504-be066653f33f
  • v0.0.3

Confusing output for keys with periods in them

Both docsonnet documentation fields below are rendered similarly such that I imagine a user could easily be confused by the structure of the data when seeing the Markdown documentation for a key with periods . in it.

{
  '#has.a.period': d.val('help'),
  'has.a.period': null,
  has: {
    a: {
      '#period': d.val('help'),
      period: null,
    },
  },
}

I guess keys that require quoting in Jsonnet should be enclosed in square brackets, the same as in Jsonnet so that the first key becomes ['has.a.period'] in the rendered documentation and the second key stays as has.a.period.

feat: python documentation-like output

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

docs: suggest to use ||| for readability

might be useful to suggest to use ||| syntax for readability of the description.

{
  '#array': d.fn(
    |||
      `array` takes a single argument of any type.
      If it is an array, it returns it, otherwise it is wrapped in an array.
    |||,
    [d.arg('x', d.T.any)]),
  array(x):: (if std.type(x) == "array" then x else [x]),
}

feat: be verbose with type names

since jsonnet doesn't use fn or obj, I think it would enhance readability by spelling those out.

Current (with backticks, see #5)

obj container
fn container.keyValuePairs

Suggested

object container
function container.keyValuePairs

docsonnet not finding nested doc-strings

Hi,

Would you be able to confirm whether this is expected to work?

I find that any object/function under new() does not get picked up by docsonnet , i.e. there's no inside_object - was hoping it would also get rendered into markdown :)

local d = import 'doc-util/main.libsonnet';
{
  // package declaration
  '#': d.pkg(
    name='myapp',
    url='...',
    help='`myapp` implements a ...',
  ),

  '#outside_object': d.obj('This works and docsonnet renders it'),
  outside_object+:: {
    foo: {},
  },

  '#new':: d.fn(help='new returns an instance of myapp',
                args=[
                  d.arg(name='config', type=d.T.string),
                  d.arg(name='name', type=d.T.string),
                ]),

  new(config, name)::
    {
      '#inside_object': d.obj('This does not get rendered by docsonnet'),
      inside_object+:: {
        foo: {},
      },
    },
}

renders to


permalink: /

package myapp

local myapp = import "..."

myapp implements a ...

Index

Fields

fn new

new(config, name)

new returns an instance of myapp

obj outside_object

This works and docsonnet renders it

Desugared Implementation

This is an issue to talk about the issues involved in a desugared implementation.

AFAIK, the main issue is about the AST not providing access to comments?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.