mirror of
https://github.com/TECHNOFAB11/docsonnet.git
synced 2026-02-02 15:45:12 +01:00
Render Markdown with Jsonnet natively (#26)
This commit is contained in:
parent
fc3f9bca2d
commit
f47f46f93f
5 changed files with 427 additions and 39 deletions
|
|
@ -1,23 +1,19 @@
|
|||
---
|
||||
permalink: /
|
||||
---
|
||||
|
||||
# package d
|
||||
|
||||
```jsonnet
|
||||
local d = import "github.com/jsonnet-libs/docsonnet/doc-util"
|
||||
local d = import 'github.com/jsonnet-libs/docsonnet/doc-util/main.libsonnet';
|
||||
```
|
||||
|
||||
`doc-util` provides a Jsonnet interface for `docsonnet`,
|
||||
a Jsonnet API doc generator that uses structured data instead of comments.
|
||||
|
||||
|
||||
## Index
|
||||
|
||||
* [`fn arg(name, type, default)`](#fn-arg)
|
||||
* [`fn fn(help, args)`](#fn-fn)
|
||||
* [`fn obj(help, fields)`](#fn-obj)
|
||||
* [`fn pkg(name, url, help)`](#fn-pkg)
|
||||
* [`fn render(obj, filename)`](#fn-render)
|
||||
* [`fn val(type, help, default)`](#fn-val)
|
||||
* [`obj argument`](#obj-argument)
|
||||
* [`fn new(name, type, default)`](#fn-argumentnew)
|
||||
|
|
@ -28,10 +24,11 @@ local d = import "github.com/jsonnet-libs/docsonnet/doc-util"
|
|||
* [`obj object`](#obj-object)
|
||||
* [`fn new(help, fields)`](#fn-objectnew)
|
||||
* [`fn withFields(fields)`](#fn-objectwithfields)
|
||||
* [`obj package`](#obj-package)
|
||||
* [`fn new(name, url, help)`](#fn-packagenew)
|
||||
* [`obj value`](#obj-value)
|
||||
* [`fn new(type, help, default)`](#fn-valuenew)
|
||||
* [`obj T`](#obj-t)
|
||||
* [`obj package`](#obj-package)
|
||||
* [`fn new(name, url, help)`](#fn-packagenew)
|
||||
|
||||
## Fields
|
||||
|
||||
|
|
@ -67,6 +64,24 @@ pkg(name, url, help)
|
|||
|
||||
`new` is a shorthand for `package.new`
|
||||
|
||||
### fn render
|
||||
|
||||
```ts
|
||||
render(obj, filename)
|
||||
```
|
||||
|
||||
`render` converts the docstrings to human readable Markdown files.
|
||||
|
||||
Usage:
|
||||
|
||||
```jsonnet
|
||||
// docs.jsonnet
|
||||
d.render(import 'main.libsonnet', 'main.libsonnet')
|
||||
```
|
||||
|
||||
Call with: `jsonnet -S -c -m docs/ docs.jsonnet`
|
||||
|
||||
|
||||
### fn val
|
||||
|
||||
```ts
|
||||
|
|
@ -75,11 +90,11 @@ val(type, help, default)
|
|||
|
||||
`val` is a shorthand for `value.new`
|
||||
|
||||
## obj argument
|
||||
### obj argument
|
||||
|
||||
Utilities for creating function arguments
|
||||
|
||||
### fn argument.new
|
||||
#### fn argument.new
|
||||
|
||||
```ts
|
||||
new(name, type, default)
|
||||
|
|
@ -87,11 +102,11 @@ new(name, type, default)
|
|||
|
||||
new creates a new function argument, taking the name, the type and optionally a default value
|
||||
|
||||
## obj func
|
||||
### obj func
|
||||
|
||||
Utilities for documenting Jsonnet methods (functions of objects)
|
||||
|
||||
### fn func.new
|
||||
#### fn func.new
|
||||
|
||||
```ts
|
||||
new(help, args)
|
||||
|
|
@ -99,7 +114,7 @@ new(help, args)
|
|||
|
||||
new creates a new function, optionally with description and arguments
|
||||
|
||||
### fn func.withArgs
|
||||
#### fn func.withArgs
|
||||
|
||||
```ts
|
||||
withArgs(args)
|
||||
|
|
@ -107,7 +122,7 @@ withArgs(args)
|
|||
|
||||
The `withArgs` modifier overrides the arguments of that function
|
||||
|
||||
### fn func.withHelp
|
||||
#### fn func.withHelp
|
||||
|
||||
```ts
|
||||
withHelp(help)
|
||||
|
|
@ -115,11 +130,11 @@ withHelp(help)
|
|||
|
||||
The `withHelp` modifier overrides the help text of that function
|
||||
|
||||
## obj object
|
||||
### obj object
|
||||
|
||||
Utilities for documenting Jsonnet objects (`{ }`).
|
||||
|
||||
### fn object.new
|
||||
#### fn object.new
|
||||
|
||||
```ts
|
||||
new(help, fields)
|
||||
|
|
@ -127,7 +142,7 @@ new(help, fields)
|
|||
|
||||
new creates a new object, optionally with description and fields
|
||||
|
||||
### fn object.withFields
|
||||
#### fn object.withFields
|
||||
|
||||
```ts
|
||||
withFields(fields)
|
||||
|
|
@ -135,26 +150,37 @@ withFields(fields)
|
|||
|
||||
The `withFields` modifier overrides the fields property of an already created object
|
||||
|
||||
## obj package
|
||||
### obj value
|
||||
|
||||
Utilities for documenting plain Jsonnet values (primitives)
|
||||
|
||||
#### fn value.new
|
||||
|
||||
```ts
|
||||
new(type, help, default)
|
||||
```
|
||||
|
||||
new creates a new object of given type, optionally with description and default value
|
||||
|
||||
### obj T
|
||||
|
||||
|
||||
* `T.any` (`string`): `"any"` - argument of type "any"
|
||||
* `T.array` (`string`): `"array"` - argument of type "array"
|
||||
* `T.boolean` (`string`): `"bool"` - argument of type "boolean"
|
||||
* `T.func` (`string`): `"function"` - argument of type "func"
|
||||
* `T.null` (`string`): `"null"` - argument of type "null"
|
||||
* `T.number` (`string`): `"number"` - argument of type "number"
|
||||
* `T.object` (`string`): `"object"` - argument of type "object"
|
||||
* `T.string` (`string`): `"string"` - argument of type "string"
|
||||
|
||||
### fn package.new
|
||||
### obj package
|
||||
|
||||
|
||||
#### fn package.new
|
||||
|
||||
```ts
|
||||
new(name, url, help)
|
||||
```
|
||||
|
||||
new creates a new package with given `name`, `import` URL and `help` text
|
||||
|
||||
## obj value
|
||||
|
||||
Utilities for documenting plain Jsonnet values (primitives)
|
||||
|
||||
### fn value.new
|
||||
|
||||
```ts
|
||||
new(type, help, default)
|
||||
```
|
||||
|
||||
new creates a new object of given type, optionally with description and default value
|
||||
Loading…
Add table
Add a link
Reference in a new issue