Skip to content

Add methods, properties, constants as directly searchable items in API docs #1183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 29, 2025

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. The SearchApiPrimitive model was already present but disabled - this PR enables it with necessary updates for modern usage.

Key Changes

  1. Enabled primitive indexing in SearchApiType::createRecord() by uncommenting and updating the code to handle array-based API data from types.json

  2. Updated SearchApiPrimitive::createRecord() to work with the JSON array format used by Yii 2.0+ API documentation instead of the original object-based approach

  3. Implemented missing methods getDescription() and getType() in the SearchApiPrimitive class

  4. Modernized Elasticsearch mappings by replacing deprecated not_analyzed with keyword syntax

  5. Re-enabled primitive search in both regular search and search-as-you-type functionality

  6. Enhanced search result display to show primitives in "ClassName::methodName()" format with proper type indicators

Visual Improvement

SearchApiPrimitive Feature Demo

The screenshot demonstrates the improvement: instead of showing only the ActiveRecord class when searching for "refresh()", users now get direct links to ActiveRecord::refresh() method along with the class itself.

Examples

Searching for "refresh()":

  • Before: Shows "ActiveRecord" class only
  • After: Shows "ActiveRecord::refresh()" method + class

Searching for "EVENT_BEFORE_INSERT":

  • Direct link to "ActiveRecord::EVENT_BEFORE_INSERT" constant

Searching for "tableName":

  • Direct link to "ActiveRecord::tableName" property

Compatibility

  • Backward compatible: Works with existing Yii 1.0 data (no primitives available)
  • Forward compatible: Automatically activates for Yii 2.0+ when detailed API data is available
  • No breaking changes: Existing search functionality remains unchanged

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
    • Triggering command: /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.

@Copilot Copilot AI changed the title [WIP] @yiisoft-contrib/yiiframework.com/issues/232 Add methods, properties, constants as directly searchable items in API docs Jul 29, 2025
@Copilot Copilot AI requested a review from samdark July 29, 2025 11:14
Copilot finished work on behalf of samdark July 29, 2025 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Search: Add methods, properties, constants as directly searchable items
2 participants