Skip to content
This repository was archived by the owner on Aug 16, 2024. It is now read-only.

Commit c705499

Browse files
KShivenduStephen Gutekanst
authored and
Stephen Gutekanst
committed
indexer/python: fix search key for functions
1 parent e7f6b08 commit c705499

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

doctree/indexer/python/indexer.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func (i *pythonIndexer) IndexDir(ctx context.Context, dir string) (*schema.Index
130130
// Function definitions
131131
{
132132
moduleFuncDefQuery := fmt.Sprintf("(module %s)", funcDefQuery)
133-
modFunctions, err := getFunctions(n, content, moduleFuncDefQuery)
133+
modFunctions, err := getFunctions(n, content, moduleFuncDefQuery, []string{modName})
134134
if err != nil {
135135
return nil, err
136136
}
@@ -179,7 +179,10 @@ func (i *pythonIndexer) IndexDir(ctx context.Context, dir string) (*schema.Index
179179
var classMethods []schema.Section
180180
classBodyNodes := captures["class_body"]
181181
if len(classBodyNodes) > 0 {
182-
classMethods, err = getFunctions(classBodyNodes[0], content, funcDefQuery)
182+
classMethods, err = getFunctions(
183+
classBodyNodes[0], content, funcDefQuery,
184+
[]string{modName, ".", className},
185+
)
183186
if err != nil {
184187
return nil, err
185188
}
@@ -245,7 +248,7 @@ func (i *pythonIndexer) IndexDir(ctx context.Context, dir string) (*schema.Index
245248
}, nil
246249
}
247250

248-
func getFunctions(node *sitter.Node, content []byte, q string) ([]schema.Section, error) {
251+
func getFunctions(node *sitter.Node, content []byte, q string, searchKeyPrefix []string) ([]schema.Section, error) {
249252
var functions []schema.Section
250253
query, err := sitter.NewQuery([]byte(q), python.GetLanguage())
251254

@@ -283,7 +286,7 @@ func getFunctions(node *sitter.Node, content []byte, q string) ([]schema.Section
283286
ShortLabel: funcName,
284287
Label: funcLabel,
285288
Detail: schema.Markdown(funcDocs),
286-
SearchKey: []string{funcName, ".", funcName},
289+
SearchKey: append(searchKeyPrefix, ".", funcName),
287290
})
288291
}
289292

0 commit comments

Comments
 (0)