Jump to content

Wikipedia:Bots/Requests for approval/GraphBot

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Sj (talk | contribs) at 22:42, 7 June 2025 (Discussion). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

New to bots on Wikipedia? Read these primers!

Operator: GalStar (talk · contribs · SUL · edit count · logs · page moves · block log · rights log · ANI search)

Time filed: 18:31, Wednesday, June 4, 2025 (UTC)

Function overview: Convert selected graphs to charts. Graphs must be of the template Template:PortGraph.

Automatic, Supervised, or Manual: Automatic

Programming language(s): Python, Rust (mwbot)

Source code available: I will potentially release it soon.

Links to relevant discussions (where appropriate):

Edit period(s): Continuous

Estimated number of pages affected: ~ a maximum 14,000 (the number of pages with broken graphs), likely fewer.

Namespace(s): Mainspace

Exclusion compliant (Yes/No): Yes

Function details:

Flow:

  • Searches for pages with Template:PortGraph
  • Loads page wikitext
  • Parse wikitext with mwparserfromhell, find all templates, storing the name, parameters, and wikitext
  • Do the following for all templates that are called "PortGraph" and have a "name" parameter.
    • Generate tab and create it on commons
      • The parameters x, y, y1, y2, xType, yType are considered
    • Generate chart and create it on commons
      • the type parameter is converted to the chart type
      • xAxisTitle and yAxisTitle are used for the axis titles
      • The title attribute is the title, if it doesn't exist, the name attribute is used instead
    • Generate replacement with [[Template:ChartDisplay]] (i.e. [[Template:ChartDisplay|definition=[]|width=[]]])
  • Take all replacements and substitute the wikitext out.
  • Post edit onto wikipedia


Discussion