forked from lowRISC/opentitan
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shortcode for inserting a generated table of content for the current folder. This can be used in Markdown files in order to have an always up-to-date list of the content of the folder. Supports a "type" parameter which can be set to "section" in order to list only subsection. Will ignore other content such as normal pages. Parameter "depth" controls the level to which the content is listed. Defaults to two if not set. Fixes lowRISC#1419 Signed-off-by: Tobias Wölfel <[email protected]>
- Loading branch information
Showing
8 changed files
with
66 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.sectioncontent { | ||
li { | ||
list-style-type: none; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ | |
@import "highlight"; | ||
@import "menu"; | ||
@import "parents"; | ||
@import "sectioncontent"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<div class="sectioncontent"> | ||
{{- $contentType := "all"}} | ||
{{- if eq (.Get "type") "section" }} | ||
{{- $contentType = "section" }} | ||
{{- end}} | ||
{{- $depthLimit := 2 }} | ||
{{- with .Get "depth" }} | ||
{{- $depthLimit = . }} | ||
{{- end }} | ||
|
||
{{- $startSection := .Page.Page }} | ||
<ul> | ||
{{- range .Page.Pages }} | ||
{{- template "subsection-loop" dict "startSection" $startSection "currentSection" . "contentType" $contentType "depthLimit" $depthLimit "depthCnt" 0 }} | ||
{{- end }} | ||
</ul> | ||
</div> | ||
|
||
{{- define "subsection-loop" }} | ||
{{- $startSection := .startSection }} | ||
{{- $currentSection := .currentSection }} | ||
{{- $contentType := .contentType }} | ||
{{- $depthLimit := .depthLimit }} | ||
{{- $depthCnt := add .depthCnt 1 }} | ||
|
||
{{- with .startSection }} | ||
<li> | ||
{{- with $currentSection }} | ||
{{- if (or (not (eq $contentType "section")) .IsSection) }} | ||
{{- if .LinkTitle }} | ||
<a href="{{.RelPermalink}}">{{- .LinkTitle }}</a> | ||
{{- else }} | ||
{{- replace .File.Dir .Parent.File.Dir "" | replaceRE "/" "-" | replaceRE "-$" ":" }} | ||
<a href="{{.RelPermalink}}">{{- .File.TranslationBaseName }}</a> | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
{{- if lt $depthCnt $depthLimit }} | ||
<ul> | ||
{{- $subsc := newScratch }} | ||
{{- range $currentSection.Pages }} | ||
{{- template "subsection-loop" dict "startSection" $startSection "currentSection" . "contentType" $contentType "depthLimit" $depthLimit "depthCnt" $depthCnt}} | ||
{{- end }} | ||
</ul> | ||
{{- end }} | ||
</li> | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters