mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 09:35:39 -05:00
Replace simple loop docs with while-true docs in course levels
This commit is contained in:
parent
8d43be2236
commit
4af6162c5c
1 changed files with 22 additions and 0 deletions
|
@ -124,6 +124,28 @@ module.exports = class DocFormatter
|
|||
console.error "Couldn't create docs template of", val, "\nwith context", context, "\nError:", e
|
||||
obj[prop] = @replaceSpriteName obj[prop] # Do this before using the template, otherwise marked might get us first.
|
||||
|
||||
if @doc.shortName is 'loop' and @options.level.get('type', true) in ['course', 'course-ladder']
|
||||
@replaceSimpleLoops()
|
||||
|
||||
replaceSimpleLoops: ->
|
||||
# Temporary hackery to make it look like we meant while True: in our loop: docs until we can update everything
|
||||
@doc.shortName = @doc.shorterName = @doc.title = @doc.name = switch @options.language
|
||||
when 'coffeescript' then "loop"
|
||||
when 'python' then "while True:"
|
||||
when 'lua' then "while true do"
|
||||
when 'clojure' then "(while true)"
|
||||
when 'io' then "while(true)"
|
||||
else "while (true)"
|
||||
for field in ['example', 'description']
|
||||
[simpleLoop, whileLoop] = switch @options.language
|
||||
when 'coffeescript' then [/loop/g, "loop"]
|
||||
when 'python' then [/loop:/g, "while True:"]
|
||||
when 'lua' then [/loop/g, "while true do"]
|
||||
when 'clojure' then [/\(dotimes( \[n \d+\])?/g, "(while true"]
|
||||
when 'io' then [/loop\(/g, "while(true,"]
|
||||
else [/loop/g, "while (true)"]
|
||||
@doc[field] = @doc[field].replace simpleLoop, whileLoop
|
||||
|
||||
formatPopover: ->
|
||||
[docName, args] = @getDocNameAndArguments()
|
||||
argumentExamples = (arg.example or arg.default or arg.name for arg in @doc.args ? [])
|
||||
|
|
Loading…
Reference in a new issue