FANDOM


editHelpEdit

This JavaScript module is a proposed extension to Wikia's source editor. It displays template documentation within the editor itself - in the form of short documentation snippets as well as in the form of links to full-size Help pages (which will open in a new tab). The long term goal is to make documentation for the entirety of wikitext available within the editor. The idea is to not only liberate experienced users from memorizing every detail about wikitext in general and the local wiki's template structure in particular, but also to make the editor more friendly to newbies by potentially turning every edit into an editing tutorial.

What it (currently) does Edit

editHelp currently attaches itself to the "Templates" module of the source editor's sidebar. It displays:

  • a dropdown menu with all templates that were used in the current page (not transcluded templates - only templates whose name shows up in the page and for which documentation is available),
  • documentation about the currently selected template (if any),
  • a dropdown menu with the selected template's parameters and
  • documentation about the currently selected parameter (if any).

editHelp is live. The documentation is loaded live from the templates' documentation pages. Every template and every template parameter a user adds or removes will change the widget's contents.

editHelp can be navigated not only via the dropdown menus but also by simply editing. Every keystroke and every mouse click updates the list of used templates, the currently active template and the currently active parameter. Users will be shown information about the template they're using and the parameter they're adding while they're editing them.

Status Edit

editHelp should be considered a demo in its current form. The included wikitext parser is not supremely reliable yet (more on that below). <nowiki> sections e.g. still trip it up. Whether using a home-grown parser is viable in the long run is unclear at this point. Using an existing solution like Parsoid may turn out to be superior.

editHelp does however run as advertised on all article pages I've tested it on. As such I feel the proposal is in a state where it can be introduced to the Fallout community and ask whether they like it and/or whether they'd like to see changes made. It should also be submitted to Wikia to make sure it doesn't violate their TOS or their JavaScript standards.

This proposal has been submitted to the forum for review.

Planned Features Edit

  • Next on the todo list are parser functions and magic words. While not the most important wikitext features, covering them next still makes sense since they're so similar to templates.
  • The fact that the documentation changes while you type may not always be useful, so a "Lock" checkbox should be added.
  • There should be a breadcrumb trail to help with nesting. If you're editing an ID template within an Infobox_character template e.g. the breadcrumb trail should read: "Infobox character => ID"

How to use it Edit

editHelp does not get loaded automatically at this time. You will have to load it manually on each edit page from User:Mazn/Doc. To do so, open your browser's web console, copypaste this:

$.getScript('/load.php?mode=articles&only=scripts&articles=User:Mazn/Doc');

hit "Enter" and close the web console again.

Known issues Edit

  • The loading indicator will be shown until at least one template is found. On empty pages or pages without documented templates, it will be shown forever.
  • If a template's documentation is not stored under templateName + "/doc" - like Template:Navbox_companions_FO4 e.g. whose documentation is stored at Template:Navbox/doc/standard - editHelp will falsely claim that no documentation exists.
  • The tokenizer does not recognize magic words or parser functions and will falsely label them as unknown templates.
  • The tokenizer currently analyzes the entire document instead of focussing on the caret's vicinity. There's some - potentially a lot - of room for performance optimization.
  • The tokenizer doesn't handle triple braces which means it's not useful for editing templates yet.
  • The tokenizer doesn't handle templates without closing braces ("}}"). Some kind of autoclosing mechanism has yet to be added, since unclosed templates are a common occurrence while editing.
  • The tokenizer doesn't handle comments, <nowiki>, <pre> and other extension tags that take precedence over templates.
  • The tokenizer assumes that all links within a template's body are closed. Unclosed links may cause pipes ("|") to be misinterpreted.
  • The documentation parser uses a lot of duct tape and wishful thinking. While the documentation at this wiki is extremely regular when compared to other wikis - thanks to Template:Docparam - it's still not ideal. One or two minor changes to Template:Docparam may be necessary. It would also be helpfull to add one or two new documentation templates - a template for the template description e.g.

Debugging tools Edit

editHelp offers a few introspection tools for users who know their way around JavaScript. You can turn debugMode on with:

window.dev.editHelp.setDebugMode( true );

This will continuously log the internal state to the web console. The debugMode is persistently saved in localStorage so you will have to manually set it to false to turn it off again. Performance may take a hit while debugMode is on

To get more introspection methods, you will have to "load" editHelp to make sure all components are active. That will return a Promise whose doneCallback receives an object with the additional methods:

window.dev.editHelp.load()
.done( function ( debug ) {
    // log an array of all the templates that were detected:
    console.log( debug.getTemplates() );
} );
  • debug.getTemplates(); returns an array of the templates that were used in the current page and for which documentation is available.
  • debug.getTemplate(); returns the name of the currently selected template from above list or -1 if there's no selected template or -2 if the template at the caret position doesn't exist or is undocumented.
  • debug.getParam(); returns the name of the currently selected template parameter or -1 if there's no selected parameter or -2 if the parameter at the caret position doesn't exist or is undocumented.
  • debug.getDocumented(); returns an array of all templates that are known to have documentation. This list is created while editHelp loads and cached in localStorage for an hour. To see debug information about the loading process, you would have to turn debugMode on, delete the cache with debug.clearDocumented(); and reload the page.
  • debug.logTokens(); displays the contents of the edit area broken down in tokens. Depending on the page, the list of tokens may be rather long and the output is verbose, so use this with care. Unlike the previous introspection functions, this one is only available while debugMode is turned on.

History Edit

  • Rewrote view to rely more on CSS for state changes. Mazn (talk) 14:35, January 17, 2016 (UTC)
  • Rewrote editor detection to function during page load and not only when editHelp is loaded from the console. Mazn (talk) 14:35, January 17, 2016 (UTC)
  • Fixed: Did not load mediawiki.api before using it. (Odd that the API is loaded by default in FF but not in Chrome) Mazn (talk) 15:21, January 15, 2016 (UTC)
Community content is available under CC-BY-SA unless otherwise noted.

Fandom may earn an affiliate commission on sales made from links on this page.

Stream the best stories.

Fandom may earn an affiliate commission on sales made from links on this page.

Get Disney+