| {{/* | 
 | A Hugo shortcode to include the content generated from the IP description Hjson | 
 |  | 
 | Usage: {{< incGenFromIpDesc hjsonPath contentType >}} | 
 |  | 
 | hjsonPath: Path to an IP description file in Hjson (ip_name.hjson) | 
 |   Relative paths are resolved relative to the directory using the shortcode. | 
 |   Absolute paths are resolved relative to REPO_TOP. | 
 |  | 
 |   This path could also be a testplan described in Hjson | 
 |   (ip_name_testplan.hjson). Testplans may additionally be suffixed with "tags" | 
 |   separated with ":" colon delimiter, such as "ip_name_testplan.hjson:foo:bar". | 
 |   The tags are extracted from the path and appended at the end to construct the | 
 |   path of the generated content, for example: | 
 |   "ip_name_testplan.hjson.foo_bar_testplan" | 
 |  | 
 | contentType: Type of generated content to include. | 
 |   Valid options: testplan, hwcfg, registers | 
 |  | 
 | The actual content is rendered as HTML by the util/build_docs.py script and only | 
 | included by the shortcode here. | 
 | */}} | 
 |  | 
 | {{ $hjsonPath := .Get 0 }} | 
 | {{ $contentType := .Get 1 }} | 
 | {{ $ipDescFile := (printf "%s.%s" $hjsonPath $contentType) }} | 
 |  | 
 | {{ if eq $contentType "testplan" }} | 
 |   {{ $splitTags := split $hjsonPath ":" }} | 
 |   {{ $tags := (cond (gt (len $splitTags) 1) (delimit (after 1 $splitTags) "_") "") }} | 
 |   {{ $ipDescFile = (printf "%s.%s_%s" (index $splitTags 0) $tags $contentType) }} | 
 | {{ end }} | 
 |  | 
 | {{ $path := "UNDEF" }} | 
 | {{ if (hasPrefix $ipDescFile "/") }} | 
 |   {{ $path = path.Join .Site.Params.generatedRoot $ipDescFile }} | 
 | {{ else }} | 
 |   {{ $path = path.Join .Site.Params.generatedRoot .Page.File.Dir $ipDescFile }} | 
 | {{ end }} | 
 | {{ if not (fileExists $path) }} | 
 |   {{ errorf "HTML for %s has not been generated for %s (looked at %s)" $contentType $hjsonPath $path }} | 
 | {{ end }} | 
 | {{ readFile $path | safeHTML }} |