Difference between revisions of "User:Kebap"
Jump to navigation
Jump to search
(+1) |
|||
Line 43: | Line 43: | ||
* Learn more [[User:Kebap/git commands|git commands]] | * Learn more [[User:Kebap/git commands|git commands]] | ||
− | = Examples for | + | = Examples for formatting = |
+ | |||
+ | API documentation of a function as used in [[Manual:Lua_functions]]: | ||
==functionName== | ==functionName== | ||
Line 73: | Line 75: | ||
--the comments up top should introduce it/explain what the snippet does | --the comments up top should introduce it/explain what the snippet does | ||
functionName("arg1", "arg2") | functionName("arg1", "arg2") | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | |||
+ | == Standardized error messages in code == | ||
+ | |||
+ | Old style, not very informative: | ||
+ | <syntaxhighlight lang="cpp"> | ||
+ | if (!lua_isnumber(L, 1)) { | ||
+ | lua_pushstring(L, "createMapLabel: wrong argument type"); | ||
+ | return lua_error(L); | ||
+ | } | ||
+ | int area = lua_isnumber(L, 1); | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | New style with additional information: | ||
+ | <syntaxhighlight lang="cpp"> | ||
+ | if (!lua_isnumber(L, 1)) { | ||
+ | lua_pushfstring(L, | ||
+ | "createMapLabel: bad argument #1 type (areaID as number expected, got %s!)", | ||
+ | luaL_typename(L, 1)); | ||
+ | return lua_error(L); | ||
+ | } | ||
+ | int area = lua_tointeger(L, 1); | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 13:05, 7 January 2021
About me
Mudlet user and script developer, hailing from MorgenGrauen (German).
Projects
- User:Kebap/documentation-in-wiki - currently on hold
- Establish translation-infrastructure for Mudlet universe
- Create PR to clean up feedback from Crowdin - see issue 1802
- Improve documentation for translators
- How to translate plural forms in crowdin
- Improve documentation for developers
- How to handle special characters at start or end of translateable text
- Learn how to write working i18n style code for English hacks like "next %n time(s)"
- QT documentation thereof: http://doc.qt.io/qt-5/i18n-source-translation.html#handling-plurals
- Graphical overview of Release dates
- Add MorgenGrauen to Mudlet MUDs
- review recommendations from Listing_Your_MUD
Enable Discord group "Testers" to (de-)register themselves via Discord reactionsdone! :)
- Create PR to clean up texts in source - see github issue 1801
Learn how to make small PR like above with Smart Git instead of github web interfacedone! :)
- Improve Mudlet documentation, which is not interesting for Mudlet users, but only for (some) developers.
- Including definitions on internal functions,
- discussions and decisions on coding style conventions,
- standard procedures like Release Checklist, update lua function list for autocompletion,
- This is done by adding Categories like "Mudlet Developer Manual" or "Mudlet Admin Manual"
- etc.
- Learn more git commands
Examples for formatting
API documentation of a function as used in Manual:Lua_functions:
functionName
- functionName(arg1, arg2, [optionalArg3])
- What the function does. In this case, it is just a non-existing function with the only purpose to show, how to write documentation for functions
Note: This is an important information
Available in Mudlet3.5+
- Parameters
- arg1:
- What arg1 is/does. Passed as a string.
- arg2:
- What arg2 is/does. Passed as a string.
- optionalArg3
- (optional) The name needn't be telling. Relevant is to mark optional arguments at the start of this line (with text "optional" in brackets) and in the function definition line (with [these] brackets)
- Returns
- whatever the function returns.
- Example
--a small example snippet of the function in action
--the comments up top should introduce it/explain what the snippet does
functionName("arg1", "arg2")
Standardized error messages in code
Old style, not very informative:
if (!lua_isnumber(L, 1)) {
lua_pushstring(L, "createMapLabel: wrong argument type");
return lua_error(L);
}
int area = lua_isnumber(L, 1);
New style with additional information:
if (!lua_isnumber(L, 1)) {
lua_pushfstring(L,
"createMapLabel: bad argument #1 type (areaID as number expected, got %s!)",
luaL_typename(L, 1));
return lua_error(L);
}
int area = lua_tointeger(L, 1);