From: Ċ½eljko Filipin Date: Wed, 18 Mar 2015 17:45:54 +0000 (+0100) Subject: Fixed Style/FileName RuboCop offense X-Git-Tag: 1.31.0-rc.0~12014^2~3 X-Git-Url: http://git.cyclocoop.org//%27%40script%40/%27?a=commitdiff_plain;h=2cc78fd8f8f3d5720b8649c9c66c74c1cad8a6cb;p=lhc%2Fweb%2Fwiklou.git Fixed Style/FileName RuboCop offense $ bundle exec rubocop Inspecting 25 files .C....................... Offenses: maintenance/jsduck/CustomTags.rb:1:1: C: Use snake_case for source file names. ^ 25 files inspected, 1 offense detected Bug: T91485 Change-Id: I91b43362f265a05284495727dab5465e1c4f0542 --- diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 58cee0c18f..da1c3af036 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -10,11 +10,6 @@ Lint/UnusedMethodArgument: Enabled: false -# Offense count: 1 -# Configuration parameters: Exclude. -Style/FileName: - Enabled: false - # Offense count: 8 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. diff --git a/jsduck.json b/jsduck.json index 67ab986f82..53c69133fe 100644 --- a/jsduck.json +++ b/jsduck.json @@ -2,7 +2,7 @@ "--title": "MediaWiki core - Documentation", "--categories": "maintenance/jsduck/categories.json", "--eg-iframe": "maintenance/jsduck/eg-iframe.html", - "--tags": "maintenance/jsduck/CustomTags.rb", + "--tags": "maintenance/jsduck/custom_tags.rb", "--warnings": ["-nodoc(class,public)"], "--builtin-classes": true, "--processes": "0", diff --git a/maintenance/jsduck/CustomTags.rb b/maintenance/jsduck/CustomTags.rb deleted file mode 100644 index 2de3ac0e9f..0000000000 --- a/maintenance/jsduck/CustomTags.rb +++ /dev/null @@ -1,116 +0,0 @@ -# Custom tags for JSDuck 5.x -# See also: -# - https://github.com/senchalabs/jsduck/wiki/Tags -# - https://github.com/senchalabs/jsduck/wiki/Custom-tags -# - https://github.com/senchalabs/jsduck/wiki/Custom-tags/7f5c32e568eab9edc8e3365e935bcb836cb11f1d -require 'jsduck/tag/tag' - -class CommonTag < JsDuck::Tag::Tag - def initialize - @html_position = POS_DOC + 0.1 - @repeatable = true - end - - def parse_doc(scanner, position) - if @multiline - return { :tagname => @tagname, :doc => :multiline } - else - text = scanner.match(/.*$/) - return { :tagname => @tagname, :doc => text } - end - end - - def process_doc(context, tags, position) - context[@tagname] = tags - end - - def format(context, formatter) - context[@tagname].each do |tag| - tag[:doc] = formatter.format(tag[:doc]) - end - end -end - -class SourceTag < CommonTag - def initialize - @tagname = :source - @pattern = "source" - super - end - - def to_html(context) - context[@tagname].map do |source| - <<-EOHTML -

Source

- #{source[:doc]} - EOHTML - end.join - end -end - -class SeeTag < CommonTag - def initialize - @tagname = :see - @pattern = "see" - super - end - - def format(context, formatter) - position = context[:files][0] - context[@tagname].each do |tag| - tag[:doc] = '
  • ' + render_long_see(tag[:doc], formatter, position) + '
  • ' - end - end - - def to_html(context) - <<-EOHTML -

    Related

    - - EOHTML - end - - def render_long_see(tag, formatter, position) - if tag =~ /\A([^\s]+)( .*)?\Z/m - name = $1 - doc = $2 ? ': ' + $2 : '' - return formatter.format("{@link #{name}} #{doc}") - else - JsDuck::Logger.warn(nil, 'Unexpected @see argument: "' + tag + '"', position) - return tag - end - end -end - -class ContextTag < CommonTag - def initialize - @tagname = :context - @pattern = 'context' - super - end - - def format(context, formatter) - position = context[:files][0] - context[@tagname].each do |tag| - tag[:doc] = render_long_context(tag[:doc], formatter, position) - end - end - - def to_html(context) - <<-EOHTML -

    Context

    - #{ context[@tagname].last[:doc] } - EOHTML - end - - def render_long_context(tag, formatter, position) - if tag =~ /\A([^\s]+)/m - name = $1 - return formatter.format("`context` : {@link #{name}}") - else - JsDuck::Logger.warn(nil, 'Unexpected @context argument: "' + tag + '"', position) - return tag - end - end -end diff --git a/maintenance/jsduck/custom_tags.rb b/maintenance/jsduck/custom_tags.rb new file mode 100644 index 0000000000..2de3ac0e9f --- /dev/null +++ b/maintenance/jsduck/custom_tags.rb @@ -0,0 +1,116 @@ +# Custom tags for JSDuck 5.x +# See also: +# - https://github.com/senchalabs/jsduck/wiki/Tags +# - https://github.com/senchalabs/jsduck/wiki/Custom-tags +# - https://github.com/senchalabs/jsduck/wiki/Custom-tags/7f5c32e568eab9edc8e3365e935bcb836cb11f1d +require 'jsduck/tag/tag' + +class CommonTag < JsDuck::Tag::Tag + def initialize + @html_position = POS_DOC + 0.1 + @repeatable = true + end + + def parse_doc(scanner, position) + if @multiline + return { :tagname => @tagname, :doc => :multiline } + else + text = scanner.match(/.*$/) + return { :tagname => @tagname, :doc => text } + end + end + + def process_doc(context, tags, position) + context[@tagname] = tags + end + + def format(context, formatter) + context[@tagname].each do |tag| + tag[:doc] = formatter.format(tag[:doc]) + end + end +end + +class SourceTag < CommonTag + def initialize + @tagname = :source + @pattern = "source" + super + end + + def to_html(context) + context[@tagname].map do |source| + <<-EOHTML +

    Source

    + #{source[:doc]} + EOHTML + end.join + end +end + +class SeeTag < CommonTag + def initialize + @tagname = :see + @pattern = "see" + super + end + + def format(context, formatter) + position = context[:files][0] + context[@tagname].each do |tag| + tag[:doc] = '
  • ' + render_long_see(tag[:doc], formatter, position) + '
  • ' + end + end + + def to_html(context) + <<-EOHTML +

    Related

    + + EOHTML + end + + def render_long_see(tag, formatter, position) + if tag =~ /\A([^\s]+)( .*)?\Z/m + name = $1 + doc = $2 ? ': ' + $2 : '' + return formatter.format("{@link #{name}} #{doc}") + else + JsDuck::Logger.warn(nil, 'Unexpected @see argument: "' + tag + '"', position) + return tag + end + end +end + +class ContextTag < CommonTag + def initialize + @tagname = :context + @pattern = 'context' + super + end + + def format(context, formatter) + position = context[:files][0] + context[@tagname].each do |tag| + tag[:doc] = render_long_context(tag[:doc], formatter, position) + end + end + + def to_html(context) + <<-EOHTML +

    Context

    + #{ context[@tagname].last[:doc] } + EOHTML + end + + def render_long_context(tag, formatter, position) + if tag =~ /\A([^\s]+)/m + name = $1 + return formatter.format("`context` : {@link #{name}}") + else + JsDuck::Logger.warn(nil, 'Unexpected @context argument: "' + tag + '"', position) + return tag + end + end +end