kerrickstaley / genanki

A Python 3 library for generating Anki decks
MIT License
1.99k stars 150 forks source link

[FEATURE REQUEST] Generate subdecks from filenames #74

Closed darigovresearch closed 2 years ago

darigovresearch commented 3 years ago

In Anki when you use the :: symbol when naming a deck and you get a little dropdown to help organise a large set of flashcards into multiple subdecks so for example Root name::Subdeck name would have Root name as the main deck name and Subdeck name as the name of the subdeck within the main deck.

Is it possible to do this with genanki?

We would love to be able to make subdecks as this would help us to autogenerate flashcards for various projects such as https://github.com/darigovresearch/Universal-Foreign-Language-Flashcards

Would be happy to do a pull request if given guidance on where to insert what in the relevant sections of the codebase.

photonbit commented 3 years ago

It is possible to do this with genanki, just add the :: when generating the Deck:

genanki.Deck(deck_id, "Root::Subdeck")

darigovresearch commented 3 years ago

I meant if it was possible to export one Anki deck that contains multiple subdecks. When you do it the above way you end up having to import the subdecks one by one into Anki.

@photonbit do you know if there is a way to do this?

photonbit commented 3 years ago

You can pack multiple decks into a single package and have one single resulting file with many decks.

deck1 = genanki.Deck(1, "Root::Subdeck1")
deck2 = genanki.Deck(2, "Root::Subdeck1")
package = genanki.Package([deck1, deck2])
package.write_to_file("thastit.apkg")
darigovresearch commented 3 years ago

@photonbit thanks for that, just tested it on our use case and it works like a charm even for a list of arbitrary length.

These are great features and potentially could be added to the docs page or the readme.

kerrick-lyft commented 3 years ago

@photonbit thanks for the help here! I'm going to work on setting up better docs for genanki. The problem is that I think a complete description of the library would be too long for the README, which I intend to be a terse introduction to the library's features. Right now, to get a full understanding of the library you have to refer to the source and the docstrings. When I have a chance I will work on setting up a docs/ directory and maybe get it hosted on GitHub pages.

darigovresearch commented 3 years ago

@kerrick-lyft yeah agree that having it all in the readme is a bit much. There are a few frameworks for building documentation. I would suggest having a separate license for the docs such as CC-BY or the like and the code in the docs be under the same license as the package itself. We often find this encourages people to contribute to the docs as well. Let us know when you do start up the docs as we would be interested in helping build out the docs where we can!

darigovresearch commented 3 years ago

References to different documentation options have been noted in Issue https://github.com/kerrickstaley/genanki/issues/76 in case anyone has a preference to what documentation framework should be used

kerrickstaley commented 2 years ago

Closing this because the initial issue was resolved. Implementing a docs site is still TODO.