Skip to content

[api-documenter] Add support for @defaultValue in Markdown and Yaml documenters#5733

Merged
octogonz merged 2 commits intomicrosoft:mainfrom
colinaaa:fix/api-documenter-defaultvalue
Apr 10, 2026
Merged

[api-documenter] Add support for @defaultValue in Markdown and Yaml documenters#5733
octogonz merged 2 commits intomicrosoft:mainfrom
colinaaa:fix/api-documenter-defaultvalue

Conversation

@colinaaa
Copy link
Copy Markdown
Contributor

Summary

From the perspective of an end user, the @defaultValue tag on class properties, variables, methods, and functions was previously extracted by api-extractor but ignored by api-documenter, resulting in missing default value documentation. This change adds the logic to both MarkdownDocumenter and YamlDocumenter to extract and render the @defaultValue tag correctly.

Fixes #4249

Details

  • MarkdownDocumenter: Added _writeDefaultValueSection to render a "Default Value" heading and block content. It is now called for Properties, PropertySignatures, Variables, TypeAliases, Methods, MethodSignatures, Constructors, ConstructSignatures, and Functions.
  • YamlDocumenter: Extracted the default value from customBlocks and serialized it to yamlItem.defaultValue.
  • Schemas: Updated IYamlItem, typescript.schema.json, and ISDPYamlFile to formally support defaultValue?: string, mapping it correctly through the UDP to SDP pipeline in ToSdpConvertHelper.ts.
  • Regenerated test snapshots for DocClass1.ts to verify output generation across both Markdown and Yaml formats.

How it was tested

Added @defaultValue "Hello World" and @defaultValue 123 to test fixtures in build-tests/api-documenter-test. Ran heft test and verified that the newly generated .snap snapshots properly contain the "Default Value" headings in Markdown and the defaultValue keys in the DocFX YAML payloads.

@colinaaa
Copy link
Copy Markdown
Contributor Author

colinaaa commented Apr 8, 2026

Hi @iclanton @octogonz, would you please take a look. Thanks!

@octogonz
Copy link
Copy Markdown
Collaborator

@colinaaa sorry this slipped through the cracks. LGTM!

@octogonz octogonz merged commit 92f3f2a into microsoft:main Apr 10, 2026
6 checks passed
@github-project-automation github-project-automation bot moved this from Needs triage to Closed in Bug Triage Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

[api-documenter] Include @defaultValue in documentation

2 participants