jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/684095 )
Change subject: [doc] Fix conf.pywikibot_epytext_to_sphinx() function ......................................................................
[doc] Fix conf.pywikibot_epytext_to_sphinx() function
Also add some more documentation to pywikibot.Site()
Change-Id: Ia35683f3023e2dadd64dfb6c0802e54aeb34d50e --- M docs/conf.py M pywikibot/__init__.py 2 files changed, 39 insertions(+), 2 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/docs/conf.py b/docs/conf.py index d88005d..4be6958 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -388,7 +388,7 @@ r'\1:\2:', line) # short token line = re.sub(r'(\A *)@(?:kwarg|kwparam) ', r'\1:keyword ', line) # keyword - line = re.sub(r'(\A| )C{([^}]*)}', r'\1:py:obj:`\2`', line) # Link + line = re.sub(r'(\A| )L{([^}]*)}', r'\1:py:obj:`\2`', line) # Link line = re.sub(r'(\A| )B{([^}]*)}', r'\1**\2**', line) # Bold line = re.sub(r'(\A| )I{([^}]*)}', r'\1*\2*', line) # Italic line = re.sub(r'(\A| )C{([^}]*)}', r'\1``\2``', line) # Code diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py index 15b0b0d..3a24dc2 100644 --- a/pywikibot/__init__.py +++ b/pywikibot/__init__.py @@ -1095,12 +1095,49 @@ By default rely on config settings. These defaults may all be overridden using the method parameters.
+ Creating the default site using config.mylang and config.family:: + + site = pywikibot.Site() + + Override default site code:: + + site = pywikibot.Site('fr') + + Override default family:: + + site = pywikibot.Site(family='wikisource') + + Setting a specific site:: + + site = pywikibot.Site('fr', 'wikisource') + + which is equal to:: + + site = pywikibot.Site('wikisource:fr') + + :Note: An already created site is cached an a new variable points to + the same object if interface, family, code and user are equal: + + >>> import pywikibot + >>> site_1 = pywikibot.Site('wikisource:fr') + >>> site_2 = pywikibot.Site('fr', 'wikisource') + >>> site_1 is site_2 + True + >>> site_1 + APISite("fr", "wikisource") + + C{APISite} is the default interface. Refer L{pywikibot.site} for + other interface types. + + **Never create a site object via interface class directly.** + Always use this factory method. + @param code: language code (override config.mylang) code may also be a sitename like 'wikipedia:test' @param fam: family name or object (override config.family) @type fam: str or pywikibot.family.Family @param user: bot user name to use on this site (override config.usernames) - @param interface: site class or name of class in pywikibot.site + @param interface: site class or name of class in L{pywikibot.site} (override config.site_interface) @type interface: subclass of L{pywikibot.site.BaseSite} or string @param url: Instead of code and fam, does try to get a Site based on the
pywikibot-commits@lists.wikimedia.org