Dev Wiki:Coding conventions

''This is a resource for users maintaining scripts on Dev Wiki. For code review, see Portal:Code review. To request a new script, see Portal:Script suggestions.''

Writing a script
Scripts and their documentation are typically found in the mainspace. For example AjaxRC can be found here, and it's source code can be found AjaxRC/code.js. For organisation, the source code should be a subpage of the documentation page. Typically the main js and css files for a script are named code.js and code.css respectively, although this isn't required.

What to include on a documentation page
A script's documentation will likely include a number of things, the most common are:
 * A description of the script
 * Import instructions and any setup instructions
 * A demo of the script, see DemoScripts below.

Much of the information you might want to include is in ready to use templates, such as Infobox JavaScript, Infobox CSS and ImportArticles.

Code protection
Experienced users can request they be added to the codeeditor usergroup. This allows them to edit protected code pages and edit DemoScripts.js. This can be requested at Wikia Developers Wiki:Requests for Codeeditor. This allows them to request their scripts to be protected to prevent vandalism and add a level of security for anyone using the script. To request your scripts be protected, add Code protect to the code page to be protected which will notify an admin of the request.

DemoScripts
DemoScripts.js is to let users add interactive demo's of their scripts to their documentation. It can be edited by users in the codeeditor, volunteer developer and admin groups. If you have any questions about how to add your script as a demo see Talk:DemoScripts.js.

If you would like to add a demo of your script and are not a member of any of these groups, you can request it be copied into DemoScripts.js. Unprotected scripts will not be imported by DemoScripts as the demo can be loaded everywhere on the wiki and are a security vulnerability.