diff --git a/app/views/play/level/tome/DocFormatter.coffee b/app/views/play/level/tome/DocFormatter.coffee index 52c0e35d1..79cee141b 100644 --- a/app/views/play/level/tome/DocFormatter.coffee +++ b/app/views/play/level/tome/DocFormatter.coffee @@ -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 ? [])