Skip to content

Commit

Permalink
doc: store module documentation as a README within the module
Browse files Browse the repository at this point in the history
This has two benefits:

1. It will be displayed when browsing the module source code on
   GitHub.
2. It prevents the documentation inadvertently disappearing if the
   module directory is renamed.
  • Loading branch information
danth committed Feb 18, 2025
1 parent ca3f700 commit a0721e7
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions docs/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pkgs.stdenvNoCC.mkDerivation {
optionsFile="$2"
outputFile="$3"
echo "## $platformName options" >>"$outputFile"
echo -e "\n## $platformName options" >>"$outputFile"
if [ -s "$optionsFile" ]; then
sed -e "$REDUCE_HEADINGS" -e "$REMOVE_DECLARED_BY" <"$optionsFile" >>"$outputFile"
Expand All @@ -120,10 +120,16 @@ pkgs.stdenvNoCC.mkDerivation {
homeManagerOptionsFile="$2"
nixosOptionsFile="$3"
readmeFile="${inputs.self}/modules/$moduleName/README.md"
page="options/modules/$moduleName.md"
outputFile="src/$page"
if [ ! -f "$file" ]; then
if [ -f "$outputFile" ]; then
echo "Please move docs/src/options/modules/$moduleName.md to modules/$moduleName/README.md" >&2
exit 1
elif [ -f "$readmeFile" ]; then
cp --no-preserve=mode,ownership "$readmeFile" "$outputFile"
else
echo "# $moduleName" >>"$outputFile"
echo ${lib.escapeShellArg ''
> [!NOTE]
Expand Down

0 comments on commit a0721e7

Please sign in to comment.