Skip to content

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

Open
colinaaa wants to merge 2 commits intomicrosoft:mainfrom
colinaaa:fix/api-documenter-defaultvalue
Open

[api-documenter] Add support for @defaultValue in Markdown and Yaml documenters#5733
colinaaa wants to merge 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs triage

Development

Successfully merging this pull request may close these issues.

[api-documenter] Include @defaultValue in documentation

1 participant