Makefile : Add doc generation.
This commit is contained in:
parent
6de0dc0efa
commit
f8d6b90c75
2
.Bashrc
2
.Bashrc
|
@ -1,3 +1,3 @@
|
||||||
for file in .config/linux/system/module/common/bash/module/*; do
|
for file in module/common/bash/module/*; do
|
||||||
source ${file}
|
source ${file}
|
||||||
done
|
done
|
||||||
|
|
|
@ -16,6 +16,12 @@ Command|Description
|
||||||
---|---
|
---|---
|
||||||
`emulator [NAME]`|Start an Android emulator. Default name is `main`.
|
`emulator [NAME]`|Start an Android emulator. Default name is `main`.
|
||||||
|
|
||||||
|
## App.
|
||||||
|
|
||||||
|
Command|Description
|
||||||
|
---|---
|
||||||
|
`steam_link`| Start steam in Steam Link mode.
|
||||||
|
|
||||||
## Archive.
|
## Archive.
|
||||||
|
|
||||||
Command|Description
|
Command|Description
|
||||||
|
@ -36,7 +42,6 @@ Command|Description
|
||||||
Command|Description
|
Command|Description
|
||||||
---|---
|
---|---
|
||||||
`ask <QUERY>`|Ask general AI.
|
`ask <QUERY>`|Ask general AI.
|
||||||
`ask_code <QUERY>`|Ask code AI.
|
|
||||||
|
|
||||||
## Battery.
|
## Battery.
|
||||||
|
|
||||||
|
@ -288,6 +293,8 @@ Command|Description
|
||||||
`nix_shell [NAME]`|Spawn shell with specified nix environment. Uses flake.nix in current dir by default.
|
`nix_shell [NAME]`|Spawn shell with specified nix environment. Uses flake.nix in current dir by default.
|
||||||
`nix_tmpshell <PACKAGES>`|Spawn nix-shell with specified packages.
|
`nix_tmpshell <PACKAGES>`|Spawn nix-shell with specified packages.
|
||||||
`nix_live`| Build live image.
|
`nix_live`| Build live image.
|
||||||
|
`nix_generations`| List nixos generations.
|
||||||
|
`nixdroid_switch`| Switch nix-on-droid.
|
||||||
|
|
||||||
## Notify.
|
## Notify.
|
||||||
|
|
||||||
|
|
54
.doc/Generate.sh
Executable file
54
.doc/Generate.sh
Executable file
|
@ -0,0 +1,54 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
self=$(realpath .)
|
||||||
|
cd ${self%/*}
|
||||||
|
|
||||||
|
IFS=$'\n'
|
||||||
|
file="Bash.md"
|
||||||
|
|
||||||
|
# Print title.
|
||||||
|
echo "# Bash reference file." > "${file}"
|
||||||
|
echo >> "${file}"
|
||||||
|
|
||||||
|
# Print help info.
|
||||||
|
echo "To get help with usage info run:" >> "${file}"
|
||||||
|
echo >> "${file}"
|
||||||
|
echo '```text' >> "${file}"
|
||||||
|
echo '$ help <COMMAND>' >> "${file}"
|
||||||
|
echo >> "${file}"
|
||||||
|
echo "or" >> "${file}"
|
||||||
|
echo >> "${file}"
|
||||||
|
echo '$ h <COMMAND>' >> "${file}"
|
||||||
|
echo '```' >> "${file}"
|
||||||
|
echo >> "${file}"
|
||||||
|
|
||||||
|
# Fill with data.
|
||||||
|
for module in $(find_module); do
|
||||||
|
# Skip if no functions.
|
||||||
|
[[ "$(find_function ${module} | grep -v ^_)" = "" ]] && continue
|
||||||
|
|
||||||
|
# Print module title.
|
||||||
|
echo "## ${module^}." >> "${file}"
|
||||||
|
echo >> "${file}"
|
||||||
|
|
||||||
|
# Print table title.
|
||||||
|
echo "Command|Description" >> "${file}"
|
||||||
|
echo "---|---" >> "${file}"
|
||||||
|
|
||||||
|
for fun in $(find_function ${module}); do
|
||||||
|
# Skip private functions.
|
||||||
|
[[ "${fun}" =~ ^_.* ]] && continue
|
||||||
|
|
||||||
|
# Parse help info.
|
||||||
|
desc="$(help ${fun} | grep -v Usage\: | tr '\n' ' ')"
|
||||||
|
usage="$(help ${fun} | grep Usage\: | sed -e s\/Usage\:\ \/\/)"
|
||||||
|
|
||||||
|
# Use function name if no usage info available.
|
||||||
|
[[ "${usage}" = "" ]] && usage="${fun}"
|
||||||
|
|
||||||
|
# Write to file.
|
||||||
|
[[ "${desc}" != "" ]] && echo "\`${usage}\`|${desc}" >> "${file}"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo >> "${file}"
|
||||||
|
done
|
|
@ -1,53 +1,4 @@
|
||||||
# Generate a markdown file with all the help info.
|
# Generate a markdown file with all the help info.
|
||||||
# Outputs to `~/.doc/Bash.md`.
|
# Outputs to `.doc/Bash.md`.
|
||||||
function doc_bash() {
|
function doc_bash() {
|
||||||
local IFS=$'\n'
|
|
||||||
local file="${HOME}/.doc/Bash.md"
|
|
||||||
|
|
||||||
# Print title.
|
|
||||||
echo "# Bash reference file." > "${file}"
|
|
||||||
echo >> "${file}"
|
|
||||||
|
|
||||||
# Print help info.
|
|
||||||
echo "To get help with usage info run:" >> "${file}"
|
|
||||||
echo >> "${file}"
|
|
||||||
echo '```text' >> "${file}"
|
|
||||||
echo '$ help <COMMAND>' >> "${file}"
|
|
||||||
echo >> "${file}"
|
|
||||||
echo "or" >> "${file}"
|
|
||||||
echo >> "${file}"
|
|
||||||
echo '$ h <COMMAND>' >> "${file}"
|
|
||||||
echo '```' >> "${file}"
|
|
||||||
echo >> "${file}"
|
|
||||||
|
|
||||||
# Fill with data.
|
|
||||||
for module in $(find_module); do
|
|
||||||
# Skip if no functions.
|
|
||||||
[[ "$(find_function ${module} | grep -v ^_)" = "" ]] && continue
|
|
||||||
|
|
||||||
# Print module title.
|
|
||||||
echo "## ${module^}." >> "${file}"
|
|
||||||
echo >> "${file}"
|
|
||||||
|
|
||||||
# Print table title.
|
|
||||||
echo "Command|Description" >> "${file}"
|
|
||||||
echo "---|---" >> "${file}"
|
|
||||||
|
|
||||||
for fun in $(find_function ${module}); do
|
|
||||||
# Skip private functions.
|
|
||||||
[[ "${fun}" =~ ^_.* ]] && continue
|
|
||||||
|
|
||||||
# Parse help info.
|
|
||||||
local desc="$(help ${fun} | grep -v Usage\: | tr '\n' ' ')"
|
|
||||||
local usage="$(help ${fun} | grep Usage\: | sed -e s\/Usage\:\ \/\/)"
|
|
||||||
|
|
||||||
# Use function name if no usage info available.
|
|
||||||
[[ "${usage}" = "" ]] && usage="${fun}"
|
|
||||||
|
|
||||||
# Write to file.
|
|
||||||
[[ "${desc}" != "" ]] && echo "\`${usage}\`|${desc}" >> "${file}"
|
|
||||||
done
|
|
||||||
|
|
||||||
echo >> "${file}"
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue