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
Document the Scrapy component API #5439
base: master
Are you sure you want to change the base?
Conversation
… them refer to the centralized definition of these classmethods locatedin class-methods.rst
Codecov Report
@@ Coverage Diff @@
## master #5439 +/- ##
==========================================
- Coverage 88.75% 88.70% -0.06%
==========================================
Files 163 163
Lines 10666 10664 -2
Branches 1818 1788 -30
==========================================
- Hits 9467 9459 -8
- Misses 923 929 +6
Partials 276 276
|
@Gallaecio Is there anything missing or anything that I could improve? |
Probably not, but I want to take some time to have a proper look at this one. I hope it does not take me too long to find the time. |
Update as per @Gallaecio 's suggestion, indeed "others" is too generic! Co-authored-by: Adrián Chaves <adrian@chaves.io>
Update class-methods.rst Resolve inconsistent vocabulary. Add explanation on from settings
re-worded, i'll try to run it now and see how it acts
Update class-methods.rst
@Gallaecio the changes that you requested are done, please let me know if there is anything I can improve |
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.
Sorry for the late feedback. I will try to be quicker for any further feedback.
=========================== | ||
Class Factory Methods | ||
=========================== |
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.
=========================== | |
Class Factory Methods | |
=========================== | |
===================== | |
Class Factory Methods | |
===================== |
:meth:`from_settings`: | ||
|
||
This class method is used by Scrapy to create an instance of the class. | ||
It's called with the current project settings, and it loads the spiders | ||
found recursively in the modules of the :setting:`SPIDER_MODULES` | ||
setting. |
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.
I am thinking factory method signatures should still be kept in the API reference. It is specially important because some components may get extra arguments, I believe, and in those cases we should document them in one of the methods (e.g. from_crawler
) and in the other method refer to the former for parameter details.
What we can do now is simplify the description, both of from_crawler
and from_settings
, to something like:
Factory method. See :ref:`class-methods`.
Assuming we also add .. _class-methods:
at the beginning of the new topic.
Also, I imagine (please check) that this class also supports from_crawler
. In that case, we should include an entry for that class method as well, with its own signature, but the same description that basically points to the new topic.
The ``from_crawler`` class method is implemented in the following objects: | ||
* ItemPipeline | ||
* DownloaderMiddleware | ||
* SpiderMiddleware | ||
* Scheduler | ||
* BaseScheduler | ||
* Spider | ||
|
||
The ``from_settings`` class method is implemented in the following objects: | ||
* MailSender | ||
* SpiderLoader |
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.
Some of these are classes, some are interface definitions (they define an API, but do not really exist as classes in Python code), but none of them are objects.
This also seems to suggest that the upper list supports only from_crawler
and the lower list supports only from_settings
. Is that so?
Remove duplicate definition of from_crawler and from_settings method. Make them refer to the centralized definitions in class-methods.rst where the explanation of the methods is elaborated. Closes #5110