1
1
mirror of https://github.com/mcuadros/ascode synced 2024-11-26 14:03:49 +01:00
ascode/docs/reference/reference.md.tmpl

124 lines
2.3 KiB
Go HTML Template

{{- define "functionName" }}
{{- if ne .Receiver "" -}}
#
{{- end -}}
### def {{ if ne .Receiver "" -}}
<i>{{ .Receiver }}</i>.
{{- end -}}
<b>{{- (index (split .Signature "(") 0) -}}</b>
{{- end -}}
{{- define "function" }}
{{ template "functionName" . }}
```go
{{if ne .Receiver "" -}}{{.Receiver}}.{{- end }}{{ .Signature }}
```
{{- if ne .Description "" }}
{{ .Description }}
{{- end -}}
{{- if gt (len .Params) 0 }}
###### Arguments
| name | type | description |
|------|------|-------------|
{{ range .Params -}}
| `{{ .Name }}` | `{{ .Type }}` | {{ (replace_all .Description "\n" "") }} |
{{ end -}}
{{- end -}}
{{- if gt (len .Examples) 0 }}
###### Examples
{{ range .Examples -}}
{{ .Description }}
```python
{{ .Code }}
```
{{ end -}}
{{- end -}}
{{- end -}}
{{- define "indexFunctionName" -}}
{{- $receiver := "" -}}
{{ if ne .Receiver "types" -}}{{ $receiver = printf "<i>%s</i>." .Receiver }}{{- end -}}
{{- $name := printf "def <b>%s</b>" (index (split .Signature "(") 0) -}}
{{- $anchor := printf "def %s<b>%s</b>" $receiver (index (split .Signature "(") 0) -}}
* [{{ $name }}({{ (index (split .Signature "(") 1) }}](#{{ sanitizeAnchor $anchor }})
{{- end -}}
{{- range . -}}
---
title: "{{ .Path }}"
summary: "{{ (replace_all .Description "\n" "") }}"
toc: true
---
## Overview
{{ if ne .Description "" }}{{ .Description }}{{ end }}
{{- if gt (len .Functions) 0 }}
## Functions
{{ range .Functions -}}
{{ template "function" . }}
{{ end -}}
{{- end }}
{{ if gt (len .Types) 0 }}
## Types
{{ range .Types -}}
### type <b>{{ .Name }}</b>
{{ if ne .Description "" }}{{ .Description }}{{ end -}}
{{ if gt (len .Fields) 0 }}
###### Properties
| name | type | description |
|------|------|-------------|
{{ range .Fields -}}
| `{{ .Name }}` | `{{ .Type }}` | {{ (replace_all .Description "\n" "") }} |
{{ end -}}
{{ end }}
{{ if gt (len .Examples) 0 }}
###### Examples
{{ range .Examples -}}
{{ .Description }}
```python
{{ .Code }}
```
{{ end -}}
{{ end -}}
{{ if gt (len .Methods) 0 }}
###### Methods
{{- range .Methods -}}
{{ template "function" . }}
{{ end -}}
{{- if gt (len .Operators) 0 }}
###### Operators
| operator | description |
|----------|-------------|
{{ range .Operators -}}
| {{ .Opr }} | {{ .Description }} |
{{ end }}
{{ end }}
{{ end }}
{{- end -}}
{{- end -}}
{{ end }}