Cleanup, sort and update README
This commit is contained in:
parent
5aa6e7f944
commit
ccad95ef02
25
README.md
25
README.md
@ -1 +1,24 @@
|
||||
## Hugo tags generator
|
||||
## Hugo help tags generator
|
||||
|
||||
### Usage
|
||||
|
||||
1. Install dependency: https://mikefarah.gitbook.io/yq/
|
||||
2. Clone hugo docs and checkout to your hugo version
|
||||
|
||||
```bash
|
||||
git clone https://github.com/gohugoio/hugoDocs/
|
||||
git checkout v0.147.5
|
||||
```
|
||||
3. Generate tags
|
||||
|
||||
```bash
|
||||
cd /path/to/your/hugo/website
|
||||
hugotags.sh /path/to/cloneOf/hugoDocs/content/en > tags
|
||||
```
|
||||
|
||||
### vim
|
||||
|
||||
All tag commands and mapping works good. The one I use often are below
|
||||
* `Ctrl w Ctrl ]` => Open the tag in horizontal split
|
||||
* `Ctrl w g Ctrl ]` => Same as above but if there are more than one tag, shows
|
||||
a list instead going to the first one
|
||||
|
56
hugotags.sh
56
hugotags.sh
@ -2,57 +2,45 @@
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Dependency: https://mikefarah.gitbook.io/yq/
|
||||
|
||||
# Clone from https://github.com/gohugoio/hugoDocs/ and checkout the tag of your
|
||||
# hugo version
|
||||
# Path to <hugoDocsDir>/content/en/
|
||||
hugo_docs_path="$1"
|
||||
|
||||
cd "$hugo_docs_path"
|
||||
|
||||
add_tag() {
|
||||
local tagname fname
|
||||
tagname="$1"
|
||||
fname="$2"
|
||||
local tagname fname
|
||||
tagname="$1"
|
||||
fname="$2"
|
||||
|
||||
# Tags file format: https://vimhelp.org/tagsrch.txt.html#ctags
|
||||
printf "%s\t%s\t2\n" "$tagname" "$hugo_docs_path/$fname"
|
||||
# Tags file format: https://vimhelp.org/tagsrch.txt.html#ctags
|
||||
printf "%s\t%s\t2\n" "$tagname" "$hugo_docs_path/$fname"
|
||||
}
|
||||
|
||||
add_methods() {
|
||||
local f title
|
||||
local f title
|
||||
|
||||
for f in methods/*/*md; do
|
||||
if [ "$(basename "$f")" = _index.md ]; then
|
||||
continue
|
||||
fi
|
||||
for f in methods/*/*md; do
|
||||
|
||||
title="$(yq --front-matter extract .title "$f")"
|
||||
add_tag "$title" "$f"
|
||||
|
||||
done
|
||||
title="$(yq --front-matter extract .title "$f")"
|
||||
add_tag "$title" "$f"
|
||||
done
|
||||
}
|
||||
|
||||
add_funcs() {
|
||||
local f halias
|
||||
local f halias
|
||||
|
||||
for f in functions/*/*md; do
|
||||
if [ "$(basename "$f")" = _index.md ]; then
|
||||
continue
|
||||
fi
|
||||
for f in functions/*/*md; do
|
||||
|
||||
add_tag "$(basename "${f%.md}")" "$f"
|
||||
add_tag "$(basename "${f%.md}")" "$f"
|
||||
|
||||
halias="$(yq --front-matter extract .params.functions_and_methods.aliases "$f" |
|
||||
grep -v -F -e null -e '[]' -e ',' || exit 0)" # Remove invalid/missing/multiple aliases
|
||||
halias="$(yq --front-matter extract .params.functions_and_methods.aliases[0] "$f")"
|
||||
|
||||
if [ -n "$halias" ]; then
|
||||
halias="${halias:1:${#halias}-2}"
|
||||
add_tag "$halias" "$f"
|
||||
fi
|
||||
done
|
||||
if [ "$halias" != "null" ]; then
|
||||
add_tag "$halias" "$f"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
add_methods
|
||||
add_funcs
|
||||
{
|
||||
add_methods
|
||||
add_funcs
|
||||
} | grep -v _index.md | sort --ignore-case
|
||||
|
Loading…
x
Reference in New Issue
Block a user