jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1081917?usp=email )
Change subject: [doc] Update scripts description for add_text.py and
clean_sandbox.py
......................................................................
[doc] Update scripts description for add_text.py and clean_sandbox.py
Add type hints to options
Change-Id: I63e21dd1ad91dd2b03f7f061c5af5885519a56b5
---
M docs/conf.py
M scripts/add_text.py
M scripts/clean_sandbox.py
3 files changed, 44 insertions(+), 28 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/docs/conf.py b/docs/conf.py
index 5d151ce..f18f61c 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -534,7 +534,7 @@
from scripts.cosmetic_changes import warning
# these scripts are skipped for fixing options lists
- skipscripts = {'add_text'}
+ skipscripts = {'add_text', 'clean_sandbox'}
if what != 'module':
return
@@ -590,6 +590,19 @@
length = 0
+TYPE_PATTERN = re.compile(r'( +)\[(float|int|str)\]')
+
+
+def pywikibot_option_types_fixups(app, what, name, obj, options, lines):
+ """Convert option types enclosed in square brackets to italic style."""
+ if what != 'module' or 'scripts.' not in name:
+ return
+
+ for index, line in enumerate(lines):
+ if line.startswith('-'):
+ lines[index] = TYPE_PATTERN.sub(r'\1*(\2)*', line)
+
+
def pywikibot_family_classproperty_getattr(obj, name, *defargs):
"""Custom getattr() to get classproperty instances."""
from sphinx.util.inspect import safe_getattr
@@ -618,6 +631,7 @@
"""Implicit Sphinx extension hook."""
app.connect('autodoc-process-docstring', pywikibot_docstring_fixups)
app.connect('autodoc-process-docstring', pywikibot_script_docstring_fixups)
+ app.connect('autodoc-process-docstring', pywikibot_option_types_fixups)
app.add_autodoc_attrgetter(type, pywikibot_family_classproperty_getattr)
diff --git a/scripts/add_text.py b/scripts/add_text.py
index c5d66f9..216ca02 100755
--- a/scripts/add_text.py
+++ b/scripts/add_text.py
@@ -6,11 +6,11 @@
Use the following command line parameters to specify what to add:
--text Text to append. "\n" are interpreted as newlines.
+-text [str] Text to append. "\n" are interpreted as newlines.
--textfile Path to a file with text to append
+-textfile [str] Path to a file with text to append
--summary Change summary to use
+-summary [str] Change summary to use
-up Append text to the top of the page rather than the bottom
@@ -28,7 +28,7 @@
-talk, -talkpage
Put the text onto the talk page instead
--excepturl Skip pages with a url that matches this regular expression
+-excepturl [str] Skip pages with a url that matches this regular expression
-noreorder Place the text beneath the categories and interwiki
diff --git a/scripts/clean_sandbox.py b/scripts/clean_sandbox.py
index 7f23e6a..f9f32f9 100755
--- a/scripts/clean_sandbox.py
+++ b/scripts/clean_sandbox.py
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
-"""
-This bot resets a (user) sandbox with predefined text.
+"""This bot resets a (user) sandbox with predefined text.
This script understands the following command-line arguments:
@@ -8,39 +7,42 @@
Furthermore, the following command line parameters are supported:
- -hours:# Use this parameter if to make the script repeat itself
- after # hours. Hours can be defined as a decimal. 0.01
- hours are 36 seconds; 0.1 are 6 minutes.
+-hours [float] Use this parameter if to make the script repeat
+ itself after the given hours. Hours can be defined as a
+ decimal. 0.01 hours are 36 seconds; 0.1 are 6 minutes.
- -delay:# Use this parameter for a wait time after the last edit
- was made. If no parameter is given it takes it from
- hours and limits it between 5 and 15 minutes.
- The minimum delay time is 5 minutes.
+-delay [int] Use this parameter for a wait time after the last edit
+ was made. If no parameter is given it takes it from hours and
+ limits it between 5 and 15 minutes. The minimum delay time is
+ 5 minutes.
- -text The text that substitutes in the sandbox, you can use this
- when you haven't configured clean_sandbox for your wiki.
+-text [str] The text that substitutes in the sandbox, you can use
+ this when you haven't configured clean_sandbox for your wiki.
- -textfile As an alternative to -text, you can use this to provide
- a file containing the text to be used.
+-textfile [str] As an alternative to -text, you can use this to provide
+ a file containing the text to be used.
- -summary Summary of the edit made by the bot. Overrides the default
- from i18n.
+-summary [str] Summary of the edit made by the bot. Overrides the
+ default from i18n.
This script is a :py:obj:`ConfigParserBot <bot.ConfigParserBot>`.
All local parameters can be given inside a scripts.ini file. Options
passed to the script are priorized over options read from ini file.
+For example:
+
+.. code:: ini
+
+ [clean_sandbox]
+ # the parameter section for clean_sandbox script
+ summary = Bot: Cleaning sandbox
+ text = {{subst:Clean Sandbox}}
+ hours: 0.5
+ delay: 7
+
.. seealso:: :python:`Supported .ini File Structure
<library/configparser.html#supported-ini-file-structure>`
-For example:
-
- [clean_sandbox]
- # the parameter section for clean_sandbox script
- summary = Bot: Cleaning sandbox
- text = {{subst:Clean Sandbox}}
- hours: 0.5
- delay: 7
"""
#
# (C) Pywikibot team, 2006-2024
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1081917?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I63e21dd1ad91dd2b03f7f061c5af5885519a56b5
Gerrit-Change-Number: 1081917
Gerrit-PatchSet: 5
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: D3r1ck01 <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]