Upgrade to Pro — share decks privately, control downloads, hide ads and more …

RuhrJS 2016: InchJS

RuhrJS 2016: InchJS

René Föhring

July 02, 2016
Tweet

More Decks by René Föhring

Other Decks in Programming

Transcript

  1. // Returns a hash for a given `filenameOrBlob`. // //

    hash(filename) // => "68ac9064904d853a037a7a8f" function hash(filenameOrBlob, mode) { }
  2. // Returns a hash for a given `filenameOrBlob`. // //

    hash(filename) // => "68ac9064904d853a037a7a8f" function hash(filenameOrBlob, mode) { } free-form
  3. /** * Generates a hash for a given `filenameOrBlob`. *

    * @example * hash(filename) * => "68ac9064904d853a037a7a8f“ * * @param filenameOrBlob [String] the filename * @param mode [String,null] optional mode * @return [String,null] */ function hash(filenameOrBlob, mode) { } JSDoc
  4. // Public: Generates a hash for the blob. // //

    filenameOrBlob – filename or blob // mode - Optional mode (defaults to "SHA1") // // Examples // // size(filename) // => "68ac9064904d853a037a7a8f“ // // Returns String or null. function hash(filenameOrBlob, mode) { } TomDoc
  5. „good code is its own documentation“ (based on my early

    twenties) versus „people are not JavaScript parsers“ (based on Zach Holman)
  6. it is more important to document … longer functions than

    short ones functions with many parameters
  7. it is more important to document … longer functions than

    short ones functions with many parameters modules exporting functions
  8. it is more important to document … longer functions than

    short ones functions with many parameters modules containing functions ...
  9. # These rules provide priorities for all # code objects.

    const codeObjects = [ functions parameters ]; # ... which are also assigned a score. const scores = [0, 100];
  10. # Called by the `initech` service. # # @return [undefined]

    function userRegistered(username, _) { } Score: ? Priority: ?
  11. # Called by the `initech` service. # # @return [undefined]

    function userRegistered(username, _) { } Score: 90/100 Priority:
  12. # Called by the `initech` service. # # @return [undefined]

    function userRegistered(username, _) { } Score: 90/100 Priority:
  13. # Called by the `initech` service. # # @return [undefined]

    function userRegistered(username, _) { } Grade: A Priority:
  14. >> require('grade_list').getAll() A – Really good B – Proper documentation

    found C – Please take a look U – Undocumented (not a bad thing)
  15. # Properly documented, could be improved: ┃ 50 4 Foo#initialize

    ┃ 50 4 Foo.Bar # Please take a look: ┃ 37 4 Foo.API#initialize ┃ 25 2 Foo.CodeObject#initialize # Undocumented: ┃ 0 4 Foo.CLI ┃ 0 4 Foo.API#send_request
  16. # Properly documented, could be improved: ┃ B ↑ Foo#initialize

    ┃ B ↑ Foo.Bar # Please take a look: ┃ C ↑ Foo.API#initialize ┃ C ↗ Foo.CodeObject#initialize # Undocumented: ┃ U ↑ Foo.CLI ┃ U ↑ Foo.API#send_request