salt/doc/apidoc-saltmods.sh
Elias Probst 34fb50b134
Fix typos (the the > the) (#52711)
* Fix typos (`the the` > `the`)

It looks like humans aren't only very bad at recognizing a double `the` in a sentence when reading [1], but they're also very good at sneaking them in unintentionally without noticing.

Fix this by running:
```
ack --ignore-dir=doc/man --ignore-dir=doc/topics/releases -i 'the the\W' -l | xargs sed -i 's|the the\(\W\)|the\1|g'
```

[1] Eye movements and word skipping during reading: Effects of word length and predictability: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3543826/

* Blacken changed files

* Blacken changed files

* Re-add unintentional delete

* Bad merge fix

* Fix broken docstring

* Another try

* pre-commit should pass now?

Co-authored-by: Daniel A. Wozniak <dwozniak@saltstack.com>
Co-authored-by: Wayne Werner <wwerner@saltstack.com>
2020-04-28 10:02:41 -07:00

81 lines
1.6 KiB
Bash
Executable file

#!/bin/sh
MOD_DIRS='
auth
beacons
clouds
engines
executors
file_server
modules
netapi
output
pillar
proxy
queues
renderers
returners
roster
runners
sdb
thorium
serializers
states
tops
wheel'
build_stubs() {
[ $# -eq 0 ] && { printf 'Module names are required.' 1>&2; return 1; }
local outdir
while [ -n $1 ]; do
outdir="ref/${1}/all"
mkdir -p "$outdir"
sphinx-apidoc --separate -o "${outdir}" $(get_excludes "$1")
find "$outdir" '(' \
-path 'ref/*/all/salt.*.*.rst' \
-o -name 'index.rst' \
')' -prune \
-o -type f -print0 \
| xargs -0 rm
find "$outdir" -type f -print0 \
| xargs -0 -r -I@ -n1 sh -c \
'sed -e "/:show-inheritance:/d" @ > "@.new" && mv -- "@.new" "@"'
shift
done
}
get_excludes() {
# This is a tad convoluted. We need to list all top-level files and
# directories in the main Salt dir _except_ for the main __init__.py file
# and the module directory for the module we're building for.
# ...that way sphinx-apidoc will exclude them from the build. (o_O)
exclude="${1:?Dirname to exclude is required.}"
find ../ \
'(' \
-path '*/.git' \
-o -path '../[!s]*/*' \
-o -path '../salt/__init__.py' \
-o -path '../*/*/*' \
')' -prune \
-o '(' \
-type d \
-o -path '../*.py' \
-o -path '../salt/*.py' \
')' -print \
| sed -e '/^\.\.\/salt$/d' \
| sed -e '/^\.\.\/salt\/'"$exclude"'$/d'
}
main() {
build_stubs $(printf '%s\n' "$MOD_DIRS")
}
main "$@"