Manual:Pywikibot/cosmetic changes.py

cosmetic_changes.py makes little changes in one or several wiki pages that make the source code look cleaner. These changes are not supposed to change the look of the rendered wiki pages.

Before running it on a specific wiki, each sub-module should be reviewed and checked if it is helpful for this wiki.

The script may be used in two ways
 * 1)   for a standalone use
 * 2) for regular use, it is recommended to put   into your user-config.py

This script performs the following operations:

"
 * fix self interwiki: interwiki links to the site itself are displayed like local links, removing their language code prefix.
 * standardize page footer: makes sure that categories, stars templates for featured articles and interwiki links are put to the correct position. templates and interwiki links are sorted into the right order.
 * clean up links: improves how links are presented by doing the following:
 * replaces underlines by spaces, also multiple underlines.
 * removes unnecessary leading spaces from a title.
 * removes unnecessary trailing spaces from a title.
 * converts URL-encoded characters to unicode.
 * removes unnecessary initial and final spaces from a label.
 * tries to capitalize the first letter of the title.
 * clean up section headers: for better readability of section header source code, puts a space between the equal signs and the title; for example: "==Section title==" becomes "== Section title ==".
 * put spaces in lists: for better readability of bullet list and enumeration wiki source code, puts a space between the * or # and the text.
 * translate and capitalize namespaces: makes sure that localized namespace names are used. Does not change "image" alias on en-wiki or fr-wiki.
 * resolve html entities
 * valid xhtml: tries to make a valid XHTML document, for example, replacing "  " with "
 * remove useless spaces
 * remove non breaking space before percent: newer MediaWiki versions automatically place a non-breaking space in front of a percent sign, so it is no longer required to place it manually.
 * fix syntax: correct mediawiki syntax for external links
 * fix HTML: translates some HTML-entities into the corresponding mediawiki syntax; remove unneeded tag.
 * fix style: convert prettytable to wikitable class (de-wiki and en-wiki only).
 * fix typo: change ccm with preleading number to cm³; change º to ° if it concerns degree Celsius or Fahrenheit
 * hyphenate isbn numbers: tries to hyphenate an ISBN

Parameters
 -step:n          When used with any other argument that specifies a set of pages, only retrieve n pages at a time from the wiki server

-wikidataquery   Takes a WikidataQuery query string like claim[31:12280] and works on the resulting pages.

-untagged        Work on image pages that don't have any license template on a                  site given in the format " . .org, e.g.                  "ja.wikipedia.org" or "commons.wikimedia.org".                  Using an external Toolserver tool.

-always          Don't prompt you for each replacement. Warning (see below) has not to be confirmed. ATTENTION: Use this with care!

-async           Put page on queue to be saved to wiki asynchronously.

-summary:XYZ     Set the summary message text for the edit to XYZ, bypassing the predefined message texts with original and replacements inserted.

-ignore:         Ignores if an error occurred and either skips the page or                  only that method. It can be set to 'page' or 'method'.