Class: MediaWiktory::Wikipedia::Actions::Parse

Inherits:
Get
  • Object
show all
Defined in:
lib/mediawiktory/wikipedia/actions/parse.rb

Overview

Parses content and returns parser output.

Usage:

api.parse.title(value).perform # returns string with raw output
# or
api.parse.title(value).response # returns output parsed and wrapped into Response object

See Base for generic explanation of working with MediaWiki actions and Response for working with action responses.

All action's parameters are documented as its public methods, see below.

Instance Method Summary collapse

Methods inherited from Get

#perform

Methods inherited from Base

#inspect, #merge, #name, #perform, #response, #to_h, #to_param, #to_url

Methods included from GlobalParams

#assert, #assertuser, #centralauthtoken, #curtimestamp, #errorformat, #errorlang, #errorsuselocal, #format, #maxage, #maxlag, #origin, #requestid, #responselanginfo, #servedby, #smaxage, #uselang

Instance Method Details

#contentformat(value) ⇒ self

Content serialization format used for the input text. Only valid when used with text.

Parameters:

  • value (String)

    One of "application/json", "text/x-wiki", "text/javascript", "text/css", "text/plain".

Returns:

  • (self)


187
188
189
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 187

def contentformat(value)
  _contentformat(value) or fail ArgumentError, "Unknown value for contentformat: #{value}"
end

#contentmodel(value) ⇒ self

Content model of the input text. If omitted, title must be specified, and default will be the model of the specified title. Only valid when used with text.

Parameters:

  • value (String)

    One of "GadgetDefinition", "SecurePoll", "MassMessageListContent", "JsonSchema", "wikitext", "javascript", "json", "css", "text", "Scribunto".

Returns:

  • (self)


200
201
202
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 200

def contentmodel(value)
  _contentmodel(value) or fail ArgumentError, "Unknown value for contentmodel: #{value}"
end

#disableeditsectionself

Omit edit section links from the parser output.

Returns:

  • (self)


144
145
146
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 144

def disableeditsection()
  merge(disableeditsection: 'true')
end

#disablelimitreportself

Omit the limit report ("NewPP limit report") from the parser output.

Returns:

  • (self)


137
138
139
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 137

def disablelimitreport()
  merge(disablelimitreport: 'true')
end

#disableppself

Use disablelimitreport instead.

Returns:

  • (self)


130
131
132
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 130

def disablepp()
  merge(disablepp: 'true')
end

#disabletidyself

Do not run HTML cleanup (e.g. tidy) on the parser output.

Returns:

  • (self)


151
152
153
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 151

def disabletidy()
  merge(disabletidy: 'true')
end

#disabletocself

Omit table of contents in output.

Returns:

  • (self)


179
180
181
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 179

def disabletoc()
  merge(disabletoc: 'true')
end

Includes language links supplied by extensions (for use with prop=langlinks).

Returns:

  • (self)


107
108
109
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 107

def effectivelanglinks()
  merge(effectivelanglinks: 'true')
end

#generatexmlself

Generate XML parse tree (requires content model wikitext; replaced by prop=parsetree).

Returns:

  • (self)


158
159
160
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 158

def generatexml()
  merge(generatexml: 'true')
end

#mainpageself

Apply mobile main page transformations.

Returns:

  • (self)


226
227
228
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 226

def mainpage()
  merge(mainpage: 'true')
end

#mobileformatself

Return parse output in a format suitable for mobile devices.

Returns:

  • (self)


212
213
214
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 212

def mobileformat()
  merge(mobileformat: 'true')
end

#noimagesself

Disable images in mobile output.

Returns:

  • (self)


219
220
221
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 219

def noimages()
  merge(noimages: 'true')
end

#oldid(value) ⇒ self

Parse the content of this revision. Overrides page and pageid.

Parameters:

  • value (Integer)

Returns:

  • (self)


73
74
75
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 73

def oldid(value)
  merge(oldid: value.to_s)
end

#onlypstself

Do a pre-save transform (PST) on the input, but don't parse it. Returns the same wikitext, after a PST has been applied. Only valid when used with text.

Returns:

  • (self)


100
101
102
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 100

def onlypst()
  merge(onlypst: 'true')
end

#page(value) ⇒ self

Parse the content of this page. Cannot be used together with text and title.

Parameters:

  • value (String)

Returns:

  • (self)


50
51
52
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 50

def page(value)
  merge(page: value.to_s)
end

#pageid(value) ⇒ self

Parse the content of this page. Overrides page.

Parameters:

  • value (Integer)

Returns:

  • (self)


58
59
60
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 58

def pageid(value)
  merge(pageid: value.to_s)
end

#previewself

Parse in preview mode.

Returns:

  • (self)


165
166
167
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 165

def preview()
  merge(preview: 'true')
end

#prop(*values) ⇒ self

Which pieces of information to get:

Parameters:

  • values (Array<String>)

    Allowed values: "text" (Gives the parsed text of the wikitext), "langlinks" (Gives the language links in the parsed wikitext), "categories" (Gives the categories in the parsed wikitext), "categorieshtml" (Gives the HTML version of the categories), "links" (Gives the internal links in the parsed wikitext), "templates" (Gives the templates in the parsed wikitext), "images" (Gives the images in the parsed wikitext), "externallinks" (Gives the external links in the parsed wikitext), "sections" (Gives the sections in the parsed wikitext), "revid" (Adds the revision ID of the parsed page), "displaytitle" (Adds the title of the parsed wikitext), "headitems" (Deprecated. Gives items to put in the of the page), "headhtml" (Gives parsed of the page), "modules" (Gives the ResourceLoader modules used on the page. To load, use mw.loader.using(). Either jsconfigvars or encodedjsconfigvars must be requested jointly with modules), "jsconfigvars" (Gives the JavaScript configuration variables specific to the page. To apply, use mw.config.set()), "encodedjsconfigvars" (Gives the JavaScript configuration variables specific to the page as a JSON string), "indicators" (Gives the HTML of page status indicators used on the page), "iwlinks" (Gives interwiki links in the parsed wikitext), "wikitext" (Gives the original wikitext that was parsed), "properties" (Gives various properties defined in the parsed wikitext), "limitreportdata" (Gives the limit report in a structured way. Gives no data, when disablelimitreport is set), "limitreporthtml" (Gives the HTML version of the limit report. Gives no data, when disablelimitreport is set), "parsetree" (The XML parse tree of revision content (requires content model wikitext)), "parsewarnings" (Gives the warnings that occurred while parsing content).

Returns:

  • (self)


81
82
83
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 81

def prop(*values)
  values.inject(self) { |res, val| res._prop(val) or fail ArgumentError, "Unknown value for prop: #{val}" }
end

#pstself

Do a pre-save transform on the input before parsing it. Only valid when used with text.

Returns:

  • (self)


93
94
95
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 93

def pst()
  merge(pst: 'true')
end

#redirectsself

If page or pageid is set to a redirect, resolve it.

Returns:

  • (self)


65
66
67
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 65

def redirects()
  merge(redirects: 'true')
end

#section(value) ⇒ self

Only parse the content of this section number.

Parameters:

  • value (String)

Returns:

  • (self)


115
116
117
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 115

def section(value)
  merge(section: value.to_s)
end

#sectionpreviewself

Parse in section preview mode (enables preview mode too).

Returns:

  • (self)


172
173
174
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 172

def sectionpreview()
  merge(sectionpreview: 'true')
end

#sectiontitle(value) ⇒ self

New section title when section is new.

Parameters:

  • value (String)

Returns:

  • (self)


123
124
125
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 123

def sectiontitle(value)
  merge(sectiontitle: value.to_s)
end

#summary(value) ⇒ self

Summary to parse.

Parameters:

  • value (String)

Returns:

  • (self)


42
43
44
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 42

def summary(value)
  merge(summary: value.to_s)
end

#templatesandboxcontentformat(value) ⇒ self

Content format of templatesandboxtext.

Parameters:

  • value (String)

    One of "application/json", "text/x-wiki", "text/javascript", "text/css", "text/plain".

Returns:

  • (self)


276
277
278
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 276

def templatesandboxcontentformat(value)
  _templatesandboxcontentformat(value) or fail ArgumentError, "Unknown value for templatesandboxcontentformat: #{value}"
end

#templatesandboxcontentmodel(value) ⇒ self

Content model of templatesandboxtext.

Parameters:

  • value (String)

    One of "GadgetDefinition", "SecurePoll", "MassMessageListContent", "JsonSchema", "wikitext", "javascript", "json", "css", "text", "Scribunto".

Returns:

  • (self)


263
264
265
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 263

def templatesandboxcontentmodel(value)
  _templatesandboxcontentmodel(value) or fail ArgumentError, "Unknown value for templatesandboxcontentmodel: #{value}"
end

#templatesandboxprefix(*values) ⇒ self

Template sandbox prefix, as with Special:TemplateSandbox.

Parameters:

  • values (Array<String>)

Returns:

  • (self)


234
235
236
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 234

def templatesandboxprefix(*values)
  values.inject(self) { |res, val| res._templatesandboxprefix(val) }
end

#templatesandboxtext(value) ⇒ self

Parse the page using this page content in place of the page named by templatesandboxtitle.

Parameters:

  • value (String)

Returns:

  • (self)


255
256
257
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 255

def templatesandboxtext(value)
  merge(templatesandboxtext: value.to_s)
end

#templatesandboxtitle(value) ⇒ self

Parse the page using templatesandboxtext in place of the contents of the page named here.

Parameters:

  • value (String)

Returns:

  • (self)


247
248
249
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 247

def templatesandboxtitle(value)
  merge(templatesandboxtitle: value.to_s)
end

#text(value) ⇒ self

Text to parse. Use title or contentmodel to control the content model.

Parameters:

  • value (String)

Returns:

  • (self)


34
35
36
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 34

def text(value)
  merge(text: value.to_s)
end

#title(value) ⇒ self

Title of page the text belongs to. If omitted, contentmodel must be specified, and API will be used as the title.

Parameters:

  • value (String)

Returns:

  • (self)


26
27
28
# File 'lib/mediawiktory/wikipedia/actions/parse.rb', line 26

def title(value)
  merge(title: value.to_s)
end