trulia / hologram

A markdown based documentation system for style guides.
http://trulia.github.io/hologram
Other
2.16k stars 200 forks source link

Export structure without generating HTML #195

Closed gakimball closed 9 years ago

gakimball commented 9 years ago

Hey guys, I'm doing a bit of research on documentation generation for the next version of the Foundation framework. Our needs are very specific because we combine HTML, Sass, and JavaScript documentation into one page.

Hologram looks super slick, and I'm curious to know if it's possible to get the raw data from the documentation parser, before it's compiled into HTML templates. I may or may not even need the Markdown formatted, I just need the data the parser collects for the templates. Basically I would eventually get it converted into JSON so I can mash it up with other documentation data generated by SassDoc and JSDoc.

It's all still speculative at the moment; I'm just exploring if it's possible with the tools out there. Thanks for your help!

gakimball commented 9 years ago

I spent some time tonight carefully examining the source code, and I was able to figure something out.

require 'hologram'
require 'json'

plugins = Hologram::Plugins.new({}, []);
parser = Hologram::DocParser.new('./scss', nil, plugins)
puts JSON.generate(parser.parse)

That lets me parse a directory without needing to set up any configuration or templating.

aflanagan commented 9 years ago

@gakimball I can't believe you found that! It's a secret @jdcantrell feature. :)

gakimball commented 9 years ago

Haha, I barely know how Ruby works, I just started at the unit tests for doc parsing and blindly derived backwards from there until it worked :)