Debian Codegraph @

CONTRIBUTING.rst

raw
1 ============
2 Contributing
3 ============
4
5 Contributions are welcome, and they are greatly appreciated! Every
6 little bit helps, and credit will always be given.
7
8 You can contribute in many ways:
9
10 Types of Contributions
11 ----------------------
12
13 Report Bugs
14 ~~~~~~~~~~~
15
16 Report bugs at https://github.com/scrapinghub/dateparser/issues.
17
18 If you are reporting a bug, please include:
19
20 * Your operating system name and version.
21 * Any details about your local setup that might be helpful in troubleshooting.
22 * Detailed steps to reproduce the bug.
23
24 Fix Bugs and Implement Features
25 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26
27 Look through the GitHub issues for bugs and feature requests. To avoid
28 duplicate efforts, try to choose issues without related PRs or with staled PRs.
29 We also encourage you to add new languages to the existing stack.
30
31 Write Documentation
32 ~~~~~~~~~~~~~~~~~~~
33
34 Dateparser could always use more documentation, whether as part of the
35 official Dateparser docs, in docstrings, or even on the web in blog posts,
36 articles, and such.
37
38 After you make local changes to the documentation, you will be able to build the
39 project running::
40
41 tox -e docs
42
43
44 Then open ``.tox/docs/tmp/html/index.html`` in a web browser to see your local
45 build of the documentation.
46
47 .. note::
48
49 If you don't have ``tox`` installed, you need to install it first using
50 ``pip install tox``.
51
52 Submit Feedback
53 ~~~~~~~~~~~~~~~
54
55 The best way to send feedback is to file an issue at https://github.com/scrapinghub/dateparser/issues.
56
57 If you are proposing a feature:
58
59 * Explain in detail how it would work.
60 * Keep the scope as narrow as possible, to make it easier to implement.
61 * Remember that contributions are welcome :)
62
63
64 Get Started!
65 ------------
66
67 Ready to contribute? Here's how to set up `dateparser` for local development.
68
69 1. Fork the `dateparser` repo on GitHub.
70 2. Clone your fork locally::
71
72 $ git clone [email protected]:your_name_here/dateparser.git
73
74 3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper
75 installed, this is how you set up your fork for local development::
76
77 $ mkvirtualenv dateparser
78 $ cd dateparser/
79 $ python setup.py develop
80
81 4. Create a branch for local development::
82
83 $ git checkout -b name-of-your-bugfix-or-feature
84
85 Now you can make your changes locally.
86
87 5. When you're done making changes, check that your changes pass flake8 and the
88 tests, including testing other Python versions with tox::
89
90 $ tox
91
92 To get ``tox``, just ``pip install`` it into your virtualenv. In addition to tests, ``tox`` checks for code style and maximum line length (119 characters).
93
94 6. Commit your changes and push your branch to GitHub::
95
96 $ git add .
97 $ git commit -m "Your detailed description of your changes."
98 $ git push origin name-of-your-bugfix-or-feature
99
100 7. Submit a pull request through the GitHub website.
101
102 Pull Request Guidelines
103 -----------------------
104
105 Before you submit a pull request, check that it meets these guidelines:
106
107 1. The pull request should include tests.
108 2. If the pull request adds functionality, the docs should be updated. Put
109 your new functionality into a function with a docstring, and add the
110 feature to the list in *README.rst*.
111 3. Check the pipelines (Github Actions) in the PR comments (or in
112 https://github.com/scrapinghub/dateparser/actions) and make sure that the
113 tests pass for all supported Python versions.
114 4. Check the new project coverage in the PR comments (or in
115 https://app.codecov.io/gh/scrapinghub/dateparser/pulls) and make sure that
116 it remained equal or higher than previously.
117 5. Follow the core developers' advice which aims to ensure code's consistency
118 regardless of the variety of approaches used by many contributors.
119 6. In case you are unable to continue working on a PR, please leave a short
120 comment to notify us. We will be pleased to make any changes required to get
121 it done.
122
123 Guidelines for Editing Translation Data
124 ---------------------------------------
125
126 English is the primary language of Dateparser. Dates in all other languages are
127 translated into English equivalents before they are parsed.
128
129 The language data that Dateparser uses to parse dates is in
130 ``dateparser/data/date_translation_data``. For each supported language, there
131 is a Python file containing translation data.
132
133 Each translation data Python files contains different kinds of translation data
134 for date parsing: month and week names - and their abbreviations, prepositions,
135 conjunctions, frequently used descriptive words and phrases (like “today”),
136 etc.
137
138 Translation data Python files are generated from the following sources:
139
140 - `Unicode CLDR <http://cldr.unicode.org/>`_ data in JSON format, located at
141 ``dateparser_data/cldr_language_data/date_translation_data``
142
143 - Additional data from the Dateparser community in YAML format, located at
144 ``dateparser_data/supplementary_language_data/date_translation_data``
145
146 If you wish to extend the data of an existing language, or add data for a new
147 language, you must:
148
149 #. Edit or create the corresponding file within
150 ``dateparser_data/supplementary_language_data/date_translation_data``
151
152 See existing files to learn how they are defined, and see
153 :ref:`language-data-template` for details.
154
155 #. Regenerate the corresponding file within
156 ``dateparser/data/date_translation_data`` running the following script::
157
158 dateparser_scripts/write_complete_data.py
159
160 #. Write tests that cover your changes
161
162 You should be able to find tests that cover the affected data, and use
163 copy-and-paste to create the corresponding new test.
164
165 If in doubt, ask Dateparser maintainers for help.
166
167 .. toctree::
168 :maxdepth: 2
169 :hidden:
170
171 template
172
173 Updating the List of Supported Languages and Locales
174 ----------------------------------------------------
175
176 Whenever the content of
177 ``dateparser.data.languages_info.language_locale_dict`` is modified, use
178 ``dateparser_scripts/update_supported_languages_and_locales.py`` to update
179 the corresponding documentation table::
180
181 dateparser_scripts/update_supported_languages_and_locales.py
182
183
184 Updating the Timezone Cache
185 ----------------------------------------------------
186
187 Whenever the content of
188 ``dateparser/timezones.py`` is modified you need to rebuild the timezone cache.
189
190 Run this command:
191 ``BUILD_TZ_CACHE=1 python -c "import dateparser"``
192
193 which should update
194 ``dateparser/data/dateparser_tz_cache.pkl``