Skip to content

fix: correct IndexSpecs code examples in extension docs#591

Merged
f2c-ci-robot[bot] merged 3 commits into
halo-dev:mainfrom
ruibaby:fix/indexspec-generics
May 11, 2026
Merged

fix: correct IndexSpecs code examples in extension docs#591
f2c-ci-robot[bot] merged 3 commits into
halo-dev:mainfrom
ruibaby:fix/indexspec-generics

Conversation

@ruibaby
Copy link
Copy Markdown
Member

@ruibaby ruibaby commented May 11, 2026

Summary

This PR fixes the index declaration code examples in the custom model documentation. The current examples have several issues that prevent them from compiling or working correctly:

  1. Missing explicit generic type parameters: IndexSpecs.single() and IndexSpecs.multi() require explicit generic types (e.g., IndexSpecs.<Moment, String>single(...)) because Java cannot infer them from static imports alone.
  2. Incorrect return type in multi-value index example: The multi example assumes getTags() returns a Set, but it typically returns a List. The example now wraps it with new HashSet<>() to match the expected Set<String> return type.

Changes

Updated the following files:

  • docs/developer-guide/plugin/api-reference/server/extension.md (next)
  • versioned_docs/version-2.22/.../extension.md
  • versioned_docs/version-2.23/.../extension.md
  • versioned_docs/version-2.24/.../extension.md
None

Update the index declaration examples to use explicit generic type
parameters and proper Set conversion for multi-value indexes:

- Replace `import static` with explicit `IndexSpecs.<E, K>` calls
- Convert List tags to HashSet in multi-value index examples
- Apply fixes to next, 2.22, 2.23, and 2.24 docs
@f2c-ci-robot f2c-ci-robot Bot added do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels May 11, 2026
Comment thread docs/developer-guide/plugin/api-reference/server/extension.md Outdated
ruibaby added 2 commits May 11, 2026 12:11
Update the docs example to return Set.of() when tags is null and return the existing tags object instead of creating a new HashSet copy. Apply the change to the main docs and versioned docs (v2.22, v2.23, v2.24) to simplify the example and avoid unnecessary allocations.
@ruibaby ruibaby requested a review from JohnNiang May 11, 2026 04:26
Copy link
Copy Markdown
Member

@JohnNiang JohnNiang left a comment

Choose a reason for hiding this comment

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

/lgtm

@f2c-ci-robot f2c-ci-robot Bot added the lgtm Indicates that a PR is ready to be merged. label May 11, 2026
@f2c-ci-robot
Copy link
Copy Markdown

f2c-ci-robot Bot commented May 11, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: JohnNiang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@f2c-ci-robot f2c-ci-robot Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 11, 2026
@f2c-ci-robot f2c-ci-robot Bot merged commit 1950510 into halo-dev:main May 11, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants