-
Notifications
You must be signed in to change notification settings - Fork 40
Add details on how to initiate a collection and add a helper function in support of that. #25
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
base: main
Are you sure you want to change the base?
Conversation
|
This section does show how to initiate a collection: https://addon-docs.ankiweb.net/command-line-use.html Your helper function can be simplified by using |
|
Thanks for the response! Evidently I did not browse through enough docs... I think that kind of proves the point that the docs could be improved though, as I doubt I'm the only one who didn't find that page. It seems to me that the CLI doc URL and site title do not describe its contents. It's not CLI usage; it's Python usage, specifically the anki module usage. I think it makes much more sense to include the alternate way to initiate a collection in (The 'anki' Module)[https://addon-docs.ankiweb.net/the-anki-module.html] under the 'The Collection' section. If you think these changes are too bulky to belong on the (The 'anki' Module)[https://addon-docs.ankiweb.net/the-anki-module.html] then maybe we could just move the alternate deck creation into the (ideally renamed) CLI documentation page? Then we could just drop a link to it on the (The 'anki' Module)[https://addon-docs.ankiweb.net/the-anki-module.html] page. I'd be happy make the changes. ...Also I'm having some problems with |
It shows usage outside the GUI, so the naming makes sense to me.
I think that's fine, but we can probably remove the helper function. Here's an example of the get_created_base_folder() method: from aqt.profiles import ProfileManager
ProfileManager.get_created_base_folder(None)
It definitely exists :) I'd recommend setting up VS Code/PyCharm and making use of their Python support. It'll also help you learn more about the anki/aqt modules without docs (because most stuff are undocumented) |
|
Okay, I removed the helper function and replaced it with the aqt function call as you've shown above. If I try to run the snippet you've pasted above in pycharm I get an import error on running that says: The Pycharm hint highlighting agrees with this message. Hovering over the warning pops up with the message: |
Pretty much what the title says.
For a fledgling Anki developer writing a non-add-on program, it is not obvious, even after reading mounds of source code and docs, that one can find and pass your collection.anki2 path to Collection() to initialize a col.
Anki Forums, Reddit, and unsolved PRs/Issues on 3rd party projects such as genanki, panki, and others are full of advanced users although perhaps new to Anki searching for (and at times unnecessarily and unknowingly trying to duplicate) functionality that already readily exists via the official module. They just can’t figure out how to use it without building an add-on.
I understand this is hosted on a domain with “addon” literally in the name, and this change doesn't directly impact Anki add-on development. However, it could be useful knowledge for add-on developers for testing. Also these docs are the only thorough documentation on Anki extensibility via its official module. I think educating users on working with collections with external scripts via the Anki module certainly falls under extensibility and provides a gateway to making Anki add-ons.
[Updated] Regarding the helper function, it has now been tested on Linux, Mac, and Windows.