straker / livingcss

Parse comments in your CSS to generate a living style guide using Markdown, Handlebars, Polymer, and Prism syntax highlighter.
MIT License
241 stars 21 forks source link

Question: output only JSON? #24

Closed lancetharper closed 7 years ago

lancetharper commented 8 years ago

I'm piggy backing off of the generated JSON to create snippets for various editors for a team to use.

I'm using gulp-livingcss and wondered if there was a way to get just the JSON for the sections returned that I could then pipe into something else to generate the snippets. I'm currently just grabbing the context.sections from preprocess and saving it out to a file, but I'd rather not have this intermediate step of saving to a file then reading from it and do it the more correct way with streams.

Is there a way to do this currently?

straker commented 8 years ago

So if I understand correctly you're looking to do something like this?

gulp.src('styles.css')
  .pipe(livingcss())  // returns a stream of JSON
  .pipe(createSnippet())
lancetharper commented 8 years ago

Yes, this exactly.

straker commented 8 years ago

Currently there is no way to do this. The current script returns a steam of html files so you can set the gulp.dest on them. I can look into setting an option in gulp to return a stream of JSON instead.

lancetharper commented 8 years ago

That would be amazing! I just saw in the docs that it mentioned generating a JSON object and wanted to make sure I wasn't missing some obvious way of getting to it without having to save it out to a file like I currently am.

straker commented 7 years ago

So sorry it's taken me so long to get back to this. I got really busy and kinda lost track of this. I just wanted to verify some requirements before I implemented the request just to make sure it makes sense.

So I can add an option to return just the context, but since gulp works with streams of files the returned stream would be JSON files that contain the context object, one for each page. Would that be sufficient for your use case?

lancetharper commented 7 years ago

It probably would be, I'd just need to rework my own gulp plugins. The way I'm doing it was working for me and I haven't had to update it yet (also haven't been working on it for a few months) so I'm not sure when I'd be circling back around to revisit this in my own project.

If it's easy to implement or you see some added value to it beyond my request; feel free to do it that way. But I wouldn't make it a high priority for yourself for now.