Skip to content

Commit

Permalink
Fix definition mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
nighca committed Jan 8, 2025
1 parent 1bc8b88 commit 928e67f
Show file tree
Hide file tree
Showing 3 changed files with 214 additions and 47 deletions.
7 changes: 6 additions & 1 deletion spx-gui/src/components/editor/code-editor/code-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ class CompletionProvider implements ICompletionProvider {

// Skip APIs from spx while without documentation, they are assumed not recommended
if (defId != null && defId.package === packageSpx && definition == null) return null
if (definition != null && definition.hiddenFromList) return null

if (definition != null) {
result.kind = definition.kind
Expand Down Expand Up @@ -510,7 +511,11 @@ export class CodeEditor extends Disposable {
let apiReferenceItems: DefinitionDocumentationItem[]
if (definitions != null && definitions.length > 0) {
const maybeDocumentationItems = await Promise.all(
definitions.map((def) => documentBase.getDocumentation(def))
definitions.map(async (def) => {
const doc = await documentBase.getDocumentation(def)
if (doc == null || doc.hiddenFromList) return null
return doc
})
)
apiReferenceItems = maybeDocumentationItems.filter((d) => d != null) as DefinitionDocumentationItem[]
} else {
Expand Down
7 changes: 7 additions & 0 deletions spx-gui/src/components/editor/code-editor/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,13 @@ export type DefinitionDocumentationItem = {
overview: string
/** Detailed explanation for the definition, overview not included */
detail: BasicMarkdownString
/**
* If the definition should be hidden from the list. Typically a definition is hidden when:
* - It is for internal usage only
* - It is not recommended to use
* - It is duplicated with another one
*/
hiddenFromList?: true
}

export interface IDocumentBase {
Expand Down
Loading

0 comments on commit 928e67f

Please sign in to comment.