Skip to content

Commit

Permalink
Merge pull request #65 from mnich0ls/markdown-links-to-examples
Browse files Browse the repository at this point in the history
Modify markdown template to add request example links
  • Loading branch information
thedevsaddam committed Jan 3, 2022
2 parents 41fb900 + 5d35cbd commit 101e113
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 18 deletions.
43 changes: 37 additions & 6 deletions assets/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,51 @@
@{{- .Data.Info.Description -}}@
@{{ end }}@

<!--- Request items indices -->
## Indices
@{{ range $index, $c := .Data.Collections }}@
<!--- Table of contents -->
@{{- $numCollections := len .Data.Collections}}@
<!--- If we have only one grouop/collection, then no need for the "ungrouped" heading -->
@{{- if eq $numCollections 1 }}@
@{{- range $index, $c := .Data.Collections -}}@
@{{- range $i, $item := $c.Items }}@
1. [@{{ $item.Name | trim }}@](#@{{ merge $i $item.Name | trim | glink | glinkInc }}@)
@{{- range $ri, $response := $item.Responses }}@
@{{- $riRoman := ($ri | addOne | roman) }}@
1. [@{{ $response.Name | trim }}@](#@{{ (print $riRoman ". Example Request: " $response.Name) | trim | glink | glinkInc }}@)
@{{- /* End iterate responses for the request */}}@
@{{- end }}@
@{{- /* End iterate requests in the collection */}}@
@{{- end }}@
@{{- /* End iterate collections */}}@
@{{- end }}@
@{{- /* End if we have more than one collection */}}@
@{{- end }}@

<!--- If we have more than one group/collection, then display each group name heading -->
@{{- if gt $numCollections 1 }}@
@{{- range $index, $c := .Data.Collections }}@
* [@{{ $c.Name | trim }}@](#@{{ $c.Name | trim | glink }}@)
@{{ range $i, $item := $c.Items }}@
* [@{{ $item.Name | trim }}@](#@{{ merge $i $item.Name | trim | glink | glinkInc }}@)
@{{- range $i, $item := $c.Items }}@
1. [@{{ $item.Name | trim }}@](#@{{ merge $i $item.Name | trim | glink | glinkInc }}@)
@{{- range $ri, $response := $item.Responses }}@
@{{- $riRoman := ($ri | addOne | roman) }}@
* [@{{ $response.Name | trim }}@](#@{{ (print $riRoman ". Example Request: " $response.Name) | trim | glink | glinkInc }}@)
@{{- /* End iterate responses for the request */}}@
@{{- end }}@
@{{- /* End iterate requests in the collection */}}@
@{{- end }}@
@{{- /* End iterate collections */}}@
@{{- end }}@
@{{- /* End if we have more than one collection */}}@
@{{- end }}@
@{{ end }}@

--------
<!--- Iterate main collection -->

@{{ range $di, $d := .Data.Collections }}@
<!--- Only show the collection name if there is more than the "ungrouped" collection -->
@{{ if gt $numCollections 1 }}@
## @{{ $d.Name | trim }}@
@{{ end }}@
@{{ $d.Description }}@

<!--- Iterate collection items -->
Expand Down
24 changes: 12 additions & 12 deletions assets_bin/assets.go

Large diffs are not rendered by default.

0 comments on commit 101e113

Please sign in to comment.