Guidelines:Modules: Difference between revisions

Jump to navigation Jump to search
m
No edit summary
Line 147: Line 147:
When coding a module, the best page to preview is often the corresponding template's documentation. If it exists, the page should have [[Template:Examples|usage examples]] for every available feature. In fact, an effective way to write modules is actually to write the documentation examples before the code itself. When you're writing the actual code, previewing that documentation page will tell you if your code is working—and will give you material to debug with if it isn't. The practice of writing test cases before the code is called {{Wp|test-driven development}}.
When coding a module, the best page to preview is often the corresponding template's documentation. If it exists, the page should have [[Template:Examples|usage examples]] for every available feature. In fact, an effective way to write modules is actually to write the documentation examples before the code itself. When you're writing the actual code, previewing that documentation page will tell you if your code is working—and will give you material to debug with if it isn't. The practice of writing test cases before the code is called {{Wp|test-driven development}}.


You should also write [[Module:Documentation#Modules|module documentation]] for any Lua function meant to be used by other modules (as is usually the case for [[Guidelines:Modules#Utility Modules|utility module]] functions). Module documentation can double as automated unit tests via the [[Module:Documentation#Tests|<code>expected</code>]] property. If the output of the function does not equal what is expected, the page is added to [[:Category:Modules with failing tests]].
You should also write [[Module:Documentation#Modules|module documentation]] for any Lua function meant to be used by other modules. Module documentation can double as automated unit tests via the [[Module:Documentation#Tests|<code>expect</code>]] property. If the output of the function does not equal what is expected, the page is added to [[:Category:Modules with failing tests]].


==Utility Modules==
==Utility Modules==

Navigation menu