diff --git a/docs/class_template.md b/docs/class_template.md index dc3b9957b..1ac9d54d8 100644 --- a/docs/class_template.md +++ b/docs/class_template.md @@ -3,4 +3,4 @@ linkTitle: "LINK" no_list: true --- -{{< python-class "PATH" >}} +{{< api-ref-class "PATH" >}} diff --git a/docs/function_template.md b/docs/function_template.md index 05d9fd846..9b35c58c8 100644 --- a/docs/function_template.md +++ b/docs/function_template.md @@ -5,4 +5,4 @@ superheading: "PARENT." weight: 100 --- -{{< python "PATH" >}} +{{< api-ref "PATH" >}} diff --git a/docs/layouts/partials/python-function-parenthesis.html b/docs/layouts/partials/api-ref-function-parenthesis.html similarity index 100% rename from docs/layouts/partials/python-function-parenthesis.html rename to docs/layouts/partials/api-ref-function-parenthesis.html diff --git a/docs/layouts/partials/python-api-link-all-partial.html b/docs/layouts/partials/api-ref-link-all-partial.html similarity index 87% rename from docs/layouts/partials/python-api-link-all-partial.html rename to docs/layouts/partials/api-ref-link-all-partial.html index 109f9be45..0d09b7c36 100644 --- a/docs/layouts/partials/python-api-link-all-partial.html +++ b/docs/layouts/partials/api-ref-link-all-partial.html @@ -1,7 +1,10 @@ {{ $context := .context}} {{ $paragraph := .paragraph}} +{{ $jsonPath := printf "versioned_docs/%s/links.json" (partial "version.html" (dict "context" $context)).dirpath }} -{{ with getJSON (printf "versioned_docs/%s/links.json" (partial "version.html" (dict "context" $context)).dirpath) }} +{{ if fileExists $jsonPath }} + +{{ with getJSON $jsonPath }} {{ $links := . }} {{ range $name, $data := $links }} @@ -36,3 +39,7 @@ {{ $paragraph | safeHTML }} {{ end }} + +{{ else }} + Missing links.json for this version! +{{ end }} diff --git a/docs/layouts/partials/python-api-link-partial.html b/docs/layouts/partials/api-ref-link-partial.html similarity index 73% rename from docs/layouts/partials/python-api-link-partial.html rename to docs/layouts/partials/api-ref-link-partial.html index 1926dc445..4f784599c 100644 --- a/docs/layouts/partials/python-api-link-partial.html +++ b/docs/layouts/partials/api-ref-link-partial.html @@ -1,7 +1,10 @@ {{ $orig_name := .paragraph }} {{ $context := .context }} +{{ $jsonPath := printf "versioned_docs/%s/links.json" (partial "version.html" (dict "context" $context)).dirpath }} -{{ with getJSON (printf "versioned_docs/%s/links.json" (partial "version.html" (dict "context" $context)).dirpath) }} +{{ if fileExists $jsonPath }} + +{{ with getJSON $jsonPath }} {{ $links := . }} {{/* We have to handle the case of Optional[name] or list[name] */}} {{ $name := $orig_name }} @@ -19,3 +22,7 @@ {{ $orig_name }} {{ end }} {{ end }} + +{{ else }} + Missing links.json for this version! +{{ end }} diff --git a/docs/layouts/partials/python-object.html b/docs/layouts/partials/api-ref-object-partial.html similarity index 63% rename from docs/layouts/partials/python-object.html rename to docs/layouts/partials/api-ref-object-partial.html index 8657bf776..2466edea8 100644 --- a/docs/layouts/partials/python-object.html +++ b/docs/layouts/partials/api-ref-object-partial.html @@ -6,21 +6,21 @@
{{ if and (eq $objData.kind "function")}} -{{ $parenthesisArgsString := partial "python-function-parenthesis.html" $objData}} +{{ $parenthesisArgsString := partial "api-ref-function-parenthesis.html" $objData}} {{ if not $objData.is_property }}

- {{ (index (last 1 $path) 0) }}({{- $parenthesisArgsString -}}) -> {{ partial "python-api-link-partial.html" (dict "paragraph" $objData.signature.return_annotation "context" $context) }} + {{ (index (last 1 $path) 0) }}({{- $parenthesisArgsString -}}) -> {{ partial "api-ref-link-partial.html" (dict "paragraph" $objData.signature.return_annotation "context" $context) }}

{{ else }}

- {{ (index (last 1 $path) 0) }} -> {{ partial "python-api-link-partial.html" (dict "paragraph" $objData.signature.return_annotation "context" $context) }} + {{ (index (last 1 $path) 0) }} -> {{ partial "api-ref-link-partial.html" (dict "paragraph" $objData.signature.return_annotation "context" $context) }}

{{ end }} {{ if $objData.docstring_parsed}}
-

{{ partial "python-api-link-all-partial.html" (dict "paragraph" ($objData.docstring_parsed.short_description | safeHTML) "context" $context) }}

-

{{ partial "python-api-link-all-partial.html" (dict "paragraph" ($objData.docstring_parsed.long_description | safeHTML) "context" $context)}}

+

{{ partial "api-ref-link-all-partial.html" (dict "paragraph" ($objData.docstring_parsed.short_description | safeHTML) "context" $context) }}

+

{{ partial "api-ref-link-all-partial.html" (dict "paragraph" ($objData.docstring_parsed.long_description | safeHTML) "context" $context)}}

{{ end }} @@ -41,8 +41,8 @@

Parameters

{{range $objData.docstring_parsed.params}} {{ .arg_name }} - {{ partial "python-api-link-partial.html" (dict "paragraph" .type_name "context" $context) }} - {{ partial "python-api-link-all-partial.html" (dict "paragraph" (.description | safeHTML) "context" $context) }} + {{ partial "api-ref-link-partial.html" (dict "paragraph" .type_name "context" $context) }} + {{ partial "api-ref-link-all-partial.html" (dict "paragraph" (.description | safeHTML) "context" $context) }} {{end}} @@ -63,7 +63,7 @@

Parameters

{{range $objData.signature.params}} {{ index . 0 }} - {{ partial "python-api-link-partial.html" (dict "paragraph" (index . 1) "context" $context) }} + {{ partial "api-ref-link-partial.html" (dict "paragraph" (index . 1) "context" $context) }} None {{end}} @@ -101,11 +101,11 @@

Returns

- {{ partial "python-api-link-partial.html" (dict "paragraph" $typeName "context" $context) }} + {{ partial "api-ref-link-partial.html" (dict "paragraph" $typeName "context" $context) }} {{ if $description }} - {{ partial "python-api-link-all-partial.html" (dict "paragraph" ($objData.docstring_parsed.returns.description | safeHTML) "context" $context) }} + {{ partial "api-ref-link-all-partial.html" (dict "paragraph" ($objData.docstring_parsed.returns.description | safeHTML) "context" $context) }} {{ else }} None {{ end }} @@ -124,8 +124,8 @@

Returns

{{index (last 2 $path) 0}}.{{ index (last 1 $path) 0 }}

{{ if $objData.docstring_parsed }}
-

{{ partial "python-api-link-all-partial.html" (dict "paragraph" ($objData.docstring_parsed.short_description | safeHTML) "context" $context) }}

-

{{ partial "python-api-link-all-partial.html" (dict "paragraph" ($objData.docstring_parsed.long_description | safeHTML) "context" $context) }}

+

{{ partial "api-ref-link-all-partial.html" (dict "paragraph" ($objData.docstring_parsed.short_description | safeHTML) "context" $context) }}

+

{{ partial "api-ref-link-all-partial.html" (dict "paragraph" ($objData.docstring_parsed.long_description | safeHTML) "context" $context) }}

{{ end }} {{end}} diff --git a/docs/layouts/partials/python.html b/docs/layouts/partials/api-ref-partial.html similarity index 57% rename from docs/layouts/partials/python.html rename to docs/layouts/partials/api-ref-partial.html index aeb21d969..4d5ab7520 100644 --- a/docs/layouts/partials/python.html +++ b/docs/layouts/partials/api-ref-partial.html @@ -1,6 +1,9 @@ {{ $path := split .path "." }} +{{ $jsonPath := printf "versioned_docs/%s/data.json" (partial "version.html" (dict "context" .context )).dirpath }} -{{ with getJSON (printf "versioned_docs/%s/data.json") (partial "version.html" (dict "context" .context )).dirpath }} +{{ if fileExists $jsonPath }} + +{{ with getJSON $jsonPath }} {{ $currentData := . }} {{ range $path }} {{ if (eq $currentData.kind "class") }} @@ -17,6 +20,10 @@
- {{ partial "python-object.html" (dict "object" $objData "path" $path "context" .) }} + {{ partial "api-ref-object-partial.html" (dict "object" $objData "path" $path "context" .) }}
{{ end }} + +{{ else }} + Missing data.json for this version! +{{ end }} diff --git a/docs/layouts/shortcodes/api-ref-base.html b/docs/layouts/shortcodes/api-ref-base.html new file mode 100644 index 000000000..38e5adea9 --- /dev/null +++ b/docs/layouts/shortcodes/api-ref-base.html @@ -0,0 +1,29 @@ +{{ $page := . }} +{{ $dirpath := (partial "version.html" (dict "context" .)).dirpath }} + +{{ $jsonPath := printf "versioned_docs/%s/data.json" $dirpath }} + +{{ if fileExists $jsonPath }} + + {{ with getJSON $jsonPath }} + {{ $data := . }} + {{ with getJSON (printf "versioned_docs/%s/links.json" $dirpath) }} + {{ $links := . }} + + + {{ end }} + {{ end }} + +{{ else }} + Missing data.json for this version! +{{ end }} diff --git a/docs/layouts/shortcodes/python-class.html b/docs/layouts/shortcodes/api-ref-class.html similarity index 54% rename from docs/layouts/shortcodes/python-class.html rename to docs/layouts/shortcodes/api-ref-class.html index 74108b618..c358b49fd 100644 --- a/docs/layouts/shortcodes/python-class.html +++ b/docs/layouts/shortcodes/api-ref-class.html @@ -1,21 +1,25 @@ {{ $path := split (.Get 0) "." }} {{ $page := .Page }} +{{ $jsonPath := printf "versioned_docs/%s/data.json" (partial "version.html" (dict "context" $page)).dirpath }} -{{ with getJSON (printf "versioned_docs/%s/data.json" (partial "version.html" (dict "context" $page)).dirpath) }} - {{ $currentData := . }} - {{ range $path }} - {{ if (eq $currentData.kind "class") }} - {{ $currentData = $currentData.functions }} - {{ end }} - {{$currentData = index $currentData .}} +{{ if fileExists $jsonPath }} + + {{ with getJSON $jsonPath }} + {{ $currentData := . }} + {{ range $path }} + {{ if (eq $currentData.kind "class") }} + {{ $currentData = $currentData.functions }} + {{ end }} + {{$currentData = index $currentData .}} {{ end }} - {{ $objData := $currentData }} - {{ $publicMethodsCounter := 0 }} - {{ $publicPropertiesCounter := 0 }} +{{ $objData := $currentData }} - {{ range $name, $func := $objData.functions }} +{{ $publicMethodsCounter := 0 }} +{{ $publicPropertiesCounter := 0 }} + +{{ range $name, $func := $objData.functions }} {{ if (not (hasPrefix $name "_"))}} {{ if $func.is_property }} {{ $publicPropertiesCounter = add $publicPropertiesCounter 1 }} @@ -24,11 +28,10 @@ {{ end }} {{ end }} - {{ end }} - +{{ end }}
- {{ partial "python-object.html" (dict "object" $objData "path" $path "context" $page) }} + {{ partial "api-ref-object-partial.html" (dict "object" $objData "path" $path "context" $page) }}

Properties

{{ if gt $publicPropertiesCounter 0 }} @@ -45,10 +48,10 @@

Properties

- {{ partial "python-api-link-partial.html" (dict "paragraph" $name "context" $page) }} + {{ partial "api-ref-link-partial.html" (dict "paragraph" $name "context" $page) }} {{ if $func.docstring_parsed }} - {{ partial "python-api-link-all-partial.html" (dict "paragraph" $func.docstring_parsed.short_description "context" $page) }} + {{ partial "api-ref-link-all-partial.html" (dict "paragraph" $func.docstring_parsed.short_description "context" $page) }} {{ else }} None {{ end }} @@ -77,12 +80,12 @@

Methods

{{ if and (not (hasPrefix $name "_")) (not $func.is_property)}} - {{ $parenthesisArgsString := partial "python-function-parenthesis.html" $func}} + {{ $parenthesisArgsString := partial "api-ref-function-parenthesis.html" $func}} - {{ partial "python-api-link-partial.html" (dict "paragraph" $name "context" $page) }}({{- $parenthesisArgsString -}}) + {{ partial "api-ref-link-partial.html" (dict "paragraph" $name "context" $page) }}({{- $parenthesisArgsString -}}) {{ if $func.docstring_parsed }} - {{ partial "python-api-link-all-partial.html" (dict "paragraph" $func.docstring_parsed.short_description "context" $page) }} + {{ partial "api-ref-link-all-partial.html" (dict "paragraph" $func.docstring_parsed.short_description "context" $page) }} {{ else }} None {{ end }} @@ -97,3 +100,7 @@

Methods

{{ end }} + +{{ else }} + Missing data.json for this version! +{{ end }} diff --git a/docs/layouts/shortcodes/api-ref-link.html b/docs/layouts/shortcodes/api-ref-link.html new file mode 100644 index 000000000..17636e194 --- /dev/null +++ b/docs/layouts/shortcodes/api-ref-link.html @@ -0,0 +1 @@ +{{ partial "api-ref-link-partial.html" (dict "paragraph" (index .Params 0) "context" .Page)}} diff --git a/docs/layouts/shortcodes/python-module.html b/docs/layouts/shortcodes/api-ref-module.html similarity index 67% rename from docs/layouts/shortcodes/python-module.html rename to docs/layouts/shortcodes/api-ref-module.html index 6173d9372..9210fbc00 100644 --- a/docs/layouts/shortcodes/python-module.html +++ b/docs/layouts/shortcodes/api-ref-module.html @@ -1,6 +1,9 @@ {{ $path := split (.Get 0) "." }} {{ $page := .Page }} -{{ $data := getJSON (printf "versioned_docs/%s/data.json" (partial "version.html" (dict "context" .Page)).dirpath) }} +{{ $jsonPath := printf "versioned_docs/%s/data.json" (partial "version.html" (dict "context" .Page)).dirpath }} + +{{ if fileExists $jsonPath }} +{{ $data := getJSON $jsonPath }} {{ $currentData := $data}} @@ -27,10 +30,14 @@ {{ if ne $objName "kind" }} {{$objData.kind}} - {{partial "python-api-link-partial.html" (dict "paragraph" $objName "context" $page) }} + {{partial "api-ref-link-partial.html" (dict "paragraph" $objName "context" $page) }} {{ end }} {{ end }}
+ +{{ else }} + Missing data.json for this version! +{{ end }} diff --git a/docs/layouts/shortcodes/api-ref.html b/docs/layouts/shortcodes/api-ref.html new file mode 100644 index 000000000..d4366cd01 --- /dev/null +++ b/docs/layouts/shortcodes/api-ref.html @@ -0,0 +1,34 @@ +{{ $page := .Page }} +{{ $path := split (.Get 0) "." }} +{{ $version := partial "version.html" (dict "context" $page)}} +{{ $jsonPath := printf "versioned_docs/%s/data.json" $version.dirpath }} + +{{ if fileExists $jsonPath }} + + {{ if and $version $version.dirpath }} + {{ with getJSON $jsonPath }} + {{ $currentData := .}} + {{ range $path }} + {{ if (eq $currentData.kind "class") }} + {{ $currentData = $currentData.functions }} + {{ end }} + {{$currentData = index $currentData .}} + {{ end }} + + {{ $objData := $currentData }} + + +
+ {{ partial "api-ref-object-partial.html" (dict "object" $objData "path" $path "context" $page) }} +
+ {{ end }} + + {{ else }} + + Problem parsing the data.json! + + {{ end }} + +{{ else }} + Missing data.json for this version! +{{ end }} diff --git a/docs/layouts/shortcodes/python-api-link.html b/docs/layouts/shortcodes/python-api-link.html deleted file mode 100644 index 123b6ce19..000000000 --- a/docs/layouts/shortcodes/python-api-link.html +++ /dev/null @@ -1 +0,0 @@ -{{ partial "python-api-link-partial.html" (dict "paragraph" (index .Params 0) "context" .Page)}} diff --git a/docs/layouts/shortcodes/python-api-ref.html b/docs/layouts/shortcodes/python-api-ref.html deleted file mode 100644 index 19eb8eccb..000000000 --- a/docs/layouts/shortcodes/python-api-ref.html +++ /dev/null @@ -1,21 +0,0 @@ -{{ $page := . }} -{{ $dirpath := (partial "version.html" (dict "context" .)).dirpath }} - -{{ with getJSON (printf "versioned_docs/%s/data.json" $dirpath) }} - {{ $data := . }} - {{ with getJSON (printf "versioned_docs/%s/links.json" $dirpath) }} - {{ $links := . }} - - - {{ end }} -{{ end }} diff --git a/docs/layouts/shortcodes/python.html b/docs/layouts/shortcodes/python.html deleted file mode 100644 index 8bb2c3c25..000000000 --- a/docs/layouts/shortcodes/python.html +++ /dev/null @@ -1,26 +0,0 @@ -{{ $page := .Page }} -{{ $path := split (.Get 0) "." }} -{{ $version := partial "version.html" (dict "context" $page)}} - -{{ if and $version $version.dirpath }} - {{ with getJSON (printf "versioned_docs/%s/data.json" $version.dirpath) }} - {{ $currentData := .}} - {{ range $path }} - {{ if (eq $currentData.kind "class") }} - {{ $currentData = $currentData.functions }} - {{ end }} - {{$currentData = index $currentData .}} - {{ end }} - - {{ $objData := $currentData }} - - -
- {{ partial "python-object.html" (dict "object" $objData "path" $path "context" $page) }} -
- {{ end }} -{{ else }} - -Problem parsing the data.json! - -{{ end }} diff --git a/docs/module_template.md b/docs/module_template.md index f31445993..1b8e39c48 100644 --- a/docs/module_template.md +++ b/docs/module_template.md @@ -4,4 +4,4 @@ linkTitle: "LINK" no_list: true --- -{{< python-module "PATH" >}} +{{< api-ref-module "PATH" >}}