Prompt
Function and method documentation should accurately describe behavior, parameters, and any non-obvious aspects of the implementation. Documentation should evolve alongside code changes.
When writing function documentation:
- Clearly explain the purpose and intended behavior of the function
- Document all parameters, including unused ones (consider using underscore notation in parameter names to reinforce documentation)
// As backends are not implemented by providers, the provider schema argument should always be nil func (s *BackendConfigState) PlanData(schema *configschema.Block, _ *configschema.Block, workspaceName string) (*plans.Backend, error) { - Note any limitations, requirements, or special conditions (like type requirements for comparisons)
// AppendWithoutDuplicates only classifies "duplicates" as diagnostics which // implement ComparableDiagnostic and return true for Equals func (diags Diagnostics) AppendWithoutDuplicates(newDiags ...Diagnostic) Diagnostics { - When deprecating functionality, always provide the recommended alternative
"endpoint": { Type: schema.TypeString, Optional: true, Deprecated: "`endpoint` is deprecated and superseded by `msi_endpoint`, please update your configuration to use `msi_endpoint` instead", } - Explain counter-intuitive implementations that might confuse future developers
// Note: we need to parse the test block before the run blocks // because run blocks depend on test configuration
Proper documentation reduces onboarding time for new developers, prevents misuse of functions, and makes code maintenance easier over time.