发布于 2015-09-04 06:53:48 | 321 次阅读 | 评论: 0 | 来源: 网络整理
重要
Double check you are reading the most recent version of this document at http://doc.scrapy.org/en/master/contributing.html
There are many ways to contribute to Scrapy. Here are some of them:
注解
Please report security issues only to scrapy-security@googlegroups.com. This is a private list only open to trusted Scrapy developers, and its archives are not public.
Well-written bug reports are very helpful, so keep in mind the following guidelines when reporting a new bug.
scrapy version -v
so developers working on your bug know exactly which version and platform it occurred on, which is often very helpful for reproducing it, or knowing if it was already fixed.The better written a patch is, the higher chance that it’ll get accepted and the sooner that will be merged.
Well-written patches should:
The best way to submit a patch is to issue a pull request on Github, optionally creating a new issue first.
Remember to explain what was fixed or the new functionality (what it is, why it’s needed, etc). The more info you include, the easier will be for core developers to understand and accept your patch.
You can also discuss the new functionality (or bug fix) before creating the patch, but it’s always good to have a patch ready to illustrate your arguments and show that you have put some additional thought into the subject. A good starting point is to send a pull request on Github. It can be simple enough to illustrate your idea, and leave documentation/tests for later, after the idea has been validated and proven useful. Alternatively, you can send an email to scrapy-users to discuss your idea first.
Finally, try to keep aesthetic changes (PEP 8 compliance, unused imports removal, etc) in separate commits than functional changes. This will make pull requests easier to review and more likely to get merged.
Please follow these coding conventions when writing code for inclusion in Scrapy:
Scrapy contrib shares a similar rationale as Django contrib, which is explained in this post. If you are working on a new functionality, please follow that rationale to decide whether it should be a Scrapy contrib. If unsure, you can ask in scrapy-users.
ItemLoader.add_value()
method should be documented in the sphinx documentation, not its docstring.scrapy.utils
package and its sub-modules.Tests are implemented using the Twisted unit-testing framework called trial
.
To run all tests go to the root directory of Scrapy source code and run:
bin/runtests.sh
(on unix)
binruntests.bat
(on windows)
To run a specific test (say scrapy.tests.test_contrib_loader
) use:
bin/runtests.sh scrapy.tests.test_contrib_loader
(on unix)
binruntests.bat scrapy.tests.test_contrib_loader
(on windows)
All functionality (including new features and bug fixes) must include a test case to check that it works as expected, so please include tests for your patches if you want them to get accepted sooner.
Scrapy uses unit-tests, which are located in the scrapy.tests
package (scrapy/tests directory). Their module name typically resembles the full path of the module they’re testing. For example, the item loaders code is in:
scrapy.contrib.loader
And their unit-tests are in:
scrapy.tests.test_contrib_loader