galaxykate / tracery

Tracery: a story-grammar generation library for javascript
Apache License 2.0
2.12k stars 251 forks source link

Put tracery up on npm #9

Closed v21 closed 8 years ago

v21 commented 8 years ago

I've not looked properly at this, but from my previous experience, the problems I had were largely down to code that implicitly depended on globals defined elsewhere (ie, jQuery, or other parts of the library). npm uses, as good practice(?) things like this: var local = require('dependency');

Previously, I just took a hacksaw to the library and glommed it into a single file, stripped out any external dependencies, and hacked out all the AMD stuff, but this time round it'd be good to keep the two versions a bit more in sync (or even identical)

There's a further stage to this, which is somewhat separate, which is to test for breaking changes in the syntax against the current CBDQ corpus. The only one I can think of off the top of my head is //, but it's worth thinking of a way to look for others.

galaxykate commented 8 years ago

Ok, this one is AMD-free, and should 'just work' with no dependencies, JQuery is only needed if you run the test functions.

It's in a closure, so everything will be inside the 'tracery' global-scope object. The other issue is that I split out the modifiers into mods-eng-basic.js (goal: be less english-centric), so you have to add import those separately, like this:

app.grammar = tracery.createGrammar();
app.grammar.addModifiers(baseEngModifiers);
galaxykate commented 8 years ago

Also, this one is a single file. Last time I was trying to use Require, but I think I need an actual expert in it to show me how to do it properly (next hackathon I'll bribe someone)

v21 commented 8 years ago

It's done! It's got some manual changes, though, :< https://github.com/v21/tracery/commit/e44886274798cd9629531c7becb6e2155ab48134

galaxykate commented 8 years ago

Oh, I literally just pushed a new version:

Other than that, not much in the way of changes, though. https://github.com/galaxykate/tracery/tree/tracery2

On Tue, Jan 5, 2016 at 3:58 PM, George Buckenham notifications@github.com wrote:

It's done! It's got some manual changes, though, :< v21@e448862 https://github.com/v21/tracery/commit/e44886274798cd9629531c7becb6e2155ab48134

— Reply to this email directly or view it on GitHub https://github.com/galaxykate/tracery/issues/9#issuecomment-169173112.

v21 commented 8 years ago

ah, beautiful!