Skip to content
osteele edited this page Oct 11, 2012 · 43 revisions

Since version 3.0 JSDuck implements support for custom tags - meant for marking up class-level metadata like author, date, license, version, etc. Each tag is implemented as a Ruby class extending from JsDuck::MetaTag (see the file for lots of documentation in there, also look at the implementation of builtin tags). Here's an example implementation of a @license tag:

    require "jsduck/meta_tag"

    class LicenseTag < JsDuck::MetaTag
      def initialize
        # This defines the name of the @tag
        @name = "license"
        # Without this, tag contents will end at first newline
        @multiline = true
      end

      # This will be called with an array of all @license tags on one class.
      # One can make use of the #format method to easily support
      # Markdown and {@link} tags inside the contents of the tag.
      def to_html(licenses)
        "<h2>Licenses:</h2>" + licenses.map {|lic| format(lic) }.join("\n")
      end
    end

You then pass the path of this file through --meta-tags option to JSDuck.

Clone this wiki locally