Xqt has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/791563 )

Change subject: [doc] Additional documentation for basic script class usage
......................................................................

[doc] Additional documentation for basic script class usage

Change-Id: I23f02d6dc4e2c12f70a9678cf583266d9e885d7d
---
M docs/library_usage.rst
M scripts/basic.py
2 files changed, 32 insertions(+), 18 deletions(-)

Approvals:
  Xqt: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/docs/library_usage.rst b/docs/library_usage.rst
index b1c0846..6aae756 100644
--- a/docs/library_usage.rst
+++ b/docs/library_usage.rst
@@ -47,29 +47,43 @@

 **Explanations:**

-:1-3: Import necessary framework code parts
-:5:   The bot is derived from ExistingPageBot. All pages from generator
-      which does not exists are skipped.
+:1-3: Import necessary framework code parts:
+      :mod:`pywikibot`, :mod:`pywikibot.pagegenerators`,
+      :class:`pywikibot.bot.ExistingPageBot`.
+:5:   The bot is derived from
+      :class:`ExistingPageBot<pywikibot.bot.ExistingPageBot>`.
+      All pages from  generator which does not exists are skipped.
 :7:   Every Bot has an *always* option which autoconfirms any changes if
       set to True. To expand all available options of a bot and set the
-      default values of them, use `update_options` attribute or update
-      `available_options` like it is shown in BasicBot below.
-:12:  All changes for each page are made in this method.
-:14:  `currentpage` is the current :py:obj:`pywikibot.Page` object from
-      generator.
+      default values of them, use
+      :attr:`update_options<pywikibot.bot.BaseBot.update_options>`
+      attribute or update
+      :attr:`available_options<pywikibot.bot.BaseBot.available_options>`
+      like it is shown in :ref:`BasicBot<Basic script>` below.
+:12:  All changes for each page are made in this
+      :meth:`treat_page<pywikibot.bot.CurrentPageBot.treat_page>` method.
+:14:  :attr:`current_page<pywikibot.bot.BaseBot.current_page>` is the current
+      :class:`pywikibot.Page` object from
+      :attr:`generator<pywikibot.bot.BaseBot.generator>`.
 :15:  All bot options which are passed to the bot class when
-      instantiating it are accessable via opt attribute. `opt.always`,
-      `opt.text` and `opt.summary` are all available options for this
+      instantiating it are accessable via
+      :class:`opt attribute<pywikibot.bot.OptionHandler>`. ``opt.always``,
+      ``opt.text`` and ``opt.summary`` are all available options for this
       bot class.
-:16:  Save the changes to the live wiki.
+:16:  Save the changes to the live wiki with
+      :meth:`put_current<pywikibot.bot.CurrentPageBot.put_current>`.
 :18:  Parse command line options inside this function.
 :20:  A dict which holds all options for the bot.
 :21:  :py:obj:`pywikibot.pagegenerators.GeneratorFactory` supports
       generators and filter options.
-:23:  Pywikibot provides global options like site specification or
-      a simulate switch to prevent live wiki changes.
-:24:  Generators and filter options of :py:obj:`pywikibot.pagegenerators`
-      are parsed here.
+:23:  Pywikibot provides :ref:`global options<Global Options>` like site
+      specification or a *simulate* switch to prevent live wiki changes.
+      These options are parsed by :func:`pywikibot.handle_args`.
+:24:  :ref:`Generators<Generator Options>` and
+      :ref:`filter options<Filter Options>` of
+      :mod:`pywikibot.pagegenerators` are parsed here using
+      :meth:`GeneratorFactory.handle_args()
+      <pywikibot.pagegenerators.GeneratorFactory.handle_args>`.
 :25:  Local options which are are available for the current bot are
       parsed in this loop.
 :29:  Create the bot passing keyword only parameters and run it.
diff --git a/scripts/basic.py b/scripts/basic.py
index 1bcd7ba..27fb367 100755
--- a/scripts/basic.py
+++ b/scripts/basic.py
@@ -162,12 +162,12 @@
     # The preloading option is responsible for downloading multiple
     # pages from the wiki simultaneously.
     gen = gen_factory.getCombinedGenerator(preload=True)
-    if gen:
+
+    # check if further help is needed
+    if not pywikibot.bot.suggest_help(missing_generator=gen):
         # pass generator and private options to the bot
         bot = BasicBot(generator=gen, **options)
         bot.run()  # guess what it does
-    else:
-        pywikibot.bot.suggest_help(missing_generator=True)


 if __name__ == '__main__':

--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/791563
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I23f02d6dc4e2c12f70a9678cf583266d9e885d7d
Gerrit-Change-Number: 791563
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to