diff --git a/README.md b/README.md index 7516ac7..0e66f7f 100644 --- a/README.md +++ b/README.md @@ -1829,6 +1829,29 @@ corresponding to when the API was available for use. } ``` +* **modelFieldDescriptions** + + Gets the complete list of field descriptions (the text seen in the gui editor when a field is empty) for the provided model name. + + *Sample request*: + ```json + { + "action": "modelFieldDescriptions", + "version": 6, + "params": { + "modelName": "Basic" + } + } + ``` + + *Sample result*: + ```json + { + "result": ["", ""], + "error": null + } + ``` + * **modelFieldsOnTemplates** Returns an object indicating the fields on the question and answer side of each card template for the given model diff --git a/plugin/__init__.py b/plugin/__init__.py index 056ca01..9562013 100644 --- a/plugin/__init__.py +++ b/plugin/__init__.py @@ -1069,6 +1069,15 @@ class AnkiConnect: return [field['name'] for field in model['flds']] + @util.api() + def modelFieldDescriptions(self, modelName): + model = self.collection().models.byName(modelName) + if model is None: + raise Exception('model was not found: {}'.format(modelName)) + else: + return [field['description'] for field in model['flds']] + + @util.api() def modelFieldsOnTemplates(self, modelName): model = self.collection().models.byName(modelName) diff --git a/tests/test_models.py b/tests/test_models.py index 7c5dbb7..bed3b82 100755 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -16,6 +16,11 @@ def test_modelFieldNames(setup): assert result == ["field1", "field2"] +def test_modelFieldDescriptions(setup): + result = ac.modelFieldDescriptions(modelName="test_model") + assert result == ["", ""] + + def test_modelFieldsOnTemplates(setup): result = ac.modelFieldsOnTemplates(modelName="test_model") assert result == {