Skip to content

Commit

Permalink
feat(python): show argument types for functions with multiple signatu…
Browse files Browse the repository at this point in the history
…res (#46)
  • Loading branch information
barjin authored Jan 22, 2025
1 parent f34ff19 commit e586f60
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@apify/docusaurus-plugin-typedoc-api",
"version": "4.3.11",
"version": "4.3.12",
"description": "Docusaurus plugin that provides source code API documentation powered by TypeDoc. ",
"keywords": [
"docusaurus",
Expand Down
5 changes: 3 additions & 2 deletions packages/plugin/src/components/MemberSignatureTitle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ export interface MemberSignatureTitleProps {
useArrow?: boolean;
hideName?: boolean;
sig: TSDSignatureReflection & { modifiers?: string[] };
hasMultipleSignatures?: boolean;
}

export function MemberSignatureTitle({ useArrow, hideName, sig }: MemberSignatureTitleProps) {
export function MemberSignatureTitle({ useArrow, hideName, sig, hasMultipleSignatures }: MemberSignatureTitleProps) {
const { isPython } = usePluginData('docusaurus-plugin-typedoc-api') as GlobalData;
// add `*` before the first keyword-only parameter
const parametersCopy = sig.parameters?.slice() ?? [];
Expand Down Expand Up @@ -56,7 +57,7 @@ export function MemberSignatureTitle({ useArrow, hideName, sig }: MemberSignatur
<span>
{param.flags?.isRest && <span className="tsd-signature-symbol">...</span>}
{escapeMdx(param.name)}
{!isPython && (
{!isPython || hasMultipleSignatures && (
<>
<span className="tsd-signature-symbol">
{(param.flags?.isOptional || 'defaultValue' in param) && '?'}
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/src/components/MemberSignatures.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function MemberSignatures({ inPanel, sigs }: MemberSignaturesProps) {
}
>
<Icon reflection={sig} />
<MemberSignatureTitle sig={sig} />
<MemberSignatureTitle hasMultipleSignatures={sigs.length > 1} sig={sig} />
</li>
))}
</ul>
Expand Down
2 changes: 1 addition & 1 deletion playground/python/src/foo.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def foo(self, param: str, param2: int):
"""
print("foo")

def foo(self, param: str, param2: int = 0, **kwargs: Unpack[FooFooArguments]):
def foo(self, param: str, param2: int = 0):
"""This is the foo method of the Foo class.
Args:
Expand Down

0 comments on commit e586f60

Please sign in to comment.