Skip to content

Commit

Permalink
When destructuring arguments, sort by source location (#101)
Browse files Browse the repository at this point in the history
This puts keyword arguments in the order they occur in the source
  • Loading branch information
hoodmane authored Sep 30, 2023
1 parent b723099 commit 3c02e36
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion sphinx_js/typedoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,13 @@ def _destructure_param(self, param: Param) -> list[Param]:
assert isinstance(type, ReflectionType)
decl = type.declaration
result = []
for child in decl.children:

def key(c: Node) -> tuple[int, int]:
src = c.sources[0]
return (src.line, src.character)

children = sorted(decl.children, key=key)
for child in children:
assert isinstance(child, Member)
result.append(
Param(
Expand Down

0 comments on commit 3c02e36

Please sign in to comment.