From 2397b18dff95ec90ff27acda776db7ad9c3f034e Mon Sep 17 00:00:00 2001 From: Javier Sagredo Date: Fri, 19 Jun 2026 00:49:51 +0200 Subject: [PATCH] Add --haddock to classgraph-plugin-flag.sh Optionally emit a -haddock ghc-option alongside the plugin flag. The plugin only harvests Haddock comments (the side-panel docs) when the target is compiled with -haddock, so this saves adding it by hand. Works in both the raw and --cabal forms; off by default. Co-Authored-By: Claude Opus 4.8 (1M context) --- classgraph-plugin-flag.sh | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/classgraph-plugin-flag.sh b/classgraph-plugin-flag.sh index 68f182f..a425045 100755 --- a/classgraph-plugin-flag.sh +++ b/classgraph-plugin-flag.sh @@ -56,6 +56,10 @@ Options: --package it is a 'package PKG' block. --package PKG Scope the --cabal stanza to the single package PKG. Only meaningful together with --cabal. + --haddock Also emit a -haddock ghc-option. The plugin only captures + Haddock comments (class/instance/family docs in the side + panel) when the target is compiled with -haddock, so add + this if you want documentation in the graph. -h, --help Show this help and exit. Environment: @@ -81,11 +85,13 @@ EOF DIR=.classgraph EMIT=raw # raw | cabal PACKAGE= +HADDOCK= # non-empty → also emit -haddock while [ $# -gt 0 ]; do case "$1" in --dir) DIR=$2; shift 2 ;; --cabal) EMIT=cabal; shift ;; --package) PACKAGE=$2; shift 2 ;; + --haddock) HADDOCK=1; shift ;; -h|--help) usage; exit 0 ;; *) echo "$PROG: unknown argument: $1" >&2 @@ -236,13 +242,19 @@ CABAL_FLAG=$(printf '%s;%s;Classgraph.Plugin;"[\\"dir=%s\\"]"' \ case "$EMIT" in raw) + # Each ghc-option on its own line so the output can be pasted/sourced + # token by token. + [ -n "$HADDOCK" ] && echo "-haddock" echo "$RAW_FLAG" ;; cabal) if [ -n "$PACKAGE" ]; then - printf 'package %s\n ghc-options:\n %s\n' "$PACKAGE" "$CABAL_FLAG" + echo "package $PACKAGE" else - printf 'program-options\n ghc-options:\n %s\n' "$CABAL_FLAG" + echo "program-options" fi + echo " ghc-options:" + [ -n "$HADDOCK" ] && echo " -haddock" + echo " $CABAL_FLAG" ;; esac -- 2.54.0