Difference between revisions of "User:R3vo"

From Bohemia Interactive Community
Jump to navigation Jump to search
m
m
Line 42: Line 42:
 
= Text Formatting =
 
= Text Formatting =
 
*[https://www.mediawiki.org/wiki/Help:Links/de Links]
 
*[https://www.mediawiki.org/wiki/Help:Links/de Links]
 +
 +
= Revo_fnc_exportFunctionsToWiki =
 +
<pre>/*
 +
Author: Karel Moricky, updated by Revo (23.12.2018)
 +
 +
Description:
 +
Export function descriptions to Community Wiki.
 +
Exported text will be copied to clipboard.
 +
Import it to wiki using https://community.bistudio.com/wiki?title=Special:Import
 +
If the page already exists, it will be replaced only when timestamp is newer.
 +
 +
Parameter(s):
 +
0: ARRAY - functions filter in format [<tags>,<categories>,<functions>]
 +
tags: STRING or ARRAY of STRINGs - CfgFunctions tags (e.g., "BIS"). Use empty string for all of them.
 +
categories: STRING or ARRAY of STRINGs - categories (e.g., "Debug"). Use empty string for all of them.
 +
functions: STRING or ARRAY of STRINGs - specific function names (e.g., "BIS_fnc_log"). Use empty string for all of them.
 +
1: NUMBER OR STRING - Game Version, default will be the current one. For version 1.00 insert "1.00"
 +
 +
Returns:
 +
NOTHING
 +
 +
Example:
 +
Export all functions: [] spawn bis_fnc_exportFunctionsToWiki;
 +
Export all Array functions: [["","Arrays"]] spawn bis_fnc_exportFunctionsToWiki;
 +
Export specific functions: [["","",["BIS_fnc_log","BIS_fnc_param"]]]  spawn bis_fnc_exportFunctionsToWiki;
 +
*/
 +
_path = _this param [0,[],[[]]];
 +
_gameVersion = _this param [1,productVersion # 2 / 100,[0,""]];
 +
_pathTags = _path param [0,[],[[],""]];
 +
_pathCategories = _path param [1,[],[[],""]];
 +
_pathFunctions = _path param [2,[],[[],""]];
 +
_text = "";
 +
_cfgRoot = configFile >> "cfgfunctions";
 +
_projects = ["arma2","arma2oa","tkoh","arma3"];
 +
_indent = 1;
 +
 +
if (_pathTags isEqualType "") then {_pathTags = [_pathTags]};
 +
if (_pathCategories isEqualType "") then {_pathCategories = [_pathCategories]};
 +
if (_pathFunctions isEqualType "") then {_pathFunctions = [_pathFunctions]};
 +
 +
_allTags = {_x != ""} count _pathTags == 0;
 +
_allCategories = {_x != ""} count _pathCategories == 0;
 +
_allFunctions = {_x != ""} count _pathFunctions == 0;
 +
 +
_fnc_addLine = {
 +
for "_t" from 1 to _indent do {_text = _text + " ";};
 +
_text = _text + _this + endl;
 +
};
 +
 +
_functionsList = call (uiNamespace getVariable ["BIS_functions_list",{[]}]);
 +
_functionsListCount = count _functionsList;
 +
 +
{
 +
_function = _x;
 +
_meta = _x call bis_fnc_functionMeta;
 +
_metaPath = _meta # 0;
 +
_metaFormat = _meta # 1;
 +
_metaTag = _meta # 6;
 +
_metaCategory = _meta # 7;
 +
_metaName = _meta # 8;
 +
 +
if (
 +
(_allTags || {{_metaTag == _x} count _pathTags > 0})
 +
&&
 +
{_allCategories || {{_metaCategory == _x} count _pathCategories > 0}}
 +
&&
 +
{_allFunctions || {{_function == _x} count _pathFunctions > 0}}
 +
)
 +
then
 +
{
 +
//Header
 +
_file = loadFile _metaPath;
 +
_headerStart = _file find "/*";
 +
_headerEnd = _file find "*/";
 +
_fileHeader = _file select [_headerStart,_headerEnd + 2];
 +
 +
_description = if (_fileHeader == "" || _metaFormat != ".sqf") then
 +
{
 +
"''N/A''"
 +
} else
 +
{
 +
format ["<pre>%1</pre>{{Informative|Placeholder description extracted from the function header by [[BIS_fnc_exportFunctionsToWiki]]}}",_fileHeader]
 +
};
 +
 +
_project = getText (_cfgRoot >> _metaTag >> "project");
 +
if (_project == "") then {_project = toLower (productVersion # 1)};
 +
 +
_indent = 0;
 +
 +
//Function template
 +
"{{Function|= Comments" call _fnc_addLine;
 +
"" call _fnc_addLine;
 +
format ["| %1 |Game name=",_project] call _fnc_addLine;
 +
"" call _fnc_addLine;
 +
format ["|%1|Game version=",_gameVersion] call _fnc_addLine;
 +
"" call _fnc_addLine;
 +
"<!---|arg= local |Multiplayer Arguments=--->" call _fnc_addLine;
 +
"" call _fnc_addLine;
 +
"<!---|eff= local |Multiplayer Effects=--->" call _fnc_addLine;
 +
"" call _fnc_addLine;
 +
format ["| %1 |Description=",_description] call _fnc_addLine;
 +
"" call _fnc_addLine;
 +
format ["|[] call [[%1]]|Syntax=",_function] call _fnc_addLine;
 +
"" call _fnc_addLine;
 +
"|p1= parameter: Datatype - (Optional, default defValue) description |Parameter 1=" call _fnc_addLine;
 +
"" call _fnc_addLine;
 +
"|Datatype - description|Return value=" call _fnc_addLine;
 +
"" call _fnc_addLine;
 +
"|x1= <code></code>|Example 1=" call _fnc_addLine;
 +
"" call _fnc_addLine;
 +
"| |See also=" call _fnc_addLine;
 +
"}}" call _fnc_addLine;
 +
"" call _fnc_addLine;
 +
//Categories
 +
format ["[[Category:Function Group: %2|{{uc:%1}}]]",_metaName,_metaCategory] call _fnc_addLine;
 +
format ["[[Category:Functions|{{uc:%1}}]]",_metaName] call _fnc_addLine;
 +
_compatible = false;
 +
{
 +
if (_x == _project) then {_compatible = true;};
 +
if (_compatible) then {
 +
format ["[[Category:{{Name|%2}}: Functions|{{uc:%1}}]]",_metaName,_x] call _fnc_addLine;
 +
};
 +
} foreach _projects;
 +
};
 +
systemChat format ["Progress:%1/100%2",round ((_foreachindex / _functionsListCount) * 100),"%"];
 +
} forEach _functionsList;
 +
 +
copyToClipboard _text;</pre>

Revision as of 02:06, 24 December 2018


About Me

Template:User de
Template:User en-2

GUI Documentation

Eden

Scripting

BIWiki To-Do

Text Formatting

Revo_fnc_exportFunctionsToWiki

/*
	Author: Karel Moricky, updated by Revo (23.12.2018)

	Description:
	Export function descriptions to Community Wiki.
	Exported text will be copied to clipboard.
	Import it to wiki using https://community.bistudio.com/wiki?title=Special:Import
	If the page already exists, it will be replaced only when timestamp is newer.

	Parameter(s):
		0: ARRAY - functions filter in format [<tags>,<categories>,<functions>]
			tags: STRING or ARRAY of STRINGs - CfgFunctions tags (e.g., "BIS"). Use empty string for all of them.
			categories: STRING or ARRAY of STRINGs - categories (e.g., "Debug"). Use empty string for all of them.
			functions: STRING or ARRAY of STRINGs - specific function names (e.g., "BIS_fnc_log"). Use empty string for all of them.
		1: NUMBER OR STRING - Game Version, default will be the current one. For version 1.00 insert "1.00"

	Returns:
	NOTHING

	Example:
	Export all functions:		[] spawn bis_fnc_exportFunctionsToWiki;
	Export all Array functions:	[["","Arrays"]] spawn bis_fnc_exportFunctionsToWiki;
	Export specific functions:	[["","",["BIS_fnc_log","BIS_fnc_param"]]]  spawn bis_fnc_exportFunctionsToWiki;
*/
_path = _this param [0,[],[[]]];
_gameVersion = _this param [1,productVersion # 2 / 100,[0,""]];
_pathTags = _path param [0,[],[[],""]];
_pathCategories = _path param [1,[],[[],""]];
_pathFunctions = _path param [2,[],[[],""]];
_text = "";
_cfgRoot = configFile >> "cfgfunctions";
_projects = ["arma2","arma2oa","tkoh","arma3"];
_indent = 1;

if (_pathTags isEqualType "") then {_pathTags = [_pathTags]};
if (_pathCategories isEqualType "") then {_pathCategories = [_pathCategories]};
if (_pathFunctions isEqualType "") then {_pathFunctions = [_pathFunctions]};

_allTags = {_x != ""} count _pathTags == 0;
_allCategories = {_x != ""} count _pathCategories == 0;
_allFunctions = {_x != ""} count _pathFunctions == 0;

_fnc_addLine = {
	for "_t" from 1 to _indent do {_text = _text + "	";};
	_text = _text + _this + endl;
};

_functionsList = call (uiNamespace getVariable ["BIS_functions_list",{[]}]);
_functionsListCount = count _functionsList;

{
	_function = _x;
	_meta = _x call bis_fnc_functionMeta;
	_metaPath = _meta # 0;
	_metaFormat = _meta # 1;
	_metaTag = _meta # 6;
	_metaCategory = _meta # 7;
	_metaName = _meta # 8;

	if (
		(_allTags || {{_metaTag == _x} count _pathTags > 0})
		&&
		{_allCategories || {{_metaCategory == _x} count _pathCategories > 0}}
		&&
		{_allFunctions || {{_function == _x} count _pathFunctions > 0}}
		)
	then
	{
		//Header
		_file = loadFile _metaPath;
		_headerStart = _file find "/*";
		_headerEnd = _file find "*/";
		_fileHeader = _file select [_headerStart,_headerEnd + 2];

	_description = if (_fileHeader == "" || _metaFormat != ".sqf") then
	{
		"''N/A''"
	} else
	{
		format ["<pre>%1

Template:Informative",_fileHeader]

};

_project = getText (_cfgRoot >> _metaTag >> "project"); if (_project == "") then {_project = toLower (productVersion # 1)};

_indent = 0;

//Function template "

-wrong parameter ("%1") defined!-[[:Category:Introduced with %1 version %1|%1]]
Hover & click on the images for description

Description

Description:
%1
Execution:
call
Groups:
Uncategorised

Syntax

Syntax:
[] call %1
Parameters:
parameter: Datatype - (Optional, default defValue) description
Return Value:
Datatype - description

Examples

Example 1:

Additional Information

See also:
See also needed

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note

[[Category:Introduced with %1 version %1]][[ Category: %1: New Functions | R3VO]][[ Category: %1: Functions | R3VO]]" call _fnc_addLine;

"" call _fnc_addLine; //Categories format ["",_metaName,_metaCategory] call _fnc_addLine; format ["",_metaName] call _fnc_addLine; _compatible = false; { if (_x == _project) then {_compatible = true;}; if (_compatible) then { format ["[[Category:%2: Functions|%1]]",_metaName,_x] call _fnc_addLine; }; } foreach _projects; }; systemChat format ["Progress:%1/100%2",round ((_foreachindex / _functionsListCount) * 100),"%"]; } forEach _functionsList;

copyToClipboard _text;