Szerkesztő:Bináris/Pywikibot dev cheatsheet
Megjelenés
|
This is an unofficial guide for myself to understand the whole process. Known logged-in Pywikibot developers are authorized and encouraged to edit this page. |
- Basics
- mw:Manual:Pywikibot
- https://doc.wikimedia.org/pywikibot/master/ (Page)
- mw:Manual:Pywikibot/Development
Install
[szerkesztés]- mw:Manual:Pywikibot/Installation
- mw:Manual:Pywikibot/Gerrit
- Keep Python up-to-date
- Use a separate clean installation for development
- Use master rather than stable
- Use git, it is necessary for commiting
- Take care of i18n
- Update it before work
- Git: mw:Gerrit/Tutorial
Code
[szerkesztés]Versions
[szerkesztés]- Supported Python versions and planned deprications are important.
- Supported MediaWiki versions are less important, unless I want to directly interact with API.
- Source of information: mw:Manual:Pywikibot/Compatibility
- Note that Python 3.9+ cannot be used on Windows 7 or earlier.
Styleguides
[szerkesztés]- PEP 8 – Style Guide for Python Code
- PEP 257 – Docstring Conventions
- Function Annotations or Type Hints
- MediaWiki conventions: mw:Manual:Coding conventions/Python (mw:Manual:Coding conventions in general)
- Pywikibot-specific: mw:Manual:Pywikibot/Development/Guidelines
Documentation: the underlying markup is reStructuredText but sphinx is used to create the final documentation files.
- Sphynx documentation: https://www.sphinx-doc.org/en/master/
- reStructuredText https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html
Sample doc:
.. seealso:: :api:`Logevents`
.. note:: logevents with `logtype='block'` only logs user blocks whereas `site.blocks` iterates all blocks including IP ranges.
:param logtype: only iterate entries of this type (see mediawiki api documentation for available types) :param user: only iterate entries that match this user name :param page: only iterate entries affecting this page :type page: pywikibot.Page or str :param namespace: namespace(s) to retrieve logevents from :type namespace: int or Namespace or an iterable of them :raises KeyError: the namespace identifier was not resolved :raises TypeError: the namespace identifier has an inappropriate type such as bool, or an iterable with more than one namespace
Tests
[szerkesztés]Standing in core directory, in presence of i18n submodule (will fail without it):
- python -m unittest discover -v -p "*_tests.py" – all, shortly
- python -m unittest -v tests.api_tests tests.site_tests – two, detailed
- python -m unittest -v tests.textlib_tests – one, detailed
I18n
[szerkesztés]- Install/Update/use: mw:Manual:Pywikibot/i18n
- mw:Localisation
- translatewiki:Translating:pywikibot → Valhallasw coordinates the localisation of pywikibot and is the point of contact for all i18n issues; Siebrand takes care of the exports (localisation updates).
- → mw:Project:Pywikibot/i18n progress → Absolutely outdated, should be delinked from Translatewiki and archived.
- mw:Manual:Pywikibot/i18n conversion (may be outdated)
- ? How do new keys get to TW?
Wikidata
[szerkesztés]Publish
[szerkesztés]- mw:Gerrit/personal sandbox Does it work for Pywikibot?
Workflow
[szerkesztés]General
[szerkesztés]- ? Who decides versions, editions and dates?
- ? What makes a version stable?
- ? How does a pach get into a version?
Coding
[szerkesztés]- Tasks found on Phabricator
- Claim → code → commit
- Tasks created by myself
- Does every task need a Phabricator ticket? (Obviously not.)
- When do I have to previously discuss it with others?
- Good first tasks for practicing
- https://phabricator.wikimedia.org/maniphest/query/D.pe8.a.NRmY/#R
Commit
[szerkesztés]Code review
[szerkesztés]Phabricator tasks
[szerkesztés]- Authored: https://phabricator.wikimedia.org/maniphest/query/authored/
- Pywikibot workboard: https://phabricator.wikimedia.org/project/view/87/
- replace.py workboard: https://phabricator.wikimedia.org/project/view/1293/
Concepts
[szerkesztés]- Gerrit
- mw:Gerrit
- Repository and code review tool
- Jenkins
- mw:Continuous integration/Jenkins
- Runs automated tests and checks coding style.
- Tox
- https://tox.wiki/en/latest/
- Test automatization