jsonnet-libs / docsonnet Goto Github PK
View Code? Open in Web Editor NEWExperimental Jsonnet docs generator
Experimental Jsonnet docs generator
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:
colors.green
(string)
: "green"
- the color greenTesting 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?
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
Line 8 in be06665
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
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
.
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)
https://pillow.readthedocs.io/en/stable/reference/Image.html#functions
something(o, x)
something
does some stuff
PARAMETERS
o (object)
- an objectx (any)
- an array or string for blah
RETURNS
object
- a fizzbuzz
ASSERTIONS
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
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]),
}
since jsonnet doesn't use fn
or obj
, I think it would enhance readability by spelling those out.
obj container
fn container.keyValuePairs
object container
function container.keyValuePairs
Similar to this:
https://golang.org/pkg/encoding/json/#HTMLEscape
<details>
<summary>Example</summary>
```jsonnet
this is an example
```
</details>
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
local myapp = import "..."
myapp
implements a ...
new(config, name)
new returns an instance of myapp
This works and docsonnet renders it
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?
current:
### fn container.array
suggested:
container.array
### fn `container.array`
I noticed that this doesn't work:
local d = import "github.com/sh0rez/docsonnet/doc-util";
but this does:
local d = import 'doc-util/main.libsonnet';
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.