From 83469c437f4996ba355428191ba9668c249a0b5f Mon Sep 17 00:00:00 2001 From: Robert Kaussow Date: Fri, 27 Oct 2023 21:38:23 +0200 Subject: [PATCH] docs: use a propertylist to document shortcode attributes (#732) --- exampleSite/content/en/shortcodes/buttons.md | 11 +++++- exampleSite/content/en/shortcodes/columns.md | 20 ++++++----- exampleSite/content/en/shortcodes/expand.md | 36 +++++++++---------- exampleSite/content/en/shortcodes/hints.md | 16 ++++----- exampleSite/content/en/shortcodes/icons.md | 6 ++-- .../content/en/shortcodes/images/_index.md | 17 +++++---- exampleSite/content/en/shortcodes/includes.md | 31 ++++++++-------- exampleSite/content/en/shortcodes/katex.md | 14 ++++++-- exampleSite/content/en/shortcodes/mermaid.md | 12 ++++++- exampleSite/content/en/shortcodes/progress.md | 17 +++++---- .../content/en/shortcodes/propertylist.md | 16 ++++----- exampleSite/content/en/shortcodes/tabs.md | 2 ++ exampleSite/content/en/shortcodes/toc-tree.md | 2 ++ exampleSite/content/en/shortcodes/toc.md | 19 +++++----- .../data/properties/shortcode-buttons.yaml | 19 ++++++++++ .../data/properties/shortcode-columns.yaml | 7 ++++ .../data/properties/shortcode-hints.yaml | 15 ++++++++ .../data/properties/shortcode-images.yaml | 19 ++++++++++ .../data/properties/shortcode-includes.yaml | 19 ++++++++++ .../data/properties/shortcode-katex.yaml | 6 ++++ .../data/properties/shortcode-mermaid.yaml | 6 ++++ .../data/properties/shortcode-progress.yaml | 15 ++++++++ .../properties/shortcode-propertylist.yaml | 15 ++++++++ .../data/properties/shortcode-toc.yaml | 10 ++++++ 24 files changed, 256 insertions(+), 94 deletions(-) create mode 100644 exampleSite/data/properties/shortcode-buttons.yaml create mode 100644 exampleSite/data/properties/shortcode-columns.yaml create mode 100644 exampleSite/data/properties/shortcode-hints.yaml create mode 100644 exampleSite/data/properties/shortcode-images.yaml create mode 100644 exampleSite/data/properties/shortcode-includes.yaml create mode 100644 exampleSite/data/properties/shortcode-katex.yaml create mode 100644 exampleSite/data/properties/shortcode-mermaid.yaml create mode 100644 exampleSite/data/properties/shortcode-progress.yaml create mode 100644 exampleSite/data/properties/shortcode-propertylist.yaml create mode 100644 exampleSite/data/properties/shortcode-toc.yaml diff --git a/exampleSite/content/en/shortcodes/buttons.md b/exampleSite/content/en/shortcodes/buttons.md index 009d3f0..87ee07f 100644 --- a/exampleSite/content/en/shortcodes/buttons.md +++ b/exampleSite/content/en/shortcodes/buttons.md @@ -4,11 +4,20 @@ title: Buttons Buttons are styled links that can lead to local page or external link. - +## Usage + + ```tpl {{}}Get Home{{}} {{}}Contribute{{}} ``` + +### Attributes + + + +{{< propertylist name=shortcode-buttons sort=name order=asc >}} + ## Example diff --git a/exampleSite/content/en/shortcodes/columns.md b/exampleSite/content/en/shortcodes/columns.md index 8302266..9f3053c 100644 --- a/exampleSite/content/en/shortcodes/columns.md +++ b/exampleSite/content/en/shortcodes/columns.md @@ -4,12 +4,6 @@ title: Columns The Columns shortcode can be used to organize content side-by-side (horizontally) for better readability. -## Attributes - -| Name | Description | default | -| --------------- | ------------------------------------------------ | ------- | -| size (optional) | size of the first column (small\|regular\|large) | regular | - ## Usage ```html @@ -29,11 +23,19 @@ Dolor sit, sumo unique argument um no ... {{}} ``` +### Attributes + + + +{{< propertylist name=shortcode-columns sort=name order=asc >}} + + + ## Example {{< columns >}} -## Left +### Left Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclimates investiture. Ornateness bland it ex enc, est yeti am bongo detract re. Pro ad prompts @@ -42,14 +44,14 @@ copious quo ad. Stet probates in duo. <---> -## Mid Content +### Mid Content Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclimates investiture. Ornateness bland it ex enc, est yeti am bongo detract re. <---> -## Right Content +### Right Content Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclimates investiture. Ornateness bland it ex enc, est yeti am bongo detract re. Pro ad prompts diff --git a/exampleSite/content/en/shortcodes/expand.md b/exampleSite/content/en/shortcodes/expand.md index 9dcd2fc..7330680 100644 --- a/exampleSite/content/en/shortcodes/expand.md +++ b/exampleSite/content/en/shortcodes/expand.md @@ -4,40 +4,38 @@ title: Expand Expand shortcode can help to decrease clutter on screen by hiding part of text. Expand content by clicking on it. -## Example +## Usage -### Default - - ```tpl {{}} -## Markdown content +### Markdown content Dolor sit, sumo unique ... {{}} ``` - + +It is also possible to use a custom label and symbol. + + + +```tpl +{{}} +### More markdown +Dolor sit, sumo unique ... +{{}} +``` + +## Example {{< expand >}} -## Markdown content +### Markdown content Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclimates investiture. Ornateness bland it ex enc, est yeti am bongo detract re. {{< /expand >}} -### With Custom Label - - -```tpl -{{}} -## Markdown content -Dolor sit, sumo unique ... -{{}} -``` - - {{< expand "Custom Label" "..." >}} -## More markdown +### More markdown Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclimates investiture. Ornateness bland it ex enc, est yeti am bongo detract re. Pro ad prompts diff --git a/exampleSite/content/en/shortcodes/hints.md b/exampleSite/content/en/shortcodes/hints.md index 51959a8..a4d728a 100644 --- a/exampleSite/content/en/shortcodes/hints.md +++ b/exampleSite/content/en/shortcodes/hints.md @@ -4,14 +4,6 @@ title: Hints Hint shortcode can be used as hint/alerts/notification block. -## Attributes - -| Name | Description | default | -| ---------------- | -------------------------------------------------------------------------------- | --------- | -| type | hint type | note | -| icon (optional) | custom icon to use,need to be an icon from an [SVG sprite](/features/icon-sets/) | undefined | -| title (optional) | hint title | undefined | - ## Usage @@ -24,6 +16,14 @@ Dolor sit, sumo unique argument um no. Gracie nominal id xiv. Romanesque acclima ``` +### Attributes + + + +{{< propertylist name=shortcode-hints sort=name order=asc >}} + + + ## Example {{< hint type=note >}} diff --git a/exampleSite/content/en/shortcodes/icons.md b/exampleSite/content/en/shortcodes/icons.md index 95c16d6..dfa3561 100644 --- a/exampleSite/content/en/shortcodes/icons.md +++ b/exampleSite/content/en/shortcodes/icons.md @@ -4,15 +4,17 @@ title: Icons Simple shortcode to include icons from SVG sprites outside of menus. +## Usage + ```tpl {{}} ``` -## Usage +## Example -| Result | Usage | +| Output | Code | | -------------------------- | -------------------------------- | | {{< icon "thumbs-up" >}} | `{{}}` | | {{< icon "thumbs-down" >}} | `{{}}` | diff --git a/exampleSite/content/en/shortcodes/images/_index.md b/exampleSite/content/en/shortcodes/images/_index.md index 951c686..01ba84e 100644 --- a/exampleSite/content/en/shortcodes/images/_index.md +++ b/exampleSite/content/en/shortcodes/images/_index.md @@ -46,15 +46,6 @@ resources: If you need more flexibility for your embedded images, you could use the `img` shortcode. It is using Hugo's [page resources](https://gohugo.io/content-management/page-resources/) and supports lazy loading of your images. -## Attributes - -| Name | Description | default | -| ---- | ------------------------------------------------------------ | ----------------- | -| name | name of the image resource defined in your front matter | empty | -| alt | description for displayed image | resource `.Title` | -| size | Thumbnail size (origin\|profile\|tiny\|small\|medium\|large) | empty | -| lazy | enable or disable image lazy loading | true | - ## Usage Define your resources in the page front matter, custom parameter `params.credits` is optional. @@ -74,6 +65,14 @@ resources: {{}} ``` +### Attributes + + + +{{< propertylist name=shortcode-images sort=name order=asc >}} + + + ## Example diff --git a/exampleSite/content/en/shortcodes/includes.md b/exampleSite/content/en/shortcodes/includes.md index 25ad079..de94631 100644 --- a/exampleSite/content/en/shortcodes/includes.md +++ b/exampleSite/content/en/shortcodes/includes.md @@ -2,28 +2,27 @@ title: Includes --- -{{< toc >}} - Include shortcode can include files of different types. By specifying a language, the included file will have syntax highlighting. +## Usage + ```tpl {{}} ``` -Attributes: +### Attributes -| Name | Description | Default | -| -------- | ----------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | -| file | path to the included file relative to the Hugo root | undefined | -| language | language for [syntax highlighting](https://gohugo.io/content-management/syntax-highlighting/#list-of-chroma-highlighting-languages) | undefined | -| type | special include type (`html,page`) | undefined (rendered as markdown) | -| options | highlighting [options](https://gohugo.io/content-management/syntax-highlighting/#highlight-shortcode) | `linenos=table` | + + +{{< propertylist name=shortcode-includes sort=name order=asc >}} + + -## Examples +## Example -### Markdown file (default) +### Example 1: Markdown file (default) If no other options are specified, files will be rendered as Markdown using the `RenderString` [function](https://gohugo.io/functions/renderstring/). @@ -43,7 +42,7 @@ If you include markdown files that should not get a menu entry, place them outsi -### Language files +### Example 2: Language files This method can be used to include source code files and keep them automatically up to date. @@ -60,9 +59,7 @@ Result: -### Special include types - -#### HTML +### Example 3: HTML HTML content will be filtered by the `safeHTML` filter and added to the rendered page output. @@ -73,9 +70,9 @@ HTML content will be filtered by the `safeHTML` filter and added to the rendered {{< include file="/static/_includes/example.html.part" type="html" >}} -#### Pages +### Example 4: Hugo Pages -In some situations, it can be helpful to include Markdown files that also contain shortcodes. While the [default method](#markdown-file-default) works fine to render plain Markdown, shortcodes are not parsed. The only way to get this to work is to use Hugo pages. There are several ways to structure these include pages, so whatever you do, keep in mind that Hugo needs to be able to render and serve these files as regular pages! How it works: +In some situations, it can be helpful to include Markdown files that also contain shortcodes. While the [default method](#example-1-markdown-file-default) works fine to render plain Markdown, shortcodes are not parsed. The only way to get this to work is to use Hugo pages. There are several ways to structure these include pages, so whatever you do, keep in mind that Hugo needs to be able to render and serve these files as regular pages! How it works: 1. First you need to create a directory **within** your content directory. For this example site `_includes` is used. 2. To prevent the theme from embedding the page in the navigation, create a file `_includes/_index.md` and add `geekdocHidden: true` to the front matter. diff --git a/exampleSite/content/en/shortcodes/katex.md b/exampleSite/content/en/shortcodes/katex.md index 4306c63..d1ed300 100644 --- a/exampleSite/content/en/shortcodes/katex.md +++ b/exampleSite/content/en/shortcodes/katex.md @@ -4,7 +4,7 @@ title: KaTeX [KaTeX](https://katex.org/) shortcode let you render math typesetting in markdown document. -## Example +## Usage ```latex {{}} @@ -12,6 +12,16 @@ f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi {{}} ``` +### Attributes + + + +{{< propertylist name=shortcode-katex sort=name order=asc >}} + + + +## Example + {{< katex display >}} @@ -20,4 +30,4 @@ f(x) = \int_{-\infty}^\infty\hat f(\xi)\,e^{2 \pi i \xi x}\,d\xi -KaTeX can be used inline, for example {{< katex >}}\pi(x){{< /katex >}} or used with the `display` parameter (see above). +KaTeX can be used inline, for example {{< katex >}}\pi(x){{< /katex >}} or used with the `display` parameter as above. diff --git a/exampleSite/content/en/shortcodes/mermaid.md b/exampleSite/content/en/shortcodes/mermaid.md index 6a644b8..0379ba8 100644 --- a/exampleSite/content/en/shortcodes/mermaid.md +++ b/exampleSite/content/en/shortcodes/mermaid.md @@ -4,7 +4,7 @@ title: Mermaid [Mermaid](https://mermaidjs.github.io/) is library for generating SVG charts and diagrams from text. -## Example +## Usage ```tpl @@ -22,6 +22,16 @@ sequenceDiagram {{}} ``` +### Attributes + + + +{{< propertylist name=shortcode-mermaid sort=name order=asc >}} + + + +## Example + {{< mermaid class="text-center" >}} diff --git a/exampleSite/content/en/shortcodes/progress.md b/exampleSite/content/en/shortcodes/progress.md index 2a863e1..e0009cf 100644 --- a/exampleSite/content/en/shortcodes/progress.md +++ b/exampleSite/content/en/shortcodes/progress.md @@ -4,20 +4,19 @@ title: Progress A progress bar shows how far a process has progressed. -## Attributes - -| Name | Description | default | -| ---------------- | -------------------------------------------------------------------------- | --------- | -| value | progress value | 0 | -| icon (optional) | icon to use, need to be an icon from an [SVG sprite](/features/icon-sets/) | undefined | -| title (optional) | progress title | undefined | - ## Usage - + ```tpl {{}} ``` + +### Attributes + + + +{{< propertylist name=shortcode-progress sort=name order=asc >}} + ## Example diff --git a/exampleSite/content/en/shortcodes/propertylist.md b/exampleSite/content/en/shortcodes/propertylist.md index d00c13c..1718b3b 100644 --- a/exampleSite/content/en/shortcodes/propertylist.md +++ b/exampleSite/content/en/shortcodes/propertylist.md @@ -4,14 +4,6 @@ title: Properties The property list shortcode creates a custom HTML description list that can be used to display properties or variables and general dependent information. The shortcode requires a data file in `data/properties/`, e.g. `data/properties/demo.yaml`. -## Attributes - -| Name | Description | default | -| ---------------- | ------------------------------------------------------ | --------- | -| name | name of the file from the `data/properties/` directory | undefined | -| sort (optional) | field name to use for sorting | undefined | -| order (optional) | sort order, only applied if `sort` is set | `asc` | - ## Usage @@ -28,6 +20,14 @@ The supported attributes can be taken from the following example: +### Attributes + + + +{{< propertylist name=shortcode-buttons sort=name order=asc >}} + + + ## Example diff --git a/exampleSite/content/en/shortcodes/tabs.md b/exampleSite/content/en/shortcodes/tabs.md index ed3a9cc..d0e768c 100644 --- a/exampleSite/content/en/shortcodes/tabs.md +++ b/exampleSite/content/en/shortcodes/tabs.md @@ -4,6 +4,8 @@ title: Tabs Tabs let you organize content by context, for example installation instructions for each supported platform. +## Usage + ```tpl {{}} diff --git a/exampleSite/content/en/shortcodes/toc-tree.md b/exampleSite/content/en/shortcodes/toc-tree.md index 406452e..27de09e 100644 --- a/exampleSite/content/en/shortcodes/toc-tree.md +++ b/exampleSite/content/en/shortcodes/toc-tree.md @@ -4,6 +4,8 @@ title: ToC-Tree The `toc-tree` shortcode will generate a Table of Content from a section file tree of your content directory. The root of the resulting ToC will be the page on which you define the shortcode. +## Usage + ```tpl {{}} diff --git a/exampleSite/content/en/shortcodes/toc.md b/exampleSite/content/en/shortcodes/toc.md index c1529a9..da8b7a3 100644 --- a/exampleSite/content/en/shortcodes/toc.md +++ b/exampleSite/content/en/shortcodes/toc.md @@ -4,21 +4,22 @@ title: ToC Simple wrapper to generate a page Table of Content from a shortcode. -**Attributes:** +## Usage -| Name | Description | Default | -| ------ | -------------------------- | ------------------------------------------------------------- | -| format | format of the returned ToC | html | - -**Usage:** - - + ```tpl {{}} ``` + +### Attributes + + + +{{< propertylist name=shortcode-toc sort=name order=asc >}} + -**Example:** +## Example {{< toc >}} diff --git a/exampleSite/data/properties/shortcode-buttons.yaml b/exampleSite/data/properties/shortcode-buttons.yaml new file mode 100644 index 0000000..71275c6 --- /dev/null +++ b/exampleSite/data/properties/shortcode-buttons.yaml @@ -0,0 +1,19 @@ +--- +properties: + - name: href + type: string + description: The URL to use as target of the button. + required: false + - name: relref + type: string + description: Executes the [relref](https://gohugo.io/functions/urls/relref/) Hugo function to resolve the relative permalink of the specified page. The result is set as the target of the button. + required: false + - name: class + type: list + description: List of space-separated CSS class names to apply. + required: false + - name: size + type: string + description: Preset of different button sizes. Supported values are `regular|large`. + required: false + devaultValue: regular diff --git a/exampleSite/data/properties/shortcode-columns.yaml b/exampleSite/data/properties/shortcode-columns.yaml new file mode 100644 index 0000000..77104b9 --- /dev/null +++ b/exampleSite/data/properties/shortcode-columns.yaml @@ -0,0 +1,7 @@ +--- +properties: + - name: size + type: string + description: Preset of different sizes for the _first_ column. Supported values are `small|regular|large`. + required: false + defaultValue: regular diff --git a/exampleSite/data/properties/shortcode-hints.yaml b/exampleSite/data/properties/shortcode-hints.yaml new file mode 100644 index 0000000..df472b4 --- /dev/null +++ b/exampleSite/data/properties/shortcode-hints.yaml @@ -0,0 +1,15 @@ +--- +properties: + - name: type + type: string + description: Type of the hint. Supported values are `note|tip|important|caution|warning`. + required: false + defaultValue: note + - name: icon + type: string + description: Icon to use. The value need to be an icon from an [SVG sprite](/features/icon-sets/). + required: false + - name: title + type: string + description: Title text of the hint. + required: false diff --git a/exampleSite/data/properties/shortcode-images.yaml b/exampleSite/data/properties/shortcode-images.yaml new file mode 100644 index 0000000..be5efa6 --- /dev/null +++ b/exampleSite/data/properties/shortcode-images.yaml @@ -0,0 +1,19 @@ +--- +properties: + - name: name + type: string + description: Mame of the image resource defined in page front matter. + required: true + - name: alt + type: string + description: Description text for the image. + required: false + - name: size + type: string + description: Thumbnail size. Supported values are `origin|profile|tiny|small|medium|large`. + required: false + - name: lazy + type: bool + description: Enable/disable lazy loading for the image. + required: false + defaultValue: true diff --git a/exampleSite/data/properties/shortcode-includes.yaml b/exampleSite/data/properties/shortcode-includes.yaml new file mode 100644 index 0000000..d5dc58d --- /dev/null +++ b/exampleSite/data/properties/shortcode-includes.yaml @@ -0,0 +1,19 @@ +--- +properties: + - name: file + type: string + description: Path of the file (relative to the Hugo root) to include. + required: true + - name: language + type: string + description: Language for [syntax highlighting](https://gohugo.io/content-management/syntax-highlighting/#list-of-chroma-highlighting-languages). + required: false + - name: type + type: string + description: Special include type. Supported values are `html|page`. If not set the included file is rendered as markdown. + required: false + - name: options + type: bool + description: highlighting [options](https://gohugo.io/content-management/syntax-highlighting/#highlight-shortcode). + required: false + defaultValue: linenos=table diff --git a/exampleSite/data/properties/shortcode-katex.yaml b/exampleSite/data/properties/shortcode-katex.yaml new file mode 100644 index 0000000..2dc0d89 --- /dev/null +++ b/exampleSite/data/properties/shortcode-katex.yaml @@ -0,0 +1,6 @@ +--- +properties: + - name: class + type: list + description: List of space-separated CSS class names to apply. + required: false diff --git a/exampleSite/data/properties/shortcode-mermaid.yaml b/exampleSite/data/properties/shortcode-mermaid.yaml new file mode 100644 index 0000000..2dc0d89 --- /dev/null +++ b/exampleSite/data/properties/shortcode-mermaid.yaml @@ -0,0 +1,6 @@ +--- +properties: + - name: class + type: list + description: List of space-separated CSS class names to apply. + required: false diff --git a/exampleSite/data/properties/shortcode-progress.yaml b/exampleSite/data/properties/shortcode-progress.yaml new file mode 100644 index 0000000..39d3cd0 --- /dev/null +++ b/exampleSite/data/properties/shortcode-progress.yaml @@ -0,0 +1,15 @@ +--- +properties: + - name: value + type: integer + description: Progress value. + required: false + defaultValue: 0 + - name: icon + type: string + description: Icon to use. The value need to be an icon from an [SVG sprite](/features/icon-sets/). + required: false + - name: title + type: string + description: Title text of the progress bar. + required: false diff --git a/exampleSite/data/properties/shortcode-propertylist.yaml b/exampleSite/data/properties/shortcode-propertylist.yaml new file mode 100644 index 0000000..4fe0fb2 --- /dev/null +++ b/exampleSite/data/properties/shortcode-propertylist.yaml @@ -0,0 +1,15 @@ +--- +properties: + - name: name + type: string + description: Name of the file from the `data/properties/` directory. + required: true + - name: sort + type: string + description: Field name to use for sorting. + required: false + - name: order + type: string + description: Sort order, only applied if `sort` is set. Supported values are `asc|desc`. + required: false + defaultValue: asc diff --git a/exampleSite/data/properties/shortcode-toc.yaml b/exampleSite/data/properties/shortcode-toc.yaml new file mode 100644 index 0000000..d5688c5 --- /dev/null +++ b/exampleSite/data/properties/shortcode-toc.yaml @@ -0,0 +1,10 @@ +--- +properties: + - name: format + type: string + description: | + Format of the returned ToC. The `html` format creates an HTML wrapper to enable the `geekdocToC` parameter that limits + the maximum ToC level to be displayed. This variant also automatically inserts a horizontal line after the ToC. The `raw` format + returns the unformatted ToC, the parameter `geekdocToC` does not work in this mode. Supported values are `html|raw`. + required: false + defaultValue: html