-
-
Notifications
You must be signed in to change notification settings - Fork 746
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rewrite: generate settings documentation
- Loading branch information
hugsy
committed
Nov 11, 2022
1 parent
8713e3f
commit af63b4d
Showing
2 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
SETTINGS_FILE="$(mktemp)" | ||
GEF_DIR="$(pwd)" | ||
GEF_MKDOC_YML="${GEF_DIR}/mkdocs.yml" | ||
GEF_DOCS_DIR="${GEF_DIR}/docs/settings" | ||
|
||
rm -fr -- "${GEF_DOCS_DIR}" | ||
mkdir -- "${GEF_DOCS_DIR}" | ||
rm -f -- ~/.gef.rc | ||
|
||
echo "[+] Collect available settings" | ||
gdb -q -ex 'gef config gef.disable_color 1' -ex 'gef config' -ex quit | awk '{print $1}' | sed '1,3d' > ${SETTINGS_FILE} | ||
|
||
echo "[+] Add the reference to mkdocs" | ||
echo "- Settings:" >> ${GEF_MKDOC_YML} | ||
|
||
echo "[+] Create documentation for settings" | ||
while read setting_long | ||
do | ||
command=$(echo ${setting_long} | cut -d . -f1) | ||
fname="${GEF_DOCS_DIR}/${command}.md" | ||
if [ ! -f ${fname} ]; then | ||
echo "# Settings for command \`${command}\`\n\n" > $fname | ||
echo " - ${command}: settings/${command}.md" >> ${GEF_MKDOC_YML} | ||
fi | ||
done < ${SETTINGS_FILE} | ||
|
||
gdb -q \ | ||
-ex "gef config gef.disable_color 1" \ | ||
-ex "pi for k,v in gef.config.items(): open(f'${GEF_DOCS_DIR}/{k.split(\".\",1)[0]}.md', 'a+').write(f''' | ||
## Setting \`{k}\`\n\n | ||
Type: \`{v.type.__name__}\`\n | ||
Default: \`{v.value}\`\n | ||
Description:\n> {v.description}\n | ||
''')" \ | ||
-ex quit > /dev/null |