Introduce exporters_list_created hook to new export code (#1978)

* Introduce exporters_list_created hook for new export code

* Fix hook and argument name
This commit is contained in:
Aristotelis 2022-07-22 11:33:07 +02:00 committed by GitHub
parent 09eef8e746
commit a584ef1f50
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View file

@ -55,6 +55,7 @@ class ExportDialog(QDialog):
NoteCsvExporter,
CardCsvExporter,
]
gui_hooks.exporters_list_did_initialize(self.exporter_classes)
self.frm.format.insertItems(
0, [f"{e.name()} (.{e.extension})" for e in self.exporter_classes]
)

View file

@ -19,7 +19,7 @@ prefix = """\
from __future__ import annotations
from typing import Any, Callable, Sequence, Literal
from typing import Any, Callable, Sequence, Literal, Type
import anki
import aqt
@ -856,6 +856,15 @@ gui_hooks.webview_did_inject_style_into_page.append(mytest)
args=["legacy_exporter: anki.exporting.Exporter"],
doc="""Called after collection and deck exports performed by legacy exporters.""",
),
Hook(
name="exporters_list_did_initialize",
args=["exporters: list[Type[aqt.import_export.exporting.Exporter]]"],
doc="""Called after the list of exporter classes is created.
Allows you to register custom exporters and/or replace existing ones by
modifying the exporter list.
""",
),
# Dialog Manager
###################
Hook(