Skip to content

Commit

Permalink
Fix: match on TalonDeclarations node
Browse files Browse the repository at this point in the history
  • Loading branch information
wenkokke committed Mar 18, 2023
1 parent ee45a08 commit 78b08fb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
45 changes: 25 additions & 20 deletions talondoc/analyze/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
TalonAssignmentStatement,
TalonBlock,
TalonCommandDeclaration,
TalonDeclarations,
TalonMatches,
TalonSettingsDeclaration,
TalonSourceFile,
Expand Down Expand Up @@ -98,29 +99,33 @@ def analyse_talon_file(
if not cached:
ast = parse_file(package.path / path, raise_parse_error=True)
assert isinstance(ast, TalonSourceFile)
for declaration in ast.children:
if isinstance(declaration, TalonMatches):
for child in ast.children:
if isinstance(child, TalonMatches):
# Register matches:
assert file_entry.matches is None
file_entry.matches = declaration
elif isinstance(declaration, TalonCommandDeclaration):
# Register command:
command_entry = UserCommandEntry(parent=file_entry, ast=declaration)
registry.register(command_entry)
elif isinstance(declaration, TalonSettingsDeclaration):
# Register settings:
for statement in declaration.right.children:
if isinstance(statement, TalonAssignmentStatement):
setting_use_entry = UserSettingEntry(
name=statement.left.text,
parent=file_entry,
value=statement.right,
file_entry.matches = child
elif isinstance(child, TalonDeclarations):
for declaration in child.children:
if isinstance(declaration, TalonCommandDeclaration):
# Register command:
command_entry = UserCommandEntry(
parent=file_entry, ast=declaration
)
registry.register(setting_use_entry)
elif isinstance(declaration, TalonTagImportDeclaration):
# Register tag import:
# TODO: add use entries
pass
registry.register(command_entry)
elif isinstance(declaration, TalonSettingsDeclaration):
# Register settings:
for statement in declaration.right.children:
if isinstance(statement, TalonAssignmentStatement):
setting_use_entry = UserSettingEntry(
name=statement.left.text,
parent=file_entry,
value=statement.right,
)
registry.register(setting_use_entry)
elif isinstance(declaration, TalonTagImportDeclaration):
# Register tag import:
# TODO: add use entries
pass

return file_entry

Expand Down
1 change: 0 additions & 1 deletion talondoc/sphinx/directives/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ def find_commands(self) -> Iterator[UserCommandEntry]:
for sig in self.arguments:
default = self.options.get("default", "include")
for command in self.find_file(sig).commands:
print(f"{sig}: {command.ast.left.text}\n")
if include_command(
command, default=default, exclude=exclude, include=include
):
Expand Down

0 comments on commit 78b08fb

Please sign in to comment.