Skip to content

Commit

Permalink
rewrite: generate settings documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
hugsy committed Nov 11, 2022
1 parent 8713e3f commit af63b4d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/generate-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jobs:
- name: Regenerate GEF API file
run: |
echo "source $(pwd)/gef.py" > ~/.gdbinit
cat ~/.gdbinit
bash scripts/generate-api-docs.sh
bash scripts/generate-settings-docs.sh
bash scripts/generate-coverage-docs.sh
- name: Build and publish the docs
run: |
Expand Down
39 changes: 39 additions & 0 deletions scripts/generate-settings-docs.sh
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

0 comments on commit af63b4d

Please sign in to comment.