docs(node): add top-level + method docs for GainNode and ConstantSourceNode#586
Open
mvanhorn wants to merge 1 commit intoorottier:mainfrom
Open
docs(node): add top-level + method docs for GainNode and ConstantSourceNode#586mvanhorn wants to merge 1 commit intoorottier:mainfrom
mvanhorn wants to merge 1 commit intoorottier:mainfrom
Conversation
…ceNode
Two of the smaller node modules had nearly empty rustdoc:
- GainNode struct: a single line ('AudioNode for volume control'), no
MDN/spec links, no usage example. Both `new` and `gain()` had no doc
at all.
- ConstantSourceNode already had a top-level example, but `new` and
`offset()` were undocumented.
Bring them up to the standard already used by DelayNode and
StereoPannerNode (referenced in orottier#115 as the reference docs):
- GainNode: top-level explainer covering what the node is good for,
MDN + spec + see-also links, runnable `# Usage` example showing a
one-second linear fade-in, `# Examples` pointing at the
amplitude_modulation and feedback_delay examples in the repo.
- GainNode::new + ConstantSourceNode::new: explain when callers should
prefer the BaseAudioContext factory, and document arguments.
- GainNode::gain + ConstantSourceNode::offset: describe default value,
typical usage, and the automation surface (a-rate, ramp methods).
- GainNode private fields gain/registration/channel_config: matching
field-level docstrings to mirror BiquadFilterNode/StereoPannerNode.
`cargo doc --no-default-features --no-deps` builds cleanly.
`cargo test --no-default-features --doc` -> 29 passed (the new
`# Usage` example compiles via `no_run` like the existing ones).
Refs orottier#115
orottier
reviewed
Apr 28, 2026
Owner
orottier
left a comment
There was a problem hiding this comment.
Can I get another pass? The CI failure is unrelated
| impl ConstantSourceNode { | ||
| /// Constructs a new `ConstantSourceNode` from explicit options. | ||
| /// | ||
| /// Most callers should prefer [`BaseAudioContext::create_constant_source`], |
Owner
There was a problem hiding this comment.
Better to frame as an 'alternative' than a pref
|
|
||
| /// Returns the offset `AudioParam`. | ||
| /// | ||
| /// The default value is `1.0`. Treat the node as a *constructible* |
Owner
There was a problem hiding this comment.
Some slop in here, keep it tight
| } | ||
|
|
||
| /// AudioNode for volume control | ||
| /// `GainNode` applies a single gain (volume) value to its incoming audio |
Owner
There was a problem hiding this comment.
For rustdocs, put linebreaks after the first line so it shows that first line as summary
| /// # Examples | ||
| /// | ||
| /// - `cargo run --release --example amplitude_modulation` | ||
| /// - `cargo run --release --example feedback_delay` |
| impl GainNode { | ||
| /// Constructs a new `GainNode` from explicit options. | ||
| /// | ||
| /// Most callers should prefer [`BaseAudioContext::create_gain`], which |
Owner
There was a problem hiding this comment.
Better to frame as an 'alternative' than a pref
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Brings two of the smaller node modules up to the doc standard already used by
DelayNodeandStereoPannerNode(which #115 cites as the reference quality bar).Before
After
GainNodecovering what the node is good for, MDN + spec + see-also links, a runnable# Usageexample (one-second linear fade-in), and# Examplespointing atamplitude_modulation/feedback_delay.GainNode::new,GainNode::gain,ConstantSourceNode::new, andConstantSourceNode::offsetcovering defaults, typical usage, and the automation surface (a-rate, ramp methods).GainNodeto mirrorBiquadFilterNode/StereoPannerNode.Why
#115 calls out
DelayNodeas the reference style and notes most other nodes haven't reached that bar.GainNodewas the most barebones (single-line struct doc, no method docs at all), so it was the highest-leverage place to start.ConstantSourceNodealready had a top-level example but its two methods were undocumented; folded that in to keep this PR a single coherent unit.Other nodes (e.g.
analyser,panner) have many more methods and would each be their own follow-up PR. Happy to take a swing at one of those next if helpful.Test plan
cargo doc --no-default-features --no-deps-- 0 errors, builds cleanlycargo test --no-default-features --doc-- 29 passed (the new# Usageexample compiles viano_runlike the existing ones)Refs #115