User blog:Rail/Contributing to Dev Wiki

When you are writing codes for your wiki such as styles with CSS, functionality improvements or entire new tools with JavaScript, or advanced templates using Lua, you might at some point find yourself wanting to share your work with the broader Fandom community and let other wikis use your codes.

Previously wikis used to do that by copying codes from each other and applying them in their own applications. Currently, there is a much better option for that, and it’s contributing your work to Dev Wiki.



It’s a place where you can add your code, as it's not your typical wiki where code pages can only be edited by administrators, but instead by every registered user can do it, and it can then be used by wikis and users across Fandom without manually copying everything. Instead, they can only use imports (smaller functions loading the code from Dev Wiki) and always enjoy the up-to-date best version of your code.

In order to have your code published on Dev Wiki for everyone to use, you should give your project an easy to recognize and remember name. Some good examples might be DiscordIntegrator - a script that lets you integrate Discord widgets into a wiki, or AntiBigText - a style that reduces font sizes on pages. A good name will help other users find your code when they're looking for a specific solution for themselves.

Once you have your name, whether it's for a JavaScript, CSS or Lua module page, you should publish your code on the wiki. Since Dev Wiki allows everyone to edit code pages, you can simply place your project under,   or   name. When writing codes that are intended to be published on Dev Wiki, you might also find its coding conventions handy!

For JavaScript pages before they can be used, they need to undergo the review process where staff member from Trust & Safety team will make sure it's safe to use. Normally when you would have users copying your JS code manually, review would have to happen on every wiki separately, but with Dev Wiki, your code can only pass review there and be used everywhere else without additional review!

Once your code is published and submitted for review, it's time to write a documentation page for your project, to make it easy to find help users understand what it's all about. Depending on the nature of your project it can be a detailed technical description (for example for JavaScript libraries) or a user-friendly step-by-step usage guide, or a mix of both!



It's always good to take a look at how other project pages are structured and built and use that for your own, that way you can be sure you don't get anything wrong. A WHAM project page is a good example to go by.



As you might see, the WHAM page contains parameters for other pages to use. It's part of the internationalization, an effort to make both code projects themselves and their respective documentation pages accessible and easy to use for users speaking various languages across the globe. Dev Wiki describes this process on its internationalization page.

When internationalizing your code, you will mostly be interested in making sure text used by your JavaScript is translatable. For example, when you’re writing a JavaScript code that adds a new option in pages’ “Edit” Dropdown like this:

You can use I18n-js library from Dev Wiki to easily and quickly make your script translatable:

Let’s quickly take a look what changed here:
 * Main code is not located inside a function  with   parameter, which is a bridge between your code and the i18n-js library
 * After the  code ends, there is an   statement loading I18n-js code. Don’t worry! If there is already i18n-js loaded, it won’t break anything.
 * Then, a special hook is used to wait until all I18n-js elements are ready to go.
 * Upon hook being executed, it runs a function loading text from Dev Wiki and launches your  function.

This means text parts of your code will be stored on Dev Wiki separately from the programmatic code in a page following this naming scheme:, so in this case –  , as   is what we ask   function to load.