mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-28 06:54:13 -04:00
Fixed #1961 (castDrainLife -> cast('drain-life') in the docs).
This commit is contained in:
parent
579e530c26
commit
e288b95543
2 changed files with 28 additions and 15 deletions
app
|
@ -73,17 +73,17 @@ if !selectedMethod
|
||||||
.docs-ace-container
|
.docs-ace-container
|
||||||
.docs-ace
|
.docs-ace
|
||||||
if language == 'javascript'
|
if language == 'javascript'
|
||||||
span= doc.owner + '.' + doc.name + '(' + argumentExamples.join(', ') + ');'
|
span= doc.owner + '.' + docName + '(' + argumentExamples.join(', ') + ');'
|
||||||
else if language == 'coffeescript'
|
else if language == 'coffeescript'
|
||||||
span= doc.ownerName + (doc.ownerName == '@' ? '' : '.') + doc.name + ' ' + argumentExamples.join(', ')
|
span= doc.ownerName + (doc.ownerName == '@' ? '' : '.') + docName + ' ' + argumentExamples.join(', ')
|
||||||
else if language == 'python'
|
else if language == 'python'
|
||||||
span= doc.ownerName + '.' + doc.name + '(' + argumentExamples.join(', ') + ')'
|
span= doc.ownerName + '.' + docName + '(' + argumentExamples.join(', ') + ')'
|
||||||
else if language == 'clojure'
|
else if language == 'clojure'
|
||||||
span= '(.' + doc.name + ' ' + doc.ownerName + ' ' + argumentExamples.join(', ') + ')'
|
span= '(.' + docName + ' ' + doc.ownerName + ' ' + argumentExamples.join(', ') + ')'
|
||||||
else if language == 'lua'
|
else if language == 'lua'
|
||||||
span= doc.ownerName + ':' + doc.name + '(' + argumentExamples.join(', ') + ')'
|
span= doc.ownerName + ':' + docName + '(' + argumentExamples.join(', ') + ')'
|
||||||
else if language == 'io'
|
else if language == 'io'
|
||||||
span= (doc.ownerName == 'this' ? '' : doc.ownerName + ' ') + doc.name + '(' + argumentExamples.join(', ') + ')'
|
span= (doc.ownerName == 'this' ? '' : doc.ownerName + ' ') + docName + '(' + argumentExamples.join(', ') + ')'
|
||||||
|
|
||||||
if (doc.type != 'function' && doc.type != 'snippet') || doc.name == 'now'
|
if (doc.type != 'function' && doc.type != 'snippet') || doc.name == 'now'
|
||||||
p.value
|
p.value
|
||||||
|
|
|
@ -55,16 +55,17 @@ module.exports = class DocFormatter
|
||||||
when 'coffeescript' then '@'
|
when 'coffeescript' then '@'
|
||||||
else 'this'
|
else 'this'
|
||||||
if @doc.type is 'function'
|
if @doc.type is 'function'
|
||||||
|
[docName, args] = @getDocNameAndArguments()
|
||||||
sep = {clojure: ' '}[@options.language] ? ', '
|
sep = {clojure: ' '}[@options.language] ? ', '
|
||||||
argNames = (arg.name for arg in @doc.args ? []).join sep
|
argNames = args.join sep
|
||||||
argString = if argNames then '__ARGS__' else ''
|
argString = if argNames then '__ARGS__' else ''
|
||||||
@doc.shortName = switch @options.language
|
@doc.shortName = switch @options.language
|
||||||
when 'coffeescript' then "#{ownerName}#{if ownerName is '@' then '' else '.'}#{@doc.name}#{if argString then ' ' + argString else '()'}"
|
when 'coffeescript' then "#{ownerName}#{if ownerName is '@' then '' else '.'}#{docName}#{if argString then ' ' + argString else '()'}"
|
||||||
when 'python' then "#{ownerName}.#{@doc.name}(#{argString})"
|
when 'python' then "#{ownerName}.#{docName}(#{argString})"
|
||||||
when 'lua' then "#{ownerName}:#{@doc.name}(#{argString})"
|
when 'lua' then "#{ownerName}:#{docName}(#{argString})"
|
||||||
when 'clojure' then "(.#{@doc.name} #{ownerName}#{if argNames then ' ' + argString else ''})"
|
when 'clojure' then "(.#{docName} #{ownerName}#{if argNames then ' ' + argString else ''})"
|
||||||
when 'io' then "#{if ownerName is 'this' then '' else ownerName + ' '}#{@doc.name}#{if argNames then '(' + argNames + ')' else ''}"
|
when 'io' then "#{if ownerName is 'this' then '' else ownerName + ' '}#{docName}#{if argNames then '(' + argNames + ')' else ''}"
|
||||||
else "#{ownerName}.#{@doc.name}(#{argString});"
|
else "#{ownerName}.#{docName}(#{argString});"
|
||||||
else
|
else
|
||||||
@doc.shortName = switch @options.language
|
@doc.shortName = switch @options.language
|
||||||
when 'coffeescript' then "#{ownerName}#{if ownerName is '@' then '' else '.'}#{@doc.name}"
|
when 'coffeescript' then "#{ownerName}#{if ownerName is '@' then '' else '.'}#{@doc.name}"
|
||||||
|
@ -76,7 +77,7 @@ module.exports = class DocFormatter
|
||||||
@doc.shorterName = @doc.shortName
|
@doc.shorterName = @doc.shortName
|
||||||
if @doc.type is 'function' and argString
|
if @doc.type is 'function' and argString
|
||||||
@doc.shortName = @doc.shorterName.replace argString, argNames
|
@doc.shortName = @doc.shorterName.replace argString, argNames
|
||||||
@doc.shorterName = @doc.shorterName.replace argString, (if argNames.length > 6 then '...' else argNames)
|
@doc.shorterName = @doc.shorterName.replace argString, (if not /cast[A-Z]/.test(@doc.name) and argNames.length > 6 then '...' else argNames)
|
||||||
if @options.language is 'javascript'
|
if @options.language is 'javascript'
|
||||||
@doc.shorterName = @doc.shortName.replace ';', ''
|
@doc.shorterName = @doc.shortName.replace ';', ''
|
||||||
if @doc.owner is 'this' or @options.tabbify
|
if @doc.owner is 'this' or @options.tabbify
|
||||||
|
@ -119,7 +120,10 @@ module.exports = class DocFormatter
|
||||||
obj[prop] = @replaceSpriteName obj[prop] # Do this before using the template, otherwise marked might get us first.
|
obj[prop] = @replaceSpriteName obj[prop] # Do this before using the template, otherwise marked might get us first.
|
||||||
|
|
||||||
formatPopover: ->
|
formatPopover: ->
|
||||||
content = popoverTemplate doc: @doc, language: @options.language, value: @formatValue(), marked: marked, argumentExamples: (arg.example or arg.default or arg.name for arg in @doc.args ? []), writable: @options.writable, selectedMethod: @options.selectedMethod, cooldowns: @inferCooldowns(), item: @options.item
|
[docName, args] = @getDocNameAndArguments()
|
||||||
|
argumentExamples = (arg.example or arg.default or arg.name for arg in @doc.args ? [])
|
||||||
|
argumentExamples.unshift args[0] if args.length > argumentExamples.length
|
||||||
|
content = popoverTemplate doc: @doc, docName: docName, language: @options.language, value: @formatValue(), marked: marked, argumentExamples: argumentExamples, writable: @options.writable, selectedMethod: @options.selectedMethod, cooldowns: @inferCooldowns(), item: @options.item
|
||||||
owner = if @doc.owner is 'this' then @options.thang else window[@doc.owner]
|
owner = if @doc.owner is 'this' then @options.thang else window[@doc.owner]
|
||||||
content = @replaceSpriteName content
|
content = @replaceSpriteName content
|
||||||
content.replace /\#\{(.*?)\}/g, (s, properties) => @formatValue downTheChain(owner, properties.split('.'))
|
content.replace /\#\{(.*?)\}/g, (s, properties) => @formatValue downTheChain(owner, properties.split('.'))
|
||||||
|
@ -130,6 +134,15 @@ module.exports = class DocFormatter
|
||||||
name = 'hero' if /Hero Placeholder/.test @options.thang.id
|
name = 'hero' if /Hero Placeholder/.test @options.thang.id
|
||||||
s.replace /#{spriteName}/g, name
|
s.replace /#{spriteName}/g, name
|
||||||
|
|
||||||
|
getDocNameAndArguments: ->
|
||||||
|
return [@doc.name, []] unless @doc.type is 'function'
|
||||||
|
docName = @doc.name
|
||||||
|
args = (arg.name for arg in @doc.args ? [])
|
||||||
|
if /cast[A-Z]/.test docName
|
||||||
|
docName = 'cast'
|
||||||
|
args.unshift '"' + _.string.dasherize(@doc.name).replace('cast-', '') + '"'
|
||||||
|
[docName, args]
|
||||||
|
|
||||||
formatValue: (v) ->
|
formatValue: (v) ->
|
||||||
return null if @doc.type is 'snippet'
|
return null if @doc.type is 'snippet'
|
||||||
return @options.thang.now() if @doc.name is 'now'
|
return @options.thang.now() if @doc.name is 'now'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue