diff options
author | Ilya Mashchenko <ilya@netdata.cloud> | 2020-02-09 02:45:41 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-08 15:45:41 -0800 |
commit | f4423a361bcae40ceef7ca13a441d54154e45d86 (patch) | |
tree | c405d811469cb95e704866d077983147bf4f4c8a /docs | |
parent | 666101a213d9f0036a0b9a5d84fcada5618dd66a (diff) |
/docs/generator: add an option to use last dir name for page name (#7997)
* /docs/generator/buildyaml.sh: add `useLastDirAsPageName` option to the navpart and use it for go.d.plugin and python.d.plugin modules
* /docs/generator/buildyaml.sh: do not use negative array indexes
Diffstat (limited to 'docs')
-rwxr-xr-x | docs/generator/buildyaml.sh | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/docs/generator/buildyaml.sh b/docs/generator/buildyaml.sh index d382233ea8..a68c021351 100755 --- a/docs/generator/buildyaml.sh +++ b/docs/generator/buildyaml.sh @@ -8,6 +8,14 @@ language="${3}" cd ${GENERATOR_DIR}/${docs_dir} +# getlastdir parses file path and returns last directory name. +# It expects path to be not empty , '/' as a delimeter and at least one '/' in the path. +getlastdir() { + local IFS=/ + read -ra array <<< "$1" + echo "${array[((${#array[@]} - 2))]}" +} + # create yaml nav subtree with all the files directly under a specific directory # arguments: # tabs - how deep do we show it in the hierarchy. Level 1 is the top level, max should probably be 3 @@ -24,6 +32,7 @@ navpart() { section=$4 maxdepth=$5 excludefirstlevel=$6 + useLastDirAsPageName=$7 spc="" i=1 @@ -37,12 +46,18 @@ navpart() { if [ -z "$maxdepth" ]; then maxdepth=1; fi if [[ -n $excludefirstlevel ]]; then mindepth=2; else mindepth=1; fi - for f in $(find $dir -mindepth $mindepth -maxdepth $maxdepth -name "${file}.md" -printf '%h|%d|%p\n' | sort -t '|' -n | awk -F '|' '{print $3}'); do + local pagename + for f in $(find "$dir" -mindepth $mindepth -maxdepth $maxdepth -name "${file}.md" -printf '%h|%d|%p\n' | sort -t '|' -n | awk -F '|' '{print $3}'); do # If I'm adding a section, I need the child links to be one level deeper than the requested level in "tabs" + pagename="'$f'" + if [ -n "$useLastDirAsPageName" ]; then + pagename="'$(getlastdir "$f")' : '$f'" + fi + if [ -z "$section" ]; then - echo "$spc- '$f'" + echo "$spc- $pagename" else - echo "$spc - '$f'" + echo "$spc - $pagename" fi done } @@ -223,12 +238,12 @@ navpart 2 collectors/plugins.d "" "External plugins" echo -ne " - Go: - 'collectors/go.d.plugin/README.md' " -navpart 4 collectors/go.d.plugin "" "Modules" 3 excludefirstlevel +navpart 4 collectors/go.d.plugin "" "Modules" 3 excludefirstlevel useLastDirAsPageName echo -ne " - Python: - 'collectors/python.d.plugin/README.md' " -navpart 4 collectors/python.d.plugin "" "Modules" 3 excludefirstlevel +navpart 4 collectors/python.d.plugin "" "Modules" 3 excludefirstlevel useLastDirAsPageName echo -ne " - Node.js: - 'collectors/node.d.plugin/README.md' |