Skip to content

Commit 2f93ea6

Browse files
committed
implement a github reference for auto-code blocks
1 parent 974b67c commit 2f93ea6

File tree

4 files changed

+70
-0
lines changed

4 files changed

+70
-0
lines changed

website_and_docs/assets/scss/_tabpane.scss

+8
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,11 @@ div.nocode {
33
margin: 2rem 0 2rem 0;
44
padding-bottom: 1rem;
55
}
6+
7+
.github {
8+
border-bottom: 1px solid #dee2e6;
9+
text-align: center;
10+
margin: 0 0 1rem 0;
11+
font-weight: 600;
12+
padding-bottom: 1rem;
13+
}

website_and_docs/content/documentation/about/style.en.md

+26
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,32 @@ You need to specify which parts are code and which are not yourself now, like th
197197
< ... >
198198
{{</* /tabpane */>}}
199199

200+
### Link to GitHub
201+
202+
If you disable code blocks, you can create whatever kind of link anywhere you want.
203+
But say you want to add a GitHub link associated with a given tab when using the default code block:
204+
{{< tabpane >}}
205+
{{< tab header="Link" github="seleniumhq/seleniumhq.github.io/blob/dev/website_and_docs/content/documentation/about/style.en.md#L205" >}}
206+
Content in automatic code block that refers to something on GitHub
207+
{{< /tab >}}
208+
{{< tab header="No Link" >}}
209+
This content should not get linked to GitHub
210+
{{< /tab >}}
211+
{{< /tabpane >}}
212+
213+
To add a link to a particular tab, pass in a `github` value
214+
to that tab. Note that only the tabs that have this value will have the link added.
215+
216+
{{</* tabpane */>}}
217+
{{</* tab header="Link" github="seleniumhq/seleniumhq.github.io/blob/dev/website_and_docs/content/documentation/about/style.en.md#L205" */>}}
218+
Content in automatic code block that refers to something on GitHub
219+
{{</* /tab */>}}
220+
{{</* tab header="No Link" */>}}
221+
This content should not get linked to GitHub
222+
{{</* /tab */>}}
223+
{{</* /tabpane */>}}
224+
225+
200226
### Code Comments
201227

202228
Minimize code comments because they are difficult to translate.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!-- Make sure that we are enclosed within a tabpane shortcode block -->
2+
{{ with $.Parent }}
3+
{{- if ne $.Parent.Name "tabpane" -}}
4+
{{- errorf "tab must be used within a tabpane block" -}}
5+
{{- end -}}
6+
{{- end -}}
7+
8+
<!-- Prefill header if not given as parameter -->
9+
{{ $header := default (printf "Tab %v" ( add $.Ordinal 1)) (.Get "header") }}
10+
11+
<!-- store all tab info in dict tab -->
12+
{{ $tab := dict "header" $header }}
13+
{{ with $.Get "lang" }}
14+
{{ $tab = merge $tab (dict "language" ($.Get "lang")) }}
15+
{{ end }}
16+
{{ with $.Get "github" }}
17+
{{ $tab = merge $tab (dict "github" ($.Get "github")) }}
18+
{{ end }}
19+
{{ with $.Get "highlight" }}
20+
{{ $tab = merge $tab (dict "highlight" ($.Get "highlight")) }}
21+
{{ end }}
22+
{{ with $.Inner }}
23+
<!-- Trim any leading and trailing newlines from .Inner, this avoids
24+
spurious lines during syntax highlighting -->
25+
{{ $tab = merge $tab (dict "content" (trim $.Inner "\n")) }}
26+
{{ end }}
27+
28+
<!-- add dict tab to parent's scratchpad -->
29+
{{ with .Parent }}
30+
{{- $.Parent.Scratch.SetInMap "tabs" (printf "%v" $.Ordinal) $tab -}}
31+
{{ end }}

website_and_docs/layouts/shortcodes/tabpane.html

+5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
{{- $entryid := printf "tabs-%v-%v" $.Ordinal $index | anchorize -}}
5050

5151
{{- highlight (index . "content") $lang $hloptions -}}
52+
{{ if $element.github }}
53+
<div class="github">
54+
<a href ="https://www.github.com/{{- $element.github -}}">See full example on GitHub.</a>
55+
</div>
56+
{{end}}
5257
{{end}}
5358

5459
</div>

0 commit comments

Comments
 (0)