-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add docs for collection_items and fetch methods #99
Conversation
The docs build fine in my "already existing" venv. No Jinja error. I can confirm that I get an error (even different from yours) when installing in a fresh venv and following the docs. I think we shouldn't worry too much about what exactly the error tells us but consider that it just points to some version/dependency issues. I had a look into sphinx_requirements.txt. For some reason I hardcoded all the versions of the packages in there, probably just to get a "known to be working" configuration for docs building. This does not seem to work anymore. Maybe it's because now we just use a slightly different Python 3.9 version. My suggestion now would be:
Sphinx |
Thanks - I created a new venv using the latest 3.9.12 and it worked! I added a missing word from the docs I wrote and pushed it. It should be ready for review and merging if the wording is acceptable. Thanks again! |
Copied from Review comment that for some reason is invisible to others 🤷 I think a better way to put this is to mention that there can be multiple instances of a given release in one or multiple collection folders and this new method is to make it more convenient to fetch all release instances from all collection folders. Example: It is possible that you have multiple instances of the same release inside one or across multiple collection folders and you might want to update or remove all of those instances. release_instances = me.collection_items(22155985)
for instance in release_instances:
print(instance) # CollectionItemInstance This method returns a list of Note.To remove an instance from the collection folder it belongs to, you need to first fetch the correct folder (using instance.folder_id) and remove it that way. See section "Removing a Release from a Collection Folder" Something like that, but better phrased and such :) Hope that clears some things. @JOJ0 Did you have some other ideas about how to document this? |
to me an important point is that with that feature we dont need to iterate through all folders to find a release, we can just get it (the colliteminstance incl all details like folder) by passing a release id we know we own. i’m still not sure if i like the chapter title. i suggest: Getting a collection item via the release id, similar to the api endpoint docs. |
docs/source/fetching_data.md
Outdated
|
||
*Note: To remove an instance from the collection folder it belongs to, you need to fetch the | ||
correct folder (using `instance.folder_id`) to remove it. See the section | ||
"Removing a Release from a Collection Folder"*. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add a link to the correct section in the docs?
Although that section is right above this one so maybe not needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree that linking to the remove chapter is essential even though it's close.
We should omit the word "iterate" in the first paragraph, since this way the point is that we don't have to iterate as opposed to the other method (accessing by folder).
I propose we move the whole chapter right below the initial "collection data" chapter: https://python3-discogs-client.readthedocs.io/en/latest/fetching_data.html#collection-data
I rephrased and reordered the whole chapter to fit in the context of this new position:
Collection Items by Release
As we saw in the previous chapter (link to it even it's close) we can access collection items by iterating through a specific folder or through the whole collection.
An alternative approach is using the collection_items
method which returns a list of CollectionItemInstance
objects. We need to pass it a release_id
or a Release object.
Since It is possible that you have (or even pysically own) multiple copies of the same release inside one or more
collection folders, using this method you'll receive all copies you own of that specific release in whatever folder it's located.
This example code prints us all CollectionItemInstances of release 22155985. Via the attributes of the CollectionItemInstances we can receive further information like the folder it's located in or get details of the actual release.
release_instances = me.collection_items(22155985)
for instance in release_instances:
print(instance)
Note: To remove an instance from the collection folder it belongs to, you need to fetch the
correct folder (using instance.folder_id
) to remove it. See the section
"Removing a Release from a Collection Folder".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also it would be nice if we directly link things like collection_items
and CollectionItemInstance
to the page/entry in the Python package docs. I forgot the syntax but have a look around, we did that already.
Nice! We are getting there. I hijacked the branch and pushed a commit. I moved the chapter up and also spotted some errors we had in the docs way before this PR (regarding folder id's 0, 1, 2). Have a look at the commit message. Pleas make sure you review the whole Collection Data chapter top to bottom in a locally rendered version. |
Also I realized we have a mixture of writings/formatting of Release object And something else: I spotted an error in our readthedocs build. It's the same Jinja error you had @prcutler . Should be easey to fix. Will look into it. |
Todo:
|
add missing "Uncategorized" folder to bulletpoint list, fix examples accordingly and add new folder.remove_release example including the usage of the collection_items method. Also some fixes where id 0 is used to add or remove to folders (The API docs state the ID must not be non-zero).
entry in Collection Data intro chapter.
Collectin Data docs chapter. Sphinx will search for the class itself. The full path to it (discogs_client.models) can be omitted.
@prcutler I figured it out (second checkbox): Have a look at my latest commit. This is how we could directly link to eg. CollectionItemInstance, get nice formatting but with an abreviated form without the annoyingly long full path of discogs_client.models.CollectionItemInstance: Last sentence in this chapter: https://python3-discogs-client.readthedocs.io/en/pr91/fetching_data.html#collection-data I think we should use this with the word "Release" (object) as well! |
in Collection data docs chapter.
Added an example for a link to the Release object docs. |
to our Sphinx reference docs (autodoc). Some other tiny fixes here and there. Mostly in Collection Data chapter.
I replaced all instances of Client, Release, CollectionItemInstance and more classes and methods with links to the Sphinx reference docs of the Python package. I also found out that it's possible to link to single attributes of a class. See |
Not sure how to link to a method in a specific class, since the |
Yeah @AnssiAhola I stumbled across that as well, I just left it alone then because I was not sure which one is the correct one (and to lazy to investigate). So you are saying the one and only correct method we want to link to is the one in APIObjects? |
one in PrimaryAPIObject, the other being in SecondaryAPIObject. FIXME
Yes the one in |
@AnssiAhola have a look at my commit....You see you can put the whole path to a method but then to have it abbreviated as The "message" this chapter should transmit to the reader was simple before these links to fetch(): Any object -> u can use fetch(). Period. ;-)) Are we overcomplicating things now? Haha :-) |
@JOJ0 Maybe the links are not necessary in this case since the example shows how to use it and the actual documentation for the method is not that useful? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the last changes @AnssiAhola . This chapter reads very good and straight forward now IMO.
Thanks to both of you for a great team effort in this PR overall! I think we did a very good job explaining the new feature but improved this page a lot as a whole. I'll merge this now and we are ready for a release.
This PR:
This should build correctly, but I'm getting an error trying to do
make html
when building in a new environment. Submitting the PR just in case someone does want to test and see if it builds.I tested the methods and used the text written by AnssiAhola in the discussions to update the docs. Any feedback on the docs is welcome.
Paul
Here's my error in a 3.9 venv: