mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-26 05:53:39 -04:00
More fixes to documentation popovers.
This commit is contained in:
parent
906ab3ac2b
commit
6e9091fdf0
5 changed files with 37 additions and 30 deletions
app
templates/play/level/tome
views/play/level/tome
|
@ -3,30 +3,34 @@ h4
|
|||
| -
|
||||
code.prop-type= doc.type == 'function' && doc.owner == 'this' ? 'method' : doc.type
|
||||
if doc.type != 'function'
|
||||
| (read-only)
|
||||
if writable
|
||||
| (writable)
|
||||
else
|
||||
| (read-only)
|
||||
|
||||
.description!= marked(doc.description || 'Still undocumented, sorry.')
|
||||
|
||||
if doc.example
|
||||
p.example
|
||||
strong Example:
|
||||
div!= marked("```\n" + doc.example + "```")
|
||||
else if doc.type == 'function' && argumentExamples.length
|
||||
p.example
|
||||
strong Example:
|
||||
div
|
||||
if language == 'javascript'
|
||||
code= doc.owner + '.' + doc.name + '(' + argumentExamples.join(', ') + ');'
|
||||
else if language == 'coffeescript'
|
||||
code= doc.ownerName + (doc.ownerName == '@' ? '' : '.') + doc.name + ' ' + argumentExamples.join(', ')
|
||||
else if language == 'python'
|
||||
code= doc.ownerName + '.' + doc.name + '(' + argumentExamples.join(', ') + ')'
|
||||
else if language == 'clojure'
|
||||
code= '(.' + doc.name + ' ' + doc.ownerName + ' ' + argumentExamples.join(', ') + ')'
|
||||
else if language == 'lua'
|
||||
code= doc.ownerName + ':' + doc.name + '(' + argumentExamples.join(', ') + ')'
|
||||
else if language == 'io'
|
||||
code= (doc.ownerName == 'this' ? '' : doc.ownerName + ' ') + doc.name + '(' + argumentExamples.join(', ') + ')'
|
||||
if !selectedMethod
|
||||
if doc.example
|
||||
p.example
|
||||
strong Example:
|
||||
div!= marked("```\n" + doc.example + "```")
|
||||
else if doc.type == 'function' && argumentExamples.length
|
||||
p.example
|
||||
strong Example:
|
||||
div
|
||||
if language == 'javascript'
|
||||
code= doc.owner + '.' + doc.name + '(' + argumentExamples.join(', ') + ');'
|
||||
else if language == 'coffeescript'
|
||||
code= doc.ownerName + (doc.ownerName == '@' ? '' : '.') + doc.name + ' ' + argumentExamples.join(', ')
|
||||
else if language == 'python'
|
||||
code= doc.ownerName + '.' + doc.name + '(' + argumentExamples.join(', ') + ')'
|
||||
else if language == 'clojure'
|
||||
code= '(.' + doc.name + ' ' + doc.ownerName + ' ' + argumentExamples.join(', ') + ')'
|
||||
else if language == 'lua'
|
||||
code= doc.ownerName + ':' + doc.name + '(' + argumentExamples.join(', ') + ')'
|
||||
else if language == 'io'
|
||||
code= (doc.ownerName == 'this' ? '' : doc.ownerName + ' ') + doc.name + '(' + argumentExamples.join(', ') + ')'
|
||||
|
||||
if (doc.type != 'function' && doc.type != 'snippet') || doc.name == 'now'
|
||||
p.value
|
||||
|
@ -64,3 +68,7 @@ if doc.returns
|
|||
| )
|
||||
if doc.returns.description
|
||||
div!= marked(doc.returns.description)
|
||||
|
||||
if selectedMethod
|
||||
p
|
||||
em Write the body of this method below.
|
|
@ -93,7 +93,7 @@ module.exports = class DocFormatter
|
|||
obj[prop] = null
|
||||
|
||||
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 ? [])
|
||||
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
|
||||
owner = if @doc.owner is 'this' then @options.thang else window[@doc.owner]
|
||||
content = content.replace /#{spriteName}/g, @options.thang.type ? @options.thang.spriteName # Prefer type, and excluded the quotes we'd get with @formatValue
|
||||
content.replace /\#\{(.*?)\}/g, (s, properties) => @formatValue downTheChain(owner, properties.split('.'))
|
||||
|
|
|
@ -61,7 +61,7 @@ module.exports = class SpellListTabEntryView extends SpellListEntryView
|
|||
found = true
|
||||
break
|
||||
return unless found
|
||||
docFormatter = new DocFormatter doc: doc, thang: @thang, language: @options.language
|
||||
docFormatter = new DocFormatter doc: doc, thang: @thang, language: @options.language, selectedMethod: true
|
||||
@$el.find('code').popover(
|
||||
animation: true
|
||||
html: true
|
||||
|
|
|
@ -59,7 +59,7 @@ module.exports = class SpellPaletteView extends View
|
|||
for lc in lcs
|
||||
for doc in (lc.get('propertyDocumentation') ? [])
|
||||
if doc.codeLanguages and not (@options.language in doc.codeLanguages)
|
||||
excludedDocs[doc.name] = doc
|
||||
excludedDocs['__' + doc.name] = doc
|
||||
continue
|
||||
allDocs['__' + doc.name] ?= []
|
||||
allDocs['__' + doc.name].push doc
|
||||
|
@ -103,8 +103,8 @@ module.exports = class SpellPaletteView extends View
|
|||
doc = _.find (allDocs['__' + prop] ? []), (doc) ->
|
||||
return true if doc.owner is owner
|
||||
return (owner is 'this' or owner is 'more') and (not doc.owner? or doc.owner is 'this')
|
||||
if not doc and not excludedDocs[prop]
|
||||
console.log 'could not find doc for', prop, 'from', allDocs['__' + prop], 'for', owner, 'of', propGroups unless doc
|
||||
if not doc and not excludedDocs['__' + prop]
|
||||
console.log 'could not find doc for', prop, 'from', allDocs['__' + prop], 'for', owner, 'of', propGroups
|
||||
doc ?= prop
|
||||
if doc
|
||||
@entries.push @addEntry(doc, shortenize, tabbify, owner is 'snippets')
|
||||
|
@ -135,7 +135,8 @@ module.exports = class SpellPaletteView extends View
|
|||
null
|
||||
|
||||
addEntry: (doc, shortenize, tabbify, isSnippet=false) ->
|
||||
new SpellPaletteEntryView doc: doc, thang: @thang, shortenize: shortenize, tabbify: tabbify, isSnippet: isSnippet, language: @options.language
|
||||
writable = (if _.isString(doc) then doc else doc.name) in (@thang.apiUserProperties ? [])
|
||||
new SpellPaletteEntryView doc: doc, thang: @thang, shortenize: shortenize, tabbify: tabbify, isSnippet: isSnippet, language: @options.language, writable: writable
|
||||
|
||||
onDisableControls: (e) -> @toggleControls e, false
|
||||
onEnableControls: (e) -> @toggleControls e, true
|
||||
|
|
|
@ -179,9 +179,7 @@ module.exports = class SpellView extends View
|
|||
doc = _.find (e.allDocs['__' + prop] ? []), (doc) ->
|
||||
return true if doc.owner is owner
|
||||
return (owner is 'this' or owner is 'more') and (not doc.owner? or doc.owner is 'this')
|
||||
console.log 'could not find doc for', prop, 'from', e.allDocs['__' + prop], 'for', owner, 'of', e.propGroups unless doc
|
||||
doc ?= prop
|
||||
if doc.snippets?[e.language]
|
||||
if doc?.snippets?[e.language]
|
||||
entry =
|
||||
content: doc.snippets[e.language].code
|
||||
name: doc.name
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue