playgroundbooks / playgroundbook

Tool for Swift Playground books
https://ashfurrow.com/blog/swift-playground-books/
MIT License
259 stars 17 forks source link

Warn on malformed special comments #11

Open ashfurrow opened 8 years ago

ashfurrow commented 8 years ago

Specially comments to direct the user start with //#-, we should warn if the string following that doesn't match a known pattern.

screen shot 2016-07-20 at 10 03 50 am screen shot 2016-07-20 at 10 03 24 am screen shot 2016-07-20 at 10 03 14 am
rhysforyou commented 8 years ago

What's the best way to implement this? Are there any nice gems that offer similar functionality to SourceKitten, or do we want to attempt to use regexps instead?

ashfurrow commented 8 years ago

I was thinking regular expressions, check for /*#- and */ (or //#-\n) and see if the middle bits match a known pattern.

Gee, soon we might have to start allowing users to opt-out of some rules 🤔 But not now, we can worry about that later 😅

rhysforyou commented 8 years ago

Yeah at some point we'll probably want to break 'rules' out into their own discrete objects to make that stuff easier, but we'll see how far we can get before that refactor's necessary.