Skip to content

Commit 7a1f1d8

Browse files
committed
[doc] Add Family attribute hints to sphinx doc.
Change-Id: I8bc1a19fc6c451cbb57c97124d8ef9f10cf3afe8
1 parent 4e43afb commit 7a1f1d8

File tree

2 files changed

+103
-71
lines changed

2 files changed

+103
-71
lines changed

ROADMAP.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ Will be removed in Pywikibot 10
119119
* 7.6.0: :mod:`tools.collections` datatypes should no longer imported from :mod:`tools`
120120
* 7.5.0: :mod:`textlib`.tzoneFixedOffset class will be removed in favour of :class:`time.TZoneFixedOffset`
121121
* 7.4.0: ``FilePage.usingPages()`` was renamed to :meth:`using_pages()<pywikibot.FilePage.using_pages>`
122+
* 7.3.0: ``linkitrail`` method of :class:`family.Family` is deprecated; use :meth:`APISite.linktrail()
123+
<pywikibot.site._apisite.APISite.linktrail>` instead
122124
* 7.2.0: ``tb`` parameter of :func:`exception()<pywikibot.exception>` function was renamed to ``exc_info``
123125
* 7.2.0: XMLDumpOldPageGenerator is deprecated in favour of a ``content`` parameter of
124126
:func:`XMLDumpPageGenerator<pagegenerators.XMLDumpPageGenerator>` (:phab:`T306134`)

pywikibot/family.py

Lines changed: 101 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Objects representing MediaWiki families."""
22
#
3-
# (C) Pywikibot team, 2004-2023
3+
# (C) Pywikibot team, 2004-2024
44
#
55
# Distributed under the terms of the MIT license.
66
#
@@ -97,98 +97,117 @@ def instance(cls):
9797
#: Not open for edits; stewards can still edit.
9898
closed_wikis: list[str] = []
9999

100-
#: Completely removed sites
100+
#: Completely removed sites.
101101
removed_wikis: list[str] = []
102102

103103
code_aliases: dict[str, str] = {}
104104
"""Code mappings which are only an alias, and there is no 'old' wiki.
105-
106105
For all except 'nl_nds', subdomains do exist as a redirect, but that
107106
should not be relied upon.
108107
"""
109108

110109
langs: dict[str, str] = {}
111110

112-
# A list of category redirect template names in different languages
111+
#: A list of category redirect template names in different languages.
113112
category_redirect_templates: dict[str, Sequence[str]] = {
114113
'_default': []
115114
}
116115

117-
# A list of disambiguation template names in different languages
116+
#: A list of disambiguation template names in different languages.
118117
disambiguationTemplates: dict[str, Sequence[str]] = {
119118
'_default': []
120119
}
121120

122-
# A dict of tuples for different sites with names of templates
123-
# that indicate an edit should be avoided
124121
edit_restricted_templates: dict[str, tuple[str, ...]] = {}
122+
"""A dict of tuples for different sites with names of templates that
123+
indicate an edit should be avoided.
124+
"""
125125

126-
# A dict of tuples for different sites with names of archive
127-
# templates that indicate an edit of non-archive bots
128-
# should be avoided
129126
archived_page_templates: dict[str, tuple[str, ...]] = {}
127+
"""A dict of tuples for different sites with names of archive
128+
templates that indicate an edit of non-archive bots should be
129+
avoided.
130+
"""
130131

131-
# A set of projects that share cross-project sessions.
132+
#: A set of projects that share cross-project sessions.
132133
cross_projects: set[str] = set()
133134

134-
# A list with the name for cross-project cookies.
135-
# default for wikimedia centralAuth extensions.
135+
#: A list with the name for cross-project cookies, default for
136+
#: wikimedia centralAuth extensions.
136137
cross_projects_cookies = ['centralauth_Session',
137138
'centralauth_Token',
138139
'centralauth_User']
139140
cross_projects_cookie_username = 'centralauth_User'
140141

141-
# A list with the name in the cross-language flag permissions
142+
#: A list with the name in the cross-language flag permissions.
142143
cross_allowed: list[str] = []
143144

144-
# A dict with the name of the category containing disambiguation
145-
# pages for the various languages. Only one category per language,
146-
# and without the namespace, so add things like:
147-
# 'en': "Disambiguation"
148145
disambcatname: dict[str, str] = {}
146+
"""A dict with the name of the category containing disambiguation
147+
pages for the various languages. Only one category per language, and
148+
without the namespace, so add things like:
149+
150+
'en': "Disambiguation"
151+
"""
149152

150-
# attop is a list of languages that prefer to have the interwiki
151-
# links at the top of the page.
152153
interwiki_attop: list[str] = []
153-
# on_one_line is a list of languages that want the interwiki links
154-
# one-after-another on a single line
154+
"""attop is a list of languages that prefer to have the interwiki
155+
links at the top of the page.
156+
"""
157+
155158
interwiki_on_one_line: list[str] = []
156-
# String used as separator between interwiki links and the text
159+
"""on_one_line is a list of languages that want the interwiki links
160+
one-after-another on a single line
161+
"""
162+
163+
#: String used as separator between interwiki links and the text.
157164
interwiki_text_separator = '\n\n'
158165

159166
# Similar for category
160167
category_attop: list[str] = []
161-
# on_one_line is a list of languages that want the category links
162-
# one-after-another on a single line
168+
"""attop is a list of categories that prefer to have the category
169+
links at the top of the page.
170+
"""
171+
163172
category_on_one_line: list[str] = []
164-
# String used as separator between category links and the text
173+
"""on_one_line is a list of languages that want the category links
174+
one-after-another on a single line.
175+
"""
176+
177+
#: String used as separator between category links and the text
165178
category_text_separator = '\n\n'
166-
# When both at the bottom should categories come after interwikilinks?
167-
# TODO: T86284 Needed on Wikia sites, as it uses the CategorySelect
168-
# extension which puts categories last on all sites. TO BE DEPRECATED!
179+
169180
categories_last: list[str] = []
181+
"""When both at the bottom should categories come after
182+
interwikilinks?
183+
184+
TODO: :phab:`T86284` Needed on Wikia sites, as it uses the
185+
CategorySelect extension which puts categories last on all sites.
186+
TO BE DEPRECATED!
187+
"""
170188

171-
# Which languages have a special order for putting interlanguage
172-
# links, and what order is it? If a language is not in
173-
# interwiki_putfirst, alphabetical order on language code is used.
174-
# For languages that are in interwiki_putfirst, interwiki_putfirst
175-
# is checked first, and languages are put in the order given there.
176-
# All other languages are put after those, in code-alphabetical
177-
# order.
178189
interwiki_putfirst: dict[str, str] = {}
190+
"""Which languages have a special order for putting interlanguage
191+
links, and what order is it? If a language is not in
192+
interwiki_putfirst, alphabetical order on language code is used. For
193+
languages that are in interwiki_putfirst, interwiki_putfirst is
194+
checked first, and languages are put in the order given there. All
195+
other languages are put after those, in code-alphabetical order.
196+
"""
179197

180-
# Some families, e. g. commons and meta, are not multilingual and
181-
# forward interlanguage links to another family (wikipedia).
182-
# These families can set this variable to the name of the target
183-
# family.
184198
interwiki_forward: str | None = None
199+
"""Some families, e. g. commons and meta, are not multilingual and
200+
forward interlanguage links to another family (wikipedia). These
201+
families can set this variable to the name of the target family.
202+
"""
185203

186-
# Language codes of the largest wikis. They should be roughly sorted
187-
# by size.
188204
languages_by_size: list[str] = []
205+
"""Language codes of the largest wikis. They should be roughly
206+
sorted by size.
207+
"""
189208

190-
# Some languages belong to a group where the possibility is high that
191-
# equivalent articles have identical titles among the group.
209+
#: Some languages belong to a group where the possibility is high
210+
#: that equivalent articles have identical titles among the group.
192211
language_groups = {
193212
# languages using the Arabic script
194213
'arab': [
@@ -248,37 +267,48 @@ def instance(cls):
248267
],
249268
}
250269

251-
# LDAP domain if your wiki uses LDAP authentication,
252-
# https://www.mediawiki.org/wiki/Extension:LDAPAuthentication2
253270
ldapDomain = ()
271+
"""LDAP domain if your wiki uses LDAP authentication.
272+
273+
.. seealso:: https://www.mediawiki.org/wiki/Extension:LDAPAuthentication2
274+
"""
254275

255-
# Allows crossnamespace interwiki linking.
256-
# Lists the possible crossnamespaces combinations
257-
# keys are originating NS
258-
# values are dicts where:
259-
# keys are the originating langcode, or _default
260-
# values are dicts where:
261-
# keys are the languages that can be linked to from the lang+ns, or
262-
# '_default'; values are a list of namespace numbers
263276
crossnamespace: CrossnamespaceType = collections.defaultdict(dict)
264-
##
265-
# Examples :
266-
#
267-
# Allowing linking to pt' 102 NS from any other lang' 0 NS is
268-
#
269-
# crossnamespace[0] = {
270-
# '_default': { 'pt': [102]}
271-
# }
272-
#
273-
# While allowing linking from pt' 102 NS to any other lang' = NS is
274-
#
275-
# crossnamespace[102] = {
276-
# 'pt': { '_default': [0]}
277-
# }
278-
279-
# Some wiki farms have UrlShortener extension enabled only on the main
280-
# site. This value can specify this last one with (lang, family) tuple.
277+
"""Allows crossnamespace interwiki linking.
278+
279+
Lists the possible crossnamespaces combinations; keys are
280+
originating namespace; values are dicts where keys are the
281+
originating langcode, or ``_default`` and values are dicts where
282+
keys are the languages that can be linked to from the lang+ns, or
283+
``_default``; values are a list of namespace numbers.
284+
285+
**Examples:**
286+
287+
Allowing linking *to* ``pt`` 102 namespace from any other lang 0
288+
namepace is:
289+
290+
.. code-block:: Python
291+
292+
crossnamespace[0] = {
293+
'_default': { 'pt': [102]}
294+
}
295+
296+
While allowing linking *from* ``pt`` 102 namespace to any other
297+
lang 0 namespace is
298+
299+
.. code-block:: Python
300+
301+
crossnamespace[102] = {
302+
'pt': { '_default': [0]}
303+
}
304+
305+
"""
306+
281307
shared_urlshortner_wiki: tuple[str, str] | None = None
308+
"""Some wiki farms have UrlShortener extension enabled only on
309+
the main site. This value can specify this last one with
310+
``(lang, family)`` tuple.
311+
"""
282312

283313
title_delimiter_and_aliases = ' _'
284314
"""Titles usually are delimited by a space and the alias is replaced

0 commit comments

Comments
 (0)