ਵਿਕੀਪੀਡੀਆ:ਸਕਰਿਬੁੰਟੋ
ਲੂਆ ਇੱਕ ਪ੍ਰੋਗ੍ਰਾਮਿੰਗ ਭਾਸ਼ਾ ਹੈ ਜੋ ਹੁਣ ਅੰਗਰੇਜੀ ਵਿਕੀਪੀਡੀਆ ਉੱਤੇ, ਸਕਿਰਬੰਟੋ ਮੀਡੀਆਵਿਕੀ ਐਕਸਟੈਂਸ਼ਨ ਰਾਹੀਂ ਉਪਲਬਧ ਹੈ। ਲੁਆ ਕੋਡ ਨੂੰ ਹੁਣ ਵਿਕੀਪੀਡੀਆ ਟੈਂਪਲੈਂਟਾਂ ਵਿੱਚ ਸਕਿਰਬੰਟੋ ਦੇ "{{#invoke:}}" ਫੰਕਸ਼ਨ ਨੂੰ ਲਾਗੂ ਕਰਕੇ ਜੜਿਆ ਜਾ ਸਕਦਾ ਹੈ। ਇਹ ਐਕਸਟੈਨਸ਼ਨ ਜੁਲਾਈ 2015 ਤੋਂ ਲੁਆ 5.1 ਜੁਲਾਈ 2015 ਤੱਕ [update] ਨੂੰ ਸਪੋਰਟ ਕਰਦੀ ਹੈ। ਲੁਆ ਸੋਰਸ ਕੋਡ ਮੌਡਿਊਲਜ਼ (ਯਾਨਿ ਕਿ, Module:Bananas) ਨਾਮਕ ਪੰਨਿਆਂ ਵਿੱਚ ਜਮਾਂ ਹੁੰਦੇ ਜਾਂਦੇ ਹਨ। ਇਹ ਵਿਅਕਤੀਗਤ ਮੌਡਿਊਲਜ਼ ਫੇਰ ਟੈਂਪਲੈਂਟ ਪੰਨਿਆਂ ਉੱਤੇ "{{#invoke:}}" ਕੋਡ ਰਾਹੀਂ ਇਨਵੋਕ (ਬੁਲਾਏ) ਕੀਤੇ ਜਾਂਦੇ ਹਨ। (ਜਿਵੇਂ Module:Bananas/doc ਇਸ "Hello, world!" ਸ਼ਬਦਾਂ ਨੂੰ ਛਾਪਣ ਵਾਸਤੇ ਆਰਜੂਮੈਂਟਾਂ ਵਰਤਣਾਆਰਜੂਮੈਂਟਾਂ ਮੌਡਿਊਲਾਂ ਵੱਲ ਉਸੇ ਤਰੀਕੇ ਨਾਲ ਪਾਸ ਕੀਤੀਆਂ ਜਾਂਦੀਆਂ ਹਨ ਜਿਸਤਰਾਂ ਫਰਮੇ ਪਾਸ ਹੁੰਦੇ ਹਨ। ਫੇਰ ਵੀ, ਨੋਟ ਕਰੋ ਕਿ ਪਹਿਲੇ ਪਾਈਪ ਅੱਖਰ ਤੋਂ ਬਾਦ ਦੇ ਅਗਲੇ ਅੱਖਰ ਹਮੇਸ਼ਾਂ ਹੀ ਫੰਕਸ਼ਨ ਦਾ ਨਾਮ ਹੁੰਦੇ ਹਨ; ਪਹਿਲੀ ਪੁਜ਼ੀਸ਼ਨ ਵਾਲੀ ਆਰਜੂਮੈਂਟ ਦੂਜੀ ਪਾਈਪ ਤੋਂ ਬਾਦ ਦੇ ਟੈਕਸਟ ਹੁੰਦੇ ਹਨ। {{#invoke:module name|function name|first positional argument|second positional argument|named argument = value}} ਉਦਾਹਰਨ ਦੇ ਤੌਰ ਤੇ, Module:BananasArgs ਵਿੱਚ , "hello" ਫੰਕਸ਼ਨ ਵੱਖਰੇ ਲੋਕਾਂ ਦਾ ਸਵਾਗਤ ਕਰਨਾ ਪਹਿਲੀ ਪੁਜ਼ੀਸ਼ਨ ਵਾਲੀ ਆਰਜੂਮੈਂਟ ਤੇ ਨਿਰਭਰ ਕਰਦਾ ਹੈ। ਇਹ ਇਸਤਰਾਂ ਕੰਮ ਕਰਦਾ ਹੈ:
BananasArgs ਕੋਲ ਇੱਕ "count_fruit" ਨਾਮਕ ਫੰਕਸ਼ਨ ਵੀ ਹੁੰਦਾ ਹੈ ਜੋ
ਜਿਆਦਾਤਰ ਮੌਡਿਊਲਜ਼ ਇੱਕ ਡੌਕੂਮੈਂਟੇਸ਼ਨ ਪੰਨਾ ਰੱਖਦੇ ਹੋਣਗੇ ਜਿਸਵਿੱਚ ਇਹ ਸਮਝਾਇਆ ਗਿਆ ਹੁੰਦਾ ਹੈ ਕਿ ਕਿਹੜੀਆਂ ਆਰਜੂਮੈਂਟਾਂ ਕੀਤੀਆਂ ਜਾ ਸਕਦੀਆਂ ਹਨ ਅਤੇ ਉਹਨਾਂ ਦੇ ਪ੍ਰਭਾਵ ਕੀ ਹੋਣਗੇ । ੳਦਾਹਰਨਾਂ
ਕਿਸੇ ਸਕ੍ਰਿਪਟ ਦੀ ਬੇਨਤੀ ਕਰੋ
ਇਤਿਹਾਸਸੌਰਡਿਡ ਇਤਿਹਾਸ. {{qif}}, ਪਾਰਜ਼ਰਫੰਕਸ਼ਨ (ParserFunctions), ਲੂਆ ਸ਼ਾਖਾ, ਵਿਕੀ ਸਕ੍ਰਿਪਟਿੰਗ ਭਾਸ਼ਾ ਨੇ (JavaScript v. Lua), mw:Extension:WikiScripts ਮੁਕਾਬਲਾ ਕਰਾਇਆ, ਲੂਆ ਵਾਸਤੇ ਸ਼ੁਰੂਆਤੀ ਸਮਰਥਨ ਨਾਲ ਟਿੱਮ ਸਕਿਰਬੰਟੋ ਲਿਖਦਾ ਹੈ| ਸਾਲਾਂ ਦੀ ਚਰਚਾ ਤੋਂ ਬਾਦ ਲੂਆ ਨੂੰ test2.wikipedia.org ਉੱਤੇ ਪਰਖਣ ਵਾਸਤੇ 2012 ਵਿੱਚ ਇਨਸਟਾਲ ਕੀਤਾ ਗਿਆ, ਜਿਸ ਵਿੱਚ ਲੂਆ ਮੌਡਿਊਲਾਜ਼ ਨੂੰ ਵਿਕਸਿਤ ਕਰਨ ਵਾਲੇ ਪ੍ਰਯੋਗਾਂ ਲਈ ਸਾਰੇ ਸੰਪਾਦਕਾਂ ਨੂੰ ਖੁੱਲਾ ਸੱਦਾ ਦਿੱਤਾ ਗਿਆ | ਲੂਆ ਫਰਵਰੀ 2013 ਵਿੱਚ ਅੰਗਰੇਜੀ ਵਿਕੀਪੀਡੀਆ ਵਿੱਚ mediawiki.org ਅਤੇ Wikimedia test wikis ਉੱਤੇ ਪਰਖਣ ਤੋਂ ਬਾਦ ਇਨਸਟਾਲ ਕਰ ਦਿੱਤੀ ਗਈ| ਲੂਆ ਬਾਰੇLua is a scripting language which can be used to analyze data, calculate expressions, and format results using functions or object-oriented programming. Although some Lua scripts can be kept simple, for easy understanding, Lua allows complex structures including tables, dynamic functions, and associative arrays where index subscripts can be words as well as index numbers. Lua also supports recursion of re-nested functions, so care should be taken to avoid excessive complexity where other users would not understand how to maintain a Lua module. The following is an example of Lua source code for a hello world function contained in Module:HelloWorld: -- All Lua modules on Wikipedia must begin by defining a variable that will hold their
-- externally accessible functions. They can have any name and may also hold data.
my_object = {}
-- Add a function to the variable. These are callable in Wikipedia via the #invoke command.
-- "frame" will contain the data that Wikipedia sends this function when it is called.
my_object.hello = function( frame )
-- Declare a local variable and assign data to it.
local str = "Hello World!"
-- Quit this function and send the information in "str" back to Wikipedia.
-- The "print" function is not allowed, so all output is accomplished via
-- returning strings in this fashion.
return str
-- End the function.
end
-- All modules end by returning the variable containing its functions to Wikipedia.
return my_object
-- We can now use this module by calling {{#invoke: HelloWorld | hello }}.
-- The #invoke command begins with the module's name, in this case "HelloWorld",
-- then takes the name of one of its functions as an argument, in this case "hello".
A sample of Lua is highlighted by tag "<source lang="lua">...</source>" placed around the Lua source code. To view some more complex examples of Lua, see article: "Lua (programming language)". For instructions on how to use Lua within MediaWiki (and hence Wikipedia), see mw:Extension:Scribunto/Lua reference manual. ਯੂਨਿਟ ਪਰਖਣਾA unit testing framework for Lua scripts on Wikipedia is available at Module:UnitTests. It allows you to execute your script on a given set of inputs and verify that the expected outputs are produced. Unit tests are especially useful for rapidly detecting regressions, where modifications to a script introduce new (or old) problems. By convention, unit tests for a module like Module:Bananas are placed in Module:Bananas/testcases, and are executed on Module talk:Bananas/testcases with e.g. -- Unit tests for [[Module:Bananas]]. Click talk page to run tests.
local p = require('Module:UnitTests')
function p:test_hello()
self:preprocess_equals('{{#invoke:Bananas | hello}}', 'Hello, world!')
end
return p
For a list of all modules using unit tests, see Special:Whatlinkshere/Module:UnitTests. There's also an alternative unit testing framework in use called Module:ScribuntoUnit, that originates from Hungarian Wikipedia. Feature-wise it's very similar to Module:UnitTests, but it has a different coding style, and throws real errors that are trapped using protected calls. It also has a method to compare floats within a given precision. ਵਿਕੀਪੀਡੀਆ ਵਿਸ਼ੇਸ਼ ਵਿਸ਼ੇਸ਼ਤਾਵਾਂOverall: Lua can only get input as text strings passed to the ਲੂਆ ਇਨਪੁੱਟ ਕਮੀਆਂLua code in Scribunto is only run when the page is being parsed. Therefore, the only user input that Lua can receive is by page editing - it cannot create a box that calculates the square root of a number you type in, or recalculate a piece of the Mandelbrot set depending on which part of the parent set you click on. The input Lua can receive includes any transcludeable text page on Wikipedia. This does not include graphics files (not even .SVG files, although they are actually text, unless you cut and paste it onto a Wiki text page), the list of pages listed in a category, nor the contents of non-transcludeable special pages. ਵਿਕੀਟੈਕਸਟTranscluded Wikipedia headers frequently contain a hidden code such as "UNIQ5ae8f2aa414ff233-h-3--QINU" which may need to be stripped out in order for them to be parsed effectively. Wikilinks of the type [[Wikipedia:Help|]] won't work if returned as output - they need to be written explicitly as [[Wikipedia:Help|Help]]. Other pre-save transforms, such as replacing ਬਦਲੇ ਹੋਏ ਫਰਮਿਆਂ ਦਾ ਨਾਮਕਰਨ
ਕਿਰਪਾ ਕਰਕੇ {{lua}} ਫਰਮਿਆਂ ਨੂੰ ਉਹਨਾਂ ਸਾਰੇ ਫਰਮਿਆਂ ਦੇ ਡਾਕੂਮੈਂਟੇਸ਼ਨ ਉੱਪ-ਪੰਨਿਆਂ ਉੱਤੇ ਰੱਖੋ ਜੋ ਲੂਆ ਵਰਤਦੇ ਹਨ, ਇਹ ਲੂਆ ਵਰਤੋਂ ਅਤੇ ਫਰਮਾ ਪਰਿਵਰਤਨਾਂ ਦੇ ਸਹਿਯੋਗ ਵਿੱਚ ਮਦੱਦ ਕਰੇਗਾ| ਇਹ ਵੀ ਦੇਖੋ
ਨੋਟਸ |
Portal di Ensiklopedia Dunia