Add methods, properties, constants as directly searchable items in API docs #1183
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.
This PR implements the feature requested in issue #232 to make API documentation methods, properties, and constants directly searchable, providing users with immediate links to specific API elements instead of just their containing classes.
Problem
Previously, when searching for specific methods like "refresh()", users would only see the containing class (e.g.,
ActiveRecord
) in search results and had to manually navigate into the class documentation to find the specific method. This created an extra step and made the search experience less efficient.Solution
The implementation reactivates existing
SearchApiPrimitive
infrastructure that was commented out in the codebase. TheSearchApiPrimitive
model was already present but disabled - this PR enables it with necessary updates for modern usage.Key Changes
Enabled primitive indexing in
SearchApiType::createRecord()
by uncommenting and updating the code to handle array-based API data fromtypes.json
Updated
SearchApiPrimitive::createRecord()
to work with the JSON array format used by Yii 2.0+ API documentation instead of the original object-based approachImplemented missing methods
getDescription()
andgetType()
in theSearchApiPrimitive
classModernized Elasticsearch mappings by replacing deprecated
not_analyzed
withkeyword
syntaxRe-enabled primitive search in both regular search and search-as-you-type functionality
Enhanced search result display to show primitives in "ClassName::methodName()" format with proper type indicators
Visual Improvement
The screenshot demonstrates the improvement: instead of showing only the
ActiveRecord
class when searching for "refresh()", users now get direct links toActiveRecord::refresh()
method along with the class itself.Examples
Searching for "refresh()":
Searching for "EVENT_BEFORE_INSERT":
Searching for "tableName":
Compatibility
The feature will work immediately for API documentation that includes method, property, and constant information in the
types.json
format used by Yii 2.0+.Fixes #232
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
asset-packagist.org
/usr/bin/php8.3 -n -c /tmp/geSmrl /usr/bin/composer update --no-interaction
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.