Skip to content

fix(sound): sound module functions have no descriptions in generated docs - #920

Merged
RichDom2185 merged 4 commits into
masterfrom
fix/sound-docs-missing-comments
Aug 29, 2026
Merged

fix(sound): sound module functions have no descriptions in generated docs#920
RichDom2185 merged 4 commits into
masterfrom
fix/sound-docs-missing-comments

Conversation

@Akshay-2007-1

Copy link
Copy Markdown
Contributor

Summary

The published sound module docs (source-academy.github.io/modules/documentation/modules/sound.html) show every function with a bare signature and no explanation - reported by Martin Henz.

  • Root cause: TypeDoc documents SoundModulePlugin's @moduleMethod-decorated class methods in src/bundles/sound/src/index.ts, since that's the bundle's actual public API surface. None of its 40 methods carried a doc comment, so the generated docs had nothing to render per function.
  • The descriptions already existed, just on the wrong layer: functions.ts's pure implementations each have a full doc comment, but functions.ts isn't part of what TypeDoc treats as public. This copies each comment onto its corresponding class method in index.ts (trimming internal migration-only asides like trombone's envelope quirk, and switching @examples from Math.sin/Math.PI to math_sin/math_PI, since Source doesn't expose a global Math object).
  • Also fixes an unrelated pre-existing bug found along the way: adsr()'s doc comment in functions.ts was sitting above the private adsrTransformer() helper instead of above adsr() itself.

Test plan

  • yarn workspace @sourceacademy/bundle-sound tsc passes
  • yarn workspace @sourceacademy/bundle-sound lint - 0 errors (6 pre-existing warnings, unchanged from baseline)
  • yarn workspace @sourceacademy/bundle-sound test - 82/82 passing
  • Ran the bundle's own docs generation (buildtools build docs .) and inspected the resulting docs.json: all 40 exported functions now carry their description end-to-end (spot-checked sine_sound, adsr, trombone, consecutively, stacking_adsr, record, play_in_tab)

The doc comment describing adsr()'s public contract was sitting above
the private adsrTransformer() helper instead of above adsr() itself,
so anyone reading the file saw the comment attached to the wrong
function.
TypeDoc documents SoundModulePlugin's @moduleMethod-decorated class
methods in index.ts, since that's the sound bundle's actual public
API surface - but none of its 40 methods had a doc comment, so every
function on the published sound module docs page rendered with a bare
signature and no explanation.

The descriptions were already written, just on the wrong layer: the
pure functions.ts implementations each have a full doc comment, but
those aren't part of what TypeDoc treats as public. This copies each
comment onto its corresponding class method (trimming internal
migration-only asides like trombone's envelope quirk, and using
`math_sin`/`math_PI` in @examples instead of `Math.sin`/`Math.PI`,
since Source doesn't expose a global `Math` object), so the generated
docs actually describe what each function does.

Verified by running buildtools' own docs generation for this bundle
and inspecting the resulting JSON: every one of the 40 exported
functions now carries its description end-to-end.
@Akshay-2007-1

Copy link
Copy Markdown
Contributor Author

@coderabbitai, do you think so that the changes in this PR when merged will fix the docs issue over at the documentation site generated by TypeDocs?

@Akshay-2007-1 Akshay-2007-1 self-assigned this Aug 27, 2026
@Akshay-2007-1 Akshay-2007-1 added Documentation [Category] critical [Priority] Fixing this is mission-critical labels Aug 27, 2026
@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- Changed files and summary ---'
git diff --stat HEAD^ HEAD
git diff --name-only HEAD^ HEAD

echo '--- Sound module public API outline ---'
ast-grep outline src/bundles/sound/src/index.ts --items all --view expanded 2>/dev/null || true

echo '--- Documentation-related workflows and configuration ---'
fd -HI -t f '.*' .github 2>/dev/null | while IFS= read -r file; do
  if rg -qni 'typedoc|buildtools build docs|github-pages|pages|documentation' "$file"; then
    echo "### $file"
    rg -ni -C 3 'typedoc|buildtools build docs|github-pages|pages|documentation' "$file"
  fi
done

echo '--- Relevant diff excerpts ---'
git diff --unified=3 HEAD^ HEAD -- src/bundles/sound/src/index.ts src/bundles/sound/src/functions.ts

Length of output: 32106


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo '--- GitHub Pages deployment workflow ---'
cat -n .github/workflows/pages-deploy.yml

echo '--- Root package documentation and build scripts ---'
if [ -f package.json ]; then
  jq '{scripts: (.scripts // {})}' package.json
fi

echo '--- Documentation build command references outside PR checks ---'
rg -n -C 4 'buildtools build docs|build docs|typedoc|documentation/modules' \
  -g 'package.json' \
  -g '*.yml' \
  -g '*.yaml' \
  -g '*.json' \
  -g '*.ts' \
  . \
  -g '!node_modules/**' -g '!build/**' -g '!dist/**'

echo '--- Sound bundle documentation configuration ---'
fd -HI -t f 'package.json|typedoc.*|tsconfig.*' src/bundles/sound | while IFS= read -r file; do
  echo "### $file"
  if [ "$(basename "$file")" = 'package.json' ]; then
    jq '{name, scripts, typedoc, documentation}' "$file"
  else
    sed -n '1,220p' "$file"
  fi
done

Length of output: 39356


@Akshay-2007-1, yes. This PR should fix the missing descriptions on the published sound-module documentation site.

TypeDoc uses src/bundles/sound/src/index.ts as the sound bundle entry point. The PR adds doc comments directly to the public SoundModulePlugin methods that have @moduleMethod decorators. Those are the methods that TypeDoc documents.

After merge to master, the GitHub Pages workflow runs yarn build:docs. That command regenerates docs for all bundles, including sound, and deploys the generated build directory.

The update will appear on the site after the deployment workflow completes successfully.

You are interacting with an AI system.

@Akshay-2007-1
Akshay-2007-1 requested a review from sayomaki August 28, 2026 09:35

@RichDom2185 RichDom2185 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a nit: Should you use JSDoc @returns instead of "Returns"?

@RichDom2185
RichDom2185 merged commit dae5015 into master Aug 29, 2026
14 checks passed
@RichDom2185
RichDom2185 deleted the fix/sound-docs-missing-comments branch August 29, 2026 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

critical [Priority] Fixing this is mission-critical Documentation [Category]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants