Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: rewrite with mkdocs and add search #363

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Build and Publish

permissions:
contents: write

on:
push:
tags:
- "*"

jobs:
deploy-docs:
name: Deploy docs
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@v3

- name: Deploy docs
uses: mhausenblas/mkdocs-deploy-gh-pages@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CONFIG_FILE: docs/mkdocs.yml
REQUIREMENTS: docs/requirements.txt
EXTRA_PACKAGES: build-base
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
vendor/
/.glide
.venv
15 changes: 15 additions & 0 deletions docs/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Documentation Getting Started

Documentation is written with [Material for MkDocs](https://squidfunk.github.io/mkdocs-material/). Python is required to build the documentation.

To setup a development environment:

```sh
python3 -m venv .venv

source .venv/bin/activate

pip install -r requirements.txt

mkdocs serve
```
1 change: 0 additions & 1 deletion docs/_config.yml

This file was deleted.

2 changes: 1 addition & 1 deletion docs/crypto.md → docs/docs/advanced/crypto.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Cryptographic and Security Functions
# Cryptographic and Security

Sprig provides a couple of advanced cryptographic functions.

Expand Down
2 changes: 1 addition & 1 deletion docs/network.md → docs/docs/advanced/network.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Network Functions
# Network

Sprig network manipulation functions.

Expand Down
2 changes: 1 addition & 1 deletion docs/os.md → docs/docs/advanced/os.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# OS Functions
# OS

_WARNING:_ These functions can lead to information leakage if not used
appropriately.
Expand Down
2 changes: 1 addition & 1 deletion docs/reflection.md → docs/docs/advanced/reflection.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Reflection Functions
# Reflection

Sprig provides rudimentary reflection tools. These help advanced template
developers understand the underlying Go type information for a particular value.
Expand Down
4 changes: 2 additions & 2 deletions docs/semver.md → docs/docs/advanced/semver.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Semantic Version Functions
# Semantic

Some version schemes are easily parseable and comparable. Sprig provides functions
for working with [SemVer 2](http://semver.org) versions.
Expand Down Expand Up @@ -47,7 +47,7 @@ A more robust comparison function is provided as `semverCompare`. It returns `tr
the constraint matches, or `false` if it does not match. This version supports version ranges:

- `semverCompare "1.2.3" "1.2.3"` checks for an exact match
- `semverCompare "^1.2.0" "1.2.3"` checks that the major and minor versions match, and that the patch
- `semverCompare "^1.2.0" "1.2.3"` checks that the major and minor versions match, and that the patch
number of the second version is _greater than or equal to_ the first parameter.

The SemVer functions use the [Masterminds semver library](https://github.com/Masterminds/semver),
Expand Down
2 changes: 1 addition & 1 deletion docs/uuid.md → docs/docs/advanced/uuid.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# UUID Functions
# UUID

Sprig can generate UUID v4 universally unique IDs.

Expand Down
2 changes: 1 addition & 1 deletion docs/conversion.md → docs/docs/functions/conversion.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Type Conversion Functions
# Type Conversion

The following type conversion functions are provided by Sprig:

Expand Down
2 changes: 1 addition & 1 deletion docs/date.md → docs/docs/functions/date.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Date Functions
# Date

## now

Expand Down
2 changes: 1 addition & 1 deletion docs/defaults.md → docs/docs/functions/defaults.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Default Functions
# Default

Sprig provides tools for setting default values for templates.

Expand Down
2 changes: 1 addition & 1 deletion docs/dicts.md → docs/docs/functions/dicts.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Dictionaries and Dict Functions
# Dictionaries and Dict

Sprig provides a key/value storage type called a `dict` (short for "dictionary",
as in Python). A `dict` is an _unorder_ type.
Expand Down
2 changes: 1 addition & 1 deletion docs/encoding.md → docs/docs/functions/encoding.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Encoding Functions
# Encoding

Sprig has the following encoding and decoding functions:

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Flow Control Functions
# Flow Control

## fail

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Integer Slice Functions
# Integer Slice

## until

Expand Down
2 changes: 1 addition & 1 deletion docs/lists.md → docs/docs/functions/lists.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Lists and List Functions
# Lists and List

Sprig provides a simple `list` type that can contain arbitrary sequential lists
of data. This is similar to arrays or slices, but lists are designed to be used
Expand Down
2 changes: 1 addition & 1 deletion docs/math.md → docs/docs/functions/math.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Integer Math Functions
# Integer Math

The following math functions operate on `int64` values.

Expand Down
2 changes: 1 addition & 1 deletion docs/mathf.md → docs/docs/functions/mathf.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Float Math Functions
# Float Math

All math functions operate on `float64` values.

Expand Down
2 changes: 1 addition & 1 deletion docs/paths.md → docs/docs/functions/paths.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Path and Filepath Functions
# Path and Filepath

While Sprig does not grant access to the filesystem, it does provide functions
for working with strings that follow file path conventions.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# String Slice Functions
# String Slice

These function operate on or generate slices of strings. In Go, a slice is a
growable array. In Sprig, it's a special case of a `list`.
Expand Down
6 changes: 3 additions & 3 deletions docs/strings.md → docs/docs/functions/strings.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# String Functions
# String

Sprig has a number of string manipulation functions.

Expand Down Expand Up @@ -459,6 +459,6 @@ The above produces `1\.2\.3`

## See Also...

The [Conversion Functions](conversion.html) contain functions for converting
strings. The [String Slice Functions](string_slice.html) contains functions
The [Conversion Functions](./conversion.md) contain functions for converting
strings. The [String Slice Functions](./string-slice.md) contains functions
for working with an array of strings.
2 changes: 1 addition & 1 deletion docs/url.md → docs/docs/functions/url.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# URL Functions
# URL

## urlParse
Parses string for URL and produces dict with URL parts
Expand Down
28 changes: 28 additions & 0 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Sprig Function Documentation

The Sprig library provides over 70 template functions for Go's template language.

## Basic Functions

- [String Functions](./functions/strings.md): `trim`, `wrap`, `randAlpha`, `plural`, etc.
- [String List Functions](./functions/string-slice.md): `splitList`, `sortAlpha`, etc.
- [Integer Math Functions](./functions/math.md): `add`, `max`, `mul`, etc.
- [Integer Slice Functions](./functions/integer-slice.md): `until`, `untilStep`
- [Float Math Functions](./functions/mathf.md): `addf`, `maxf`, `mulf`, etc.
- [Date Functions](./functions/date.md): `now`, `date`, etc.
- [Defaults Functions](./functions/defaults.md): `default`, `empty`, `coalesce`, `fromJson`, `toJson`, `toPrettyJson`, `toRawJson`, `ternary`
- [Encoding Functions](./functions/encoding.md): `b64enc`, `b64dec`, etc.
- [Lists and List Functions](./functions/lists.md): `list`, `first`, `uniq`, etc.
- [Dictionaries and Dict Functions](./functions/dicts.md): `get`, `set`, `dict`, `hasKey`, `pluck`, `dig`, `deepCopy`, etc.
- [Type Conversion Functions](./functions/conversion.md): `atoi`, `int64`, `toString`, etc.
- [Path and Filepath Functions](./functions/paths.md): `base`, `dir`, `ext`, `clean`, `isAbs`, `osBase`, `osDir`, `osExt`, `osClean`, `osIsAbs`
- [Flow Control Functions](./functions/flow-control.md): `fail`

## Advanced Functions

- [UUID Functions](./advanced/uuid.md): `uuidv4`
- [OS Functions](./advanced/os.md): `env`, `expandenv`
- [Version Comparison Functions](./advanced/semver.md): `semver`, `semverCompare`
- [Reflection](./advanced/reflection.md): `typeOf`, `kindIs`, `typeIsLike`, etc.
- [Cryptographic and Security Functions](./advanced/crypto.md): `derivePassword`, `sha256sum`, `genPrivateKey`, etc.
- [Network](./advanced/network.md): `getHostByName`
24 changes: 0 additions & 24 deletions docs/index.md

This file was deleted.

26 changes: 26 additions & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
site_name: Sprig
site_url: https://github.com/Masterminds/sprig
repo_name: Sprig
repo_url: https://github.com/Masterminds/sprig
use_directory_urls: true
theme:
name: material
features:
- content.code.annotate
- navigation.instant
- navigation.expand
- navigation.sections
- navigation.tabs.sticky

plugins:
- tags
- search

markdown_extensions:
- def_list
- pymdownx.highlight
- pymdownx.superfences
- admonition
- attr_list
- pymdownx.tabbed
- pymdownx.superfences
26 changes: 26 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
certifi==2022.12.7
charset-normalizer==3.0.1
click==8.1.3
colorama==0.4.6
ghp-import==2.1.0
idna==3.4
importlib-metadata==6.0.0
Jinja2==3.1.2
Markdown==3.3.7
MarkupSafe==2.1.2
mergedeep==1.3.4
mkdocs==1.4.2
mkdocs-material==9.0.13
mkdocs-material-extensions==1.1.1
packaging==23.0
Pygments==2.14.0
pymdown-extensions==9.9.2
python-dateutil==2.8.2
PyYAML==6.0
pyyaml_env_tag==0.1
regex==2022.10.31
requests==2.28.2
six==1.16.0
urllib3==1.26.14
watchdog==2.2.1
zipp==3.14.0