Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc samples autogenerator #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sosie-js
Copy link
Contributor

@sosie-js sosie-js commented Aug 31, 2021

I put the toy ankisync2_api.py in examples/
Play by yourself ^^

@patarapolw
Copy link
Owner

I don't really get how to use.

@sosie-js
Copy link
Contributor Author

sosie-js commented Sep 6, 2021

Well ankisync2_api.py generated the *_actions.py files already that are samples from anki-connect project which can be reused for your project as tests files.

These are:
deck-actions.py
card-actions.py
media-actions.py
note-actions.py
miscellaneous-actions.py
statistic-actions.py
graphical-actions.py
model-actions.py

and are matching the samples given on the foosoft website, ie Alex, the anki-connect author.

Let's try the first example of the desk-actions.py ,

  1. copy the part of code which includes the head imports, and the invoke command
    and add an extra line print(result)
# test-action.py

from ankisync2.ankiconnect import  ankiconnect as invoke

        
"""
====================================
Gets the complete list of deck names for the current user.
====================================
"""
result = invoke("deckNames")
#See the result 
print('got list of decks: {}'.format(result))
  1. Ensure you have installed anki-connect plugin in Anki by following Alex Installation steps

  2. Open Anki either
    a) in Gui mode; anki (will use ~/.local/share/Anki2/User1/collection.anki2 database )
    or
    b) in syncserver mode : anki --syncserver (will use ~/.syncserver/collections-server.anki2 database )

  3. trigger the python above to see the result.
    python3 test-action.py

NOTE: I have not yet tested all samples but it will a provide a good way to discover the API of
anki-connect thanks to your project I improved since. Of course, pytest can be used to validate the examples.

@patarapolw
Copy link
Owner

Regarding AnkiConnect, it would be hard to do in CI, anyway.

And ankisync2/ankiconnect.py is already a very simple script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants